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>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>
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: