Jump to content

  • Log In with Google      Sign In   
  • Create Account

Photo

Halloween Motion Triggered Sound and Light Thingamajig


  • Please log in to reply
12 replies to this topic

#1 DanAndDusty

DanAndDusty

    Level 1

  • Members
  • 120 posts
  • LocationSussex, UK

Posted 24 October 2011 - 12:45 AM

Hi all,

For Halloween this year I wanted to make a motion triggered device that screams at you and makes some UV lights flash/flicker.

Here is a video of the device in action.


My first thought was to use an SD Card but I couldn't get this to work (this was my first attempt with the hardware UART and I have a feeling I may be able to get a little further now.. so who knows)

When the attempt with the SD Card failed I decided to use a 25AA1024 SPI 1Mbit EEPROM. As the EEPROM doesn't connect directly to a PC I needed a way to get the sound files onto the device. So I added a serial control menu that allows uploading via XMODEM. I chose XMODEM as the packet size is only 128 bytes, the protocol requirements are minimal and just about every comms program has the protocol built it. Because of the 128 bytes for the buffer and the serial requirements I used a G2553. For the serial comms I used an FT232 breakout circuit running at 460800 baud and she screams along happily. I have also tried it using the UART->USB of the launchpad at 9600 and it works there too, albeit much slower.

Once the sound data is on the eeprom I store it as 8 bit unsigned raw samples. These I send out to a DAC. The only DAC I had to hand was a MAX5159. The only problem with this was there is an internal gain of 2x. So I had to divide Vcc by 2 to provide the DACs reference. Easy I thought.. Voltage Divider to the rescue.. However when I tried this I found that the voltage would jump about over quite a largish range. Further reading of the 5159 datasheet unearthed this little tidbit.. The reference input impedance ranges from 18k ohms (1558 hex) to several giga ohms.. Ouch... Thats gunna throw my little voltage divider off a little.. So I remember reading at some point that op-amps can be used to buffer inputs for just such situations. Ive not used an op-amp before but had a few LM324 quad op-amps to hand. Set one of the devices up as a voltage follower and bingo.. She worked.. I pass the output from the DAC through an AC Coupling Capacitor into a computer speaker amplifier. The quality isn't suitable for an audiophile but for this it works wonders.

I also wanted some flashing lights.. (hey.. who doesn't like flashing lights).. I wanted these to flash roughly in time with the audio. So after a sound file has been uploaded the 430 runs a very simplistic peak counting routine. It finds the highest peak that occurs atleast 40 times in the sound file. It only checks the highest so the deepest trough won't trigger it, but Im happy with the results. When the sound is played back, each time this peak value is passed the lights are triggered. I used 10 UV LEDs driven via an NPN Transistor. The voltage drop of the transistor meant that they weren't as bright as I would like at 3.3V so I power them from 4 rechargeable AA batteries (4.8-5.0v ish) and use a 3.3V LDO for the rest of the circuit. The batteries Im using are 2900 mAh ones and during my testing they have been running the device for a week with no sign of giving out. So lasting all night shouldn't be a worry :smile:

To trigger the sounds Im using an LDR as the lower resistor of a voltage divider. I compare this voltage to one from a potentiometer (for adjusting to different light levels) using another device in the LM324 quad op-amp. This triggers an interrupt on a pin on P2. For feedback on adjusting the pot I use another op-amp triggered from the same voltages to drive an LED. Adjust the pot until the LED comes on.. back off a little so it has just turned off and bingo.. Its primed and ready. There will be a light source the other side of the (narrow) garden that will be blocked by someone walking past it and this will trigger the playback of the sound/light combo.

Because I don't want to have a PC down in the garden to setup I added a "playback" mode which is triggered if P2.4 is tied high at power on.

Future changes that may (or may not.. depending on time free and success) include...
Using an SD Card to store the sound samples. The EEPROM is 1MBit or 128KBytes. at 22KHz 8 bits this can store less than 6 seconds of sound.
Compressing the sound files using something simple like uLaw or ADPCM. I have no experience with sound compression so lets see how this goes.
Adding an audio amplifier circuit At the moment the audio is amplified using PC speakers with built in amplifier. If I can add this to the circuit it would be neater. I tried this using an LM386 but the quality was abysmal. Im still getting my head around analogue circuitry so Its not a total surprise :smile:

When the POTM is announced I think I'll enter this as its not often I document my projects as detailed as I should. I tend to leap on to the next brain spasm. This time though, the code is neatish and well documented. Im even drawing up a schematic over the next couple of nights (never used eagle before so bear with me on this)

Hope you enjoyed my little ramble, over the next few nights I should be posting the code and schematic. For now though I am off to bed.

Enjoy,

Dan


  • bluehash, timotet, RobG and 3 others like this

#2 bluehash

bluehash

    Site Admin

  • Administrators
  • 5,451 posts

Posted 24 October 2011 - 04:11 PM

D&D,
Job well done! Nicely explained in the video. Thanks for writing all this up.

Stellarisiti - Join the new Tiva-C/Stellaris ARM Forums discussing Tiva-C(Stellaris) Microcontrollers.

C2kCentral - C2000 News, Projects and Forums
43oh - MSP430 Discussion, News, Projects and Hacks
MachineGrid - Robots, Hacks and Technology!


#3 RobG

RobG

    Level 5

  • Members
  • 2,811 posts
  • LocationCary, NC, US


Posted 24 October 2011 - 04:51 PM

We should have POTM Halloween edition :) PftH

#4 bluehash

bluehash

    Site Admin

  • Administrators
  • 5,451 posts

Posted 24 October 2011 - 05:28 PM

I was supposed to do it, but was unable to pull it out. Next year, we sure will have one.

Stellarisiti - Join the new Tiva-C/Stellaris ARM Forums discussing Tiva-C(Stellaris) Microcontrollers.

C2kCentral - C2000 News, Projects and Forums
43oh - MSP430 Discussion, News, Projects and Hacks
MachineGrid - Robots, Hacks and Technology!


#5 MarkoeZ

MarkoeZ

    Level 2

  • Members
  • 228 posts
  • LocationNetherlands

Posted 24 October 2011 - 06:01 PM

Great project!

Also very informative video and description.

Thanks
My Site/Blog/Projects Page: http://www.markoez.com

#6 DanAndDusty

DanAndDusty

    Level 1

  • Members
  • 120 posts
  • LocationSussex, UK

Posted 24 October 2011 - 07:16 PM

Glad you guys seem to be liking it. As promised here is the schematic. Its my first time producing anything in eagle so any suggestions would be appreciated. Please note that although the schematic doesn't show it... There is an AC Coupling capacitor on the speaker/amplifier connection.

HalloweenSchematic.png

I'll upload the code over the next day or so when I can get to that PC..

#7 DanAndDusty

DanAndDusty

    Level 1

  • Members
  • 120 posts
  • LocationSussex, UK

Posted 24 October 2011 - 07:18 PM

I was supposed to do it, but was unable to pull it out. Next year, we sure will have one.


Shame BH.. Im sure there are gunna be some interesting Halloween projects round here.

#8 timotet

timotet

    Level 1

  • Members
  • 146 posts
  • LocationBend , Oregon

Posted 24 October 2011 - 11:08 PM

great job! nice work using the op amps.
Ive done a couple of projects with the lm386 and been impressed with the results dont give up on it.

#9 DanAndDusty

DanAndDusty

    Level 1

  • Members
  • 120 posts
  • LocationSussex, UK

Posted 24 October 2011 - 11:11 PM

OK.. Here is the code.. There is a separate header/code file for each section/device.. So we have

EEPROM_USCI.c/h - Contains the main flow of the project
25AA1024.c/h - Contains the routines for talking to the EEPROM (25AA1024)
MAX5159.c/h - Contains the routines for talking to the DAC (MAX5159)
USCI_UART.c/h - Contains routines for sending stuff through the serial port (Uses USCI on the 2553)
xmodem.c.h - The "Fun" part of the project for me.. Routines for receiving a file using xmodem.

[attachment=0]Zipped Source Here[/attachment]

BTW BH.. I see I made it to the front of the blog.. Thanks for that. (Veteran member.. Woot :) )

Attached Files


  • bluehash, RobG, Rickta59 and 1 other like this

#10 Rickta59

Rickta59

    Level 3

  • Global Moderators
  • 746 posts
  • LocationEastern NC


Posted 25 October 2011 - 12:33 AM

Great stuff!

What program are you using to create the sound files that get uploaded?

#11 DanAndDusty

DanAndDusty

    Level 1

  • Members
  • 120 posts
  • LocationSussex, UK

Posted 25 October 2011 - 02:02 AM

Great stuff!

What program are you using to create the sound files that get uploaded?


Im using Audacity.. I use the export->Other Uncompressed Files->Raw Unsigned 8 bit PCM

#12 username

username

    Level 2

  • Members
  • 276 posts


Posted 08 November 2011 - 07:51 AM

Very impressive work there! ... but for Gods sake how on earth did you learn to use EEPROM and DACs before learning how to use an op amp? I assume you work in software?

Verryy cool project. Will have to study up on how you did all that! Thanks again for sharing :)
RoHS = Restriction of Helpful Substances....

#13 DanAndDusty

DanAndDusty

    Level 1

  • Members
  • 120 posts
  • LocationSussex, UK

Posted 09 November 2011 - 09:57 PM

Very impressive work there! ... but for Gods sake how on earth did you learn to use EEPROM and DACs before learning how to use an op amp? I assume you work in software?

Verryy cool project. Will have to study up on how you did all that! Thanks again for sharing :)


Thanks for that username. Yes Im coming to all this from Software. To me ICs are like lego.. Plug the bits together and I can work most of it out fairly easily. The electronics side is what Im learning as I go along. I know the very basics (V=I*R etc) but don't know the "almost basics" that most EEs take for granted. For example I only found out last week that there is a voltage drop across a resistor and using V=IR you can calculate the current passing through it. Obvious once I came across it.. but without having it pointed out to me Im not sure I would have thought of it.

Thats why the projects here are so entertaining. Always something new.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users