Do you want to build a robot that is in an invisible enclosure? Or have you wondered how the robotic lawn mowers stay in their garden?
In this Instructable I will show you how you can easily build a perimeter loop yourself.
This perimeter loop uses a filter named matched filter. This filter allows us to recognize the signal from the receiver with a bunch of noise.
1x Arduino Uno or similar
1x Arduino Nano or similar
1x L298N Motor driver board
1x LM386 amplifier board
1x 24V relais (we need only the coil of it)
1x 150nF capacitor (foil or ceramic)
1x 94K resistor
1x 22pF capacitor
1x wire (works best with wire for lawn mower robots)
1x power resistor (i’ts value is depending on the length of the wire)
some wires to build the circuit
Step 1: How Does It Work?
Put simply, a perimeter wire sends a magnetic signal which is received and evaluated by a receiver.
As we learned at school, a current can only be induced in the receiver coil if we have an alternating current in the transmitter coil. Of course, we could just send a simple alternating current from the socket through the transmitting coil. But our robot would probably drive after the next best electric lawnmower because the signal from the wire is not “unique” enough.
Something else interesting is happening inside and outside wire. While the signal is received normally inside, it is suddenly mirrored outside. Which is why we can easily distinguish between inside and outside.
Next you could send a rectangular current through the wire with about 8 Khz. Unfortunately we cannot determine whether we are inside or outside because we only have one phase. But the signal can be filtered out with a simple fft filter. But let’s assume we have a source of interference nearby that also works with 8khz. For example an electric scooter or an electric car. The signal would be superimposed and our robot would also escape from the enclosure.
So we need a signal that is even more “unique”.
In the graphic labeled “raw data” you can see the raw data of the receiver coil. The signal consists of a 31-step signal which switches alternately between high and low. The times of the high and low states are always different.
This makes the signal very unique and can easily be filtered out from several disruptive factors at the same time.
In the graphic that is labeled with matched filter output, you can see the output of the filter. the peaks are the matches with the filter. the negative peaks are also in agreement. if the robot were now outside, the peaks would be negative and the others positive. With the help of which peak comes first, you can now easily determine whether you are inside or outside.
You can also create and simulate your own signals with this link.
But how does the filter exactly work? Please check the sketch description for the receiver.
If you would like to know this down to the smallest detail and would like more information about the perimeter wire, visit the ardumower.de homepage
Step 2: Build the Transmitter Wire
Upload the following sketch to the Arduino Nano:
What is happening in this sketch.
Timer1 from the Aruduino is configured to generate an interrupt at 10Khz frequency.
In this timer ISR the signal is shifted out over pin D2 and D3.
You can change your signal if you edit the arrey “H” and the variable “signal_length” please check it first at the matched filter simulator.
Step 3: Build the Receiver Circuit
Next you have to solder a 150nF foil capacitor in parallel with the coil. The capacitor smooths the signal and filters out high frequency interferences. Now you can connect the coil with the L286 amplifier module to the input side. The 100microFarad capacitor on the module must be bridged otherwise your signal is not correct.
Now we have to build a RC filter. The module produces some noise which correlate with the signal and make it noisy. For the fIlter you will need a 94K resistor and a 22pF ceramic capacitor.
The output of the filter is finally connected with the Arduino at the A0 pin.
Step 4: Programm and Test the Cirucit
with #include “perimeter.h” can you include the perimeter tabs.
now you have to configure the hardware for receiving the signal.
in the void setup() function you have to write PerimeterConfigure();
follow is happening:
Timer1 is used and set to 10khz interrupts
analog to digital converter is set to second highest speed.
some global variables are generated.
Now you can in void loop() trigger a signal recording and filtering with “getPerimeter(analogPin)”.
the return value is the signal strength of your signal. If it returns a zero no valid signal is detected.
What is happening in there?
first of all 150 samples will be recorded from the analog pin.
Then it goes throught the first matched filter algorythm. It outputs a characteristic filter courve.
The second matched filter searches for exactly this courve.
Now it searches for peaks an will it store in a pointer variable.
Read more: Perimeter Wire Using Matched Filter