Hello to all,
I’ve bought an electric dog fence since I want to use it with my mobile robot.
The system I’ve bought has a transmitter, a buried wire and a receiver with two connector and one led.
Now, when the receiver is near the wire, the led blinks, the receiver beeps and gives pulsed shocked through the connectors.
Pulses and beeps are proportional to the distance from the buried wire.
Surely, the receiver outputs an alternate signal and I’d like to be able to read it with my Arduino: do you think it’s possible?
I want to detect the output signal because in this way I can know when my robot is near the area border and if this happens I can make it change direction.
What I have to do to read this signal in Arduino?
Should I have to convert the alternate signal to a DC one? It is possible to check the pulses delay? This can help the robot to know the distance from the wire: pulses increase when distance decrease.
Hmmm, are you asking if an arduino can measure the time between pulses?
I know that Arduino is able to measure time between pulses
I do not know how to convert the AC signal to a DC one (in the easier way it is possible) and make it suitable for Arduino.
What sort of AC signal is it?
Unfortunately, this dog fence didn’t come with any datasheet or technical specs, so I really do not know what kind of signal it outputs.
I know it is AC and also that the pulse increase while the distance from the wire decrease; but i do not have any tool (like a scope) to analyze the signal
Do you have 4 diodes and an LED to hand?
If so, wire the diodes into a bridge rectifier (http://www.reuk.co.uk/OtherImages/bridgerectifier.gif), and connect the LED with a series resistor to the DC side of the rectifier (with your AC signal to the AC side). Without knowing the voltage of the AC signal, I would use a 2k resistor or something in that region to be safe (doesnt have to be exact, anywhere between 1k and 4k should do).
Then see what happens to the LED as you get closer to the fence.
Does it blink?
If YES: does the rate of blinking change as you move closer to the fence?
if NO: does it fade, maybe get brighter with distance?
Without any specifics it is difficult to work out what is the best way to connect it until a little more is know. The above test is a good start.
I would also suggest you get a multimeter (doesn’t have to be expensive, you can get dirt cheap ones for 10-15 $). Most will give an average voltage for AC signals. That would also be useful to know.
Or, you could just hack one of the dog receivers (which is what I though you were doing). Should be pretty easy to find the LED control pin and feed that into an arduino digital port. Worst case, you’d need to use an NPN transistor to boost the voltage level a bit. Make sure you’ve got a common gnd.
Philba:
Or, you could just hack one of the dog receivers (which is what I though you were doing). Should be pretty easy to find the LED control pin and feed that into an arduino digital port. Worst case, you’d need to use an NPN transistor to boost the voltage level a bit. Make sure you’ve got a common gnd.
Or you could do that yeah, I missed that line in his original post :shhh:
Philba and TCWORLD, thanks a lot for your suggestions!
With the multimeter, i read something like 15-20V for each pulse.
However, I think the best solution is to directly use the LED output or the buzzer voltage output since they work according on the pulses so I should use one of them to detect pulses in Arduino.
I have to check if the voltage output for each pulse is 5V.
Do you think it will be OK if it is 3,3V and not 5V?
Should I use PWM input or any digital input should work?
P.S. I’m going to test the rectifier solution
3.3V should be recognised fine by a 5v digital input. Note that there is not PWM INput.
If it doesn’t quite, you can connected it to an Analog input (ADC), and read in the value. When it is above a certain level consider it as a 1, and when it is below it, consider it a 0.
An alternative to the ADC is to use the Analog comparator. You can set it to have an internal reference of 1.1V. When the input is higher than that it is considered a 1 and below it a 0. The Comparator triggers an interrupt when it changes, which would easily allow you to time between pulses.
In general, when hacking a piece of gear to do something it wasn’t originally designed for, you should take some precautions to protect what you are interfacing to. optoisolators are particularly good for that. Then you KNOW that your arduino won’t be getting a big voltage spike shoved down it’s throat. Plus, it doesn’t care what voltage your arduino is running at. Basically, you replace the LED with the opto’s LED and the phototransistor side of the opto runs straight into the arduino input. Make sure you use internal pull-ups (set input mode, then output a HIGH). Your arduino will see a low when the LED would have lit up and a high the rest of the time. Look for one with NPN or darlington output. Sometimes called optocouplers. Some good optos to use are 4N27, 4N35, H11D1.
Hi guys, I tried to read voltage output from the buzzer and the little led but it’s too low, something like 0,3V at maximum.
Then, I realized the diodes rectifier and I added the LED to the DC side: the LED blinking change as I move closer to the fence.
I tried to measure the DC voltage with a multimeter and it seems to be something like 1,8V with 2,2V peaks even if the receiver battery is almost discarged.
When the receiver approaches to the wire, the number of blinking between each pause increases.
For example, at 1 meter from the wire, I have three blinkings and then a pause; at 30 centimeters, I have nine blinkings with the same pause.
It would be important for me to detect the different time between the blinkings in order to know how close to the wire my robot is.
Can you help me to know how to read this DC voltage with Arduino, please?
Do I have to connect Arduino GND to DC GND side and the analog input to the positive DC side?
(I tried in this way, but analog input changes randomly)
I’m not sure you’ve understood the replies completely. If you were measuring the voltage across the LED pins, that’s what I would expect you to get. There should be a resistor in series with the led. Try reading the voltage across the LED and the resistor (so both are between your probes). The resistor and LED could be switched around from the diagram below. You should be able to tap into the signal where it comes out of the box labeled micro.
http://cq.cx/pics/int-led.png
Yes, you need to connect the two device’s grounds - there needs to be a complete circuit.
You could use an analog input on your arduino. Personall,y I’d use an optoisolator like I described above (to keep from damaging the arduino) but you could make the analog approach work. Since there needs to be voltage to light up the LED, you really should be getting 2 voltages - 0 and something not zero (2.2 or higher).