Introduction: Arduino PetSafe Cat Barrier
Hey, all! I finally decided to write this as an instructable of my own - my first. To give proper credit, this project originated with user whyameye's original post on Sept. 2, 2013 - Original PetSafe Barrier Project. I built on his success, and used data he gathered on how the PetSafe "shock collar" system worked, and used an arduino to build my circuit to emulate his results with his 555-chip circuit.
I wired up an Arduino Duemilenove with the output NPN power transistor via a 1k resistor on pin 9, just as if I were wiring up a basic LED blinking circuit, then wired a 1k potentiometer in series with the output load wire loop to adjust field strength. All was powered with a 9V battery. (Note: if you need more field strength, simply wire the power supply for the TIP29 power transistor to a separate, higher DC voltage supply - maybe try 9V or 12V first. Remember to tie the DC- to the common ground)
I used the arduino timer1.pwm routine to generate the 10.5KHz during the on pulse, and a loop with 18ms on / 18ms off for the 36 ms pulse carrier wave. This emulates the astable multivibrator circuit whyameye created with his 555 circuit. Here is a the arduino sketch code:
/*
* Astable multivibrator signal emulator
* for PetSafe fence
*/
#include "TimerOne.h"
void setup()
{
pinMode(9, OUTPUT);
Timer1.initialize(95.2); // initialize timer1, and set a 95.2us second period (10.5KHz)
}
// the loop routine runs over and over again forever:
void loop()
{
Timer1.pwm(9, 512); // setup pwm on pin 9, 50% duty cycle
delay(18); // wait for 18ms
digitalWrite(9, LOW); // turn the LED off by making the voltage LOW
delay(18); // wait for 18ms
}
20 Comments
Question 3 years ago
I want to add a receiver that just makes a sound.
I tried to write a code but it didn't work. Do you have an Arduino receiver?
Reply 3 years ago
I am glad you were able to make this work. I haven't been doing Arduino projects since then, so am not current on the platform (perhaps again someday). Hopefully you can get it figured out, or have somebody on this board offer suggestions.
LUCK!
4 years ago
Very cool, just built it to and tested it out on an Arduino NANO and it works great with my cat collar. Signal strength seems low (collar needs to be withing 3" of the loop to trigger). Now I need to find a way to get the antenna loop signal to project out as far out as possible (i'm trying to use this as a remote control). What would be the best way to boost the output (transmission range) way up?
Reply 4 years ago
It's awesome you built one and it works! I am tempted to break mine out again for a new effort, as my new cat is becoming bothersome jumping all over the kitchen counters and such.
It's been awhile since I looked at this, but it seems to me I had to experiment with signal strength myself. I had suggested larger voltage than the 9VDC I originally built it with. Try higher DC voltages to drive your pulse (up to the rating of whatever power transistor you are using). Also try bigger loops, or multiple loop windings. Let me know if any of these suggestions (or other things you try) work
Luck!
5 years ago
Thanks for the information, it worked like a charm!!! Now I just gotta print a nice box for it all and call this project done!
Reply 5 years ago
Thanks for the feedback. I am glad you made good use of this.
6 years ago
Just wanted to say that this is an awesome project. In my case, the 1K resistor to pin 9 was too high, so I used a 100ohm resistor instead.
I have a Pet Stop pet fence, so I had to change the period to 142.8us (7Khz) with a delay of 6.5ms (13 ms total).
Thanks crazy1gadgets !
Reply 6 years ago
Nice to know it worked out for you. I played around with the resistors, too, after I posted the project. Glad you were able to figure out the duty cycle for the Pet Stop pet fence.
7 years ago
Any chance I can purchase this set up with the collar? I have an incredibly stubborn dog insistent on eating the cats food every day. I would love to shock him when he goes for the cats bowl.
8 years ago
You are correct that setting pulse period to 160 us will get you to 6.25KHz. The fact that Vce only cycles between 3.8v and 5.2v (while Vbe cycles between 5v and 0v) is telling me that either your transistor or transistor circuit is faulty.
Connect a 1K or greater resistor between your 5v power supply and the collector of the transistor, then measure Vce again as you cycle (1 second pulses again). You should definitely be cycling between 5v and 0v as all you have with your power transistor is a simple inverting amp (when you apply 5 volts from arduino pin 9 to the base, current flows across the base 1k resistor through the transistor to ground which saturates it, so it should "switch" the transistor CE pathway completely open connecting collector to ground - with only minor voltage drop, maybe .6v or so).
Again, I would suggest taking the transistor completely out of the circuit and loop your wired + resistors directly to arduino pin 9, just to test response from your collar. I actually did this with my Arduino (see posts in Whyameye's original post on Sept. 2, 2013 - Original PetSafe Barrier Project), and measured about 9mA, well within the pin 9 current limit of 20mA. Get that to work, then add back the transistor to the circuit.
8 years ago
Vc3 drops to 3.8 then to 5.2. Vbe drops to 0.
All that being said my collar is definatly different. Some research on web shows its 6.25 KHZ. I attempted to change the 95.2 to 160 in the code to represent 6.25. However still no go. Ill try to remove/replace transister with adjusted code later on and see if that works.
8 years ago
After digging around the web a while I came up with the fact that the collar I have uses 6.25KHZ. How would I adjust the code to equal this?
Thanx in advance.
8 years ago
Yeah, unfortunately the original design by Whyameye (see previous posts from over a year ago) were specifically for the PetSafe dog collar he had (I don't remember the model. It works with my PetSafe Cat Collar 300-648 (are you sure you didn't transpose your numbers above)?
Interesting that your voltage drops from 5.2 to 3.8v each second. Vce should drop pretty much to zero when in the "off" state up to max voltage in "on" state. Try reading Vbe with your meter to see what you get. Better yet, disconnect the power transistor entirely and see what output your arduino puts out between pin 9 and ground. If that bounces between 0 and 5v then your arduino is ok, then it's probably a bad transistor.
You may even be able to get the collar to trigger without the power transistor in place. Just connect the loop antennae wire between your +5VDC source and pin 9 but be sure to put your 1k resistor and the 1pot, and see what you get.
Remember, the external transistor is only there to prevent too high current draw from the arduino board chip. There shouldn't be enough current to "fry" the chip, but you don't want to heat it up too much and wear it out. (I think I mentioned this in a previous post).
Luck
8 years ago
I tried out the coughaway.pd from the other post. It did not trigger my dogs collar. Now i did not run an antenna. But i heard it form my PC and brough the collar very close to my PC. I think this collar might be working differently then the ones you guys used.
8 years ago
Without a 'scope this may be difficult to troubleshoot. Does your multi-meter have frequency measurement capabilities (i.e. Hz)? Then you could see if you were getting an output at least in the loop.
For the carrier square wave (18ms on + 18ms off = 36 ms period) you should be able to measure approx 28 Hz. The pulse is 10.5 KHz so you might see this as well depending on your settings.
If you don't have a frequency setting on your multi-meter, you will need to at least see if you are getting any kind of output at the loop. I would suggest changing the carrier wave pulse to 1 second on, 1 second off, then you will easily be able to see output voltage at the loop turn on and off each second - change the last lines of your Arduino sketch to:
Timer1.pwm(9, 512); // setup pwm on pin 9, 50% duty cycle
delay(1000); // wait for 1 sec
digitalWrite(9, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for 1 sec
Once you can verify you are at least getting voltage at the loop, then go back to the original program, and try again. Let me know how it goes
Best of luck!
8 years ago
Just tried it today and cant get it to work. Only 2 legs of the POT get used correct? The middle leg going to the Transister?
Reply 8 years ago
yes, the middle leg of the pot will go to the collector of the transistor. The pot will in this case function as a variable resistor only (rheostat). The other leg will go to the loop wire.
Are you getting any results at all? Do you have a 'scope or multimeter to make any tests?
Reply 8 years ago
I do have multimemter but no scope. Ill try it out once more. Does the POT setting only work in a small area? should i dial it up very slowly?
8 years ago on Introduction
Thank you for this! I am trying to cover a yard which is approximetly 100 feet x 100 feet- could you post a hint as to how I could power that perimeter wire? Thank you!
9 years ago on Introduction
Awesome. Thanks heaps for this. Will make it this weekend.