I have been endlessly annoyed with my dog getting on the couch. Even if I can keep her off the couch when I'm home, she still gets on the couch when I am away. Enter the Dog Repellent device. I designed this device to work all day long. During the day it will sound a loud alarm while vibrating, to hopefully, and harmlessly, scare the dog off the couch. During the night I don't want to hear the alarm but I still don't want the dog on the couch, so it only vibrates, in a manner that is annoying to my dog. The materials are not exotic, in fact, I had all of these things lying around the house. Lets begin!
Step 1: Gather Materials.
Bill of Materials. (partial list -- Major components)
-PICAXE 08M or 08M2
-8 Pin IC socket (optional but helpful)
- Audiovox, or similar vibration sensor. (Car alarm, or "shock sensor" (it doesn't actually shock anything it is just a vibration detector.))
-Radioshack project box. (6x4x2 or 7x4x3) http://www.radioshack.com/family/index.jsp?categoryId=2032276
- AA batteries and holder
- pager vibrator/motor (shown above, potted in hot glue)
- 5-12V siren (the louder the better)
- 2 General purpose N-channel FET (a logic level FET, such as FQP30NO6L works best, but most will probably work.)
- various resistors and capacitors
Step 2: PROGRAM THE ROBOT! Err I Mean the PICAXE
If you own any picaxe devices then you already know about their ease of use and versatility. If you don't know about the Picaxe then you should definitely try them out.
Nowadays everything runs on ARDUINO. I love arduino, but keeping my "embedded" intelligence in a project is almost always necessary. The arduino can definitely provide that intelligence, but they generally cost around $20-30, unless you use a barebones or a clone-duino, so they are much too expensive to dedicate to many projects. I like to build projects and let them sit around, I don't want to have to pull the brains out every time I want to build something new. That is why I love Picaxe. Each 08M picaxe only costs $2-3 and they can be reprogrammed many times, so they are cheap enough that I can leave all my projects intact and just smart enough to be useful.
Enough about that, now let's program this thing.
I program my picaxe via USB cable into the handy little programmer that includes a FTDI chip. Don't worry too much about the FTDI or what it means. Basically, you need a starter kit like the one sold HERE.
The usb cable is a special cable, which includes the USB to serial interface, so keep these details in mind if you decide to shop elsewhere.
There are many places on the web where you can learn exactly how to program a picaxe so I have omitted the details. PICAXE.COM for instance has a wealth of knowledge including full fledged user manuals! So much geeky knowledge I can hardly stand it.
I created the program initially in the picaxe's cool flowchart like programming language (see image), using an included program called "LOGICATOR". I have included both the Logicator (PLF) file and the BASIC (BAS) file. Download the file of your choosing with the programmer of your choosing and then remove the picaxe from the programmer so it can be installed in the next step when we ASSEMBLE THE MINIONS! err I mean, assemble the hardware.
Step 3: Assemble the Electronics
Build the circuit board following the schematic loosely, as I just used what I had laying around. My board is not the best looking but it does work. If you want to take the time to lay the components out with EAGLE or similar software it will surely help. I prefer the quick point to point wiring for projects like this. I did use an 8 pin IC socket though to make upgrading software easier, plus if I blow up the picaxe I can always replace it. Not that I would ever blow up any electronics or anything...
Note that I used 2 battery packs, labeled as 5Va and 5Vb, this isn't entirely necessary but the current draw from my motor was resetting the picaxe when ever it activated so I used a separate battery pack for it. Also note that the 5Vb can be from 5-12V if you have a higher voltage alarm for instance. Just make sure the voltage that you are substituting ONLY goes to the motor/alarm and NOT to the picaxe, it will make him angry. You wouldn't like him when he's angry. I did another silly thing and put the "disc style" pager motor into a bottle cap and then filled the bottle cap with hot glue. I did this because the pager motor was metal and I didn't want any shorting going on in my project box and because I have too much time on my hands.
The "shock" (vibration) sensor I used is a standard Audiovox, AUTO-ALARM style shock sensor. I think it is designed to run off of 12 volts but it worked perfectly for my purposes even at 5 volts. It has adjustable sensitivity so it can detect small vibrations up to larger jolts. You should be able to obtain one online by searching or at a best buy or similar store that sells car radios and alarm systems etc.
I also installed a rather large capacitor from 5Va to ground, but it doesn't appear in the schematic (an electrolytic 1000uF @35V I think).
Keep in mind if you decide to stray from the schematic that the picaxe doesn't like certain pins floating, meaning not connected, so if you don't use a pin you should put a 10k resistor from the pin to ground.
PRO TIP: Don't use giant expensive FETs like I did, they aren't really necessary for a project like this, plus they generally require a higher gate voltage to "turn on" and may heat up under certain conditions.
NOOB TIP: I included a picture of schematic symbols for the various kinds of FETs, which may be helpful. And a picture of a standard FET pin out.
Step 4: Assemble the Extremeties
Assemble the sensors and battery packs and connect them to the main circuit board. Once you find out how all of the components will lay on the board and where the wires will end up you can start to create the cut outs in the project box. I am using a common plastic project box to house this circuit, available at RadioShack et al.
Step 5: Project Box Cut-outs.
I put tape onto my box and drew each cutout. I then cut out the pieces using a dremel tool. I tried to plan where all the holes would go by laying the circuit board out and identifying where each component fell. The switches were grouped together, the Cds sensor was on the top of the project box so it would be exposed to the ambient light, the speaker was set against the wall of the box, and small air holes were drilled to maximize sound output. I also made a small bracket, out of some metal Technix pieces I had laying around, to secure the speaker. Internal components were mounted and screwed into the project box, or hot glued in place as necessary. The batteries are installed first, and the circuit board fits on top of the batteries then the "pager motor" fits in next to the circuit board. Wires ran out through holes in the side of the project box to the sensor and to the alarm. Ignore the lowly "rev 2" schematic in the pictures, he was unworthy.
The photocell that peaks through a hole in the top of the project box is held in place with hot glue. To make it look nice I put tape over the hole and then hot glued the sensor in place. When the hot glue was dry I removed the tape, which left a nice looking sensor hole which is flush with the project box surface.
Step 6: Test Your Might!
Ok so test the circuit. The theory of operation goes thusly, if it is night time, keep quiet and just vibrate! but also keep the dog off the couch. If it is day time, sound the alarms and vibrate. Maybe the first "shock" the sensor receives is just a person sitting down so sound a small beep on the internal speaker to let them know what's about to happen. Give them a chance to open switch S2 (which needs to remain closed in normal operation BTW) which will disable the shock sensor all together. BUT should they move again and set off the shock sensor again 1 of 2 things can happen.
1. The switch S2 remains closed and a low signal is sent to the picaxe pin3 (P4) When this happens the picaxe will check whether it is day or night, via the light sensor, and make a grumbly low tone on its internal speaker and then act accordingly.
2. The small internal speaker beeps and a person, with fingers nimble and fast, opens switch S2 within 1.5 seconds. The picaxe will acknowledge that the switch has been opened with a short happy little chirp, and will ignore any further input from the shock sensor for 15 minutes. ((A word of explanation is necessary. I originally intended to have S2 be a NC momentary switch, so when the internal speaker beeped you could hit the momentary button and disable it for 15 minutes. In actual usage 15 minutes is not that long and I found myself hitting the button again and again, so I changed it to a slide switch to facilitate my couch-potato worthiness.))
You may notice I never actually show my "alarm", that is because I don't have a picture of it, and I cannot get one, and you can't make me! Really, it was just the two wires shown in the schematic that exit through a small hole and connect to a "loud speaker" like 12V 100dB siren. It was so much larger than the actual project box that it looked funny sitting on my couch all the time so I disconnected it and haven't found a suitable replacement yet. Maybe I can do that in the future.
I hope you enjoyed this small project, I also hope you modify it in some way and make it better, or just make it bigger and grander! Put lights on it! Run some super eccentric code on an Arduino that communicates via wifi to the picaxe through an xbee via the picaxe's serial lines. I don't know just try stuff, it's fun.
Oh, and if I made some simple mistakes such as grammER or spealling or an incorrect schematic symbol, please tell me about it endlessly in the comments. ;)