Jump to content
43oh

Halloween Motion Triggered Sound and Light Thingamajig


Recommended Posts

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
Link to post
Share on other sites

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.

 

post-1927-135135519847_thumb.png

 

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

Link to post
Share on other sites

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.

 

 

Link to post
Share on other sites
  • 2 weeks later...
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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...