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


Step 1: Wiring the Breadboard Circuit

Step 2: Results

<p>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.</p><p>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).</p><p>Thanks crazy1gadgets !</p>
<p>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. </p>
<p>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.</p>
<p>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. </p><p>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 &quot;switch&quot; the transistor CE pathway completely open connecting collector to ground - with only minor voltage drop, maybe .6v or so).</p><p>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 - <a href="https://www.instructables.com/id/PetSafe-Pet-Barrier-Transmitter/" rel="nofollow">Original PetSafe Barrier Project</a>), 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.</p>
<p>Vc3 drops to 3.8 then to 5.2. Vbe drops to 0.</p><p>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.</p>
<p>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?</p><p>Thanx in advance.</p>
<p>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)?</p><p>Interesting that your voltage drops from 5.2 to 3.8v each second. Vce should drop pretty much to zero when in the &quot;off&quot; state up to max voltage in &quot;on&quot; 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. </p><p>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. </p><p>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 &quot;fry&quot; 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).</p><p>Luck</p>
<p>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. </p>
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.<br><br>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.<br><br>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:<br><br>Timer1.pwm(9, 512); // setup pwm on pin 9, 50% duty cycle<br><br>delay(1000); // wait for 1 sec<br><br>digitalWrite(9, LOW); // turn the LED off by making the voltage LOW<br><br>delay(1000); // wait for 1 sec<br><br><br>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<br><br>Best of luck!
<p>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?</p>
<p>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. </p><p>Are you getting any results at all? Do you have a 'scope or multimeter to make any tests?</p>
<p>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?</p>
<p>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!</p>
<p>Awesome. Thanks heaps for this. Will make it this weekend.</p>

About This Instructable




More by crazy1gadgets:Arduino PetSafe Cat Barrier 
Add instructable to: