Posted on by & filed under Electronics, Lawn Mower, Robotics Projects & Kits.


Wire guidance technology is widely used in the industry, particularly, in warehouses where handling is automated. The robots follow a wire loop buried in the ground. An alternating current of relatively low intensity and frequency between 5Kz and 40KHz flows in this wire. The robot is equipped with inductive sensors, usually based on a tank circuit (with a resonance frequency equal or close to the frequency of the generated wave) that measures the intensity of the electromagnetic field close to the ground. A processing chain (amplification, filters, comparison) makes it possible to determine the position of the robot within to the wire.

These days, perimeter/boundary wire is also used to create “invisible fences” to keep pets within yards, and robot lawn mowers within zones. LEGO also uses the same principle to guide vehicles along roads without visitors seeing any lines. For example, here is a video of the Robomow RS630 in action :

This tutorial explains in an easy and intuitive way to help you understand the theory, design, and implementation to make your own generator and sensor for a perimeter wire. The files (Schematics, Eagle Files, Gerbers, 3D Files and Arduino Sample Code) are also available for download. This way, you can add the wire perimeter detection feature to your favorite robot and keep it within an operating “zone”. How cool is that!



The perimeter wire generator circuit will be based on the famous NE555 timer. NE555 or more commonly called 555 is an integrated circuit used for timer or multivibrator mode. This component is still used today because of its ease of use, low cost, and stability. One billion units are manufactured per year. For our generator, we will use the NE555 in Astable configuration. The stable configuration allows using the NE555 as an oscillator. Two resistors and a capacitor make it possible to modify the oscillation frequency as well as the duty cycle. The arrangement of the components is as shown in the schematic below.

The NE555 Generates a (rough) square wave which can run the length of the perimeter wire. Referring to the NE555 datasheet for the timer, there is a sample circuit, as well as the theory of operation (8.3.2 A-stable operation). Texas Instruments is not the only manufacturer of NE555 ICs, so should you choose another chip, be sure to check its manual.

We do offer this nice 555 Timer Soldering Kit that will give you the opportunity to solder all the internal components of a 555 timer in a through hole package to allow you to understand the operation of this circuit in detail.

Schematic and Prototyping

The schematic provided in the NE555 manual (8.3.2 A-stable operation section) is fairly complete. A few additional components were added and discussed below.


NE555 A-stable typical circuit

NE555 Circuit for A-stable Operation

The formula used to calculate the frequency of the output square wave is :

    f = 1.44 / ((Ra+2*Rb)*C)         (1) 

The frequency range of the generated square wave will be between 32Khz and 44KHz which is a specific frequency that shouldn’t interfere with other close devices. For this, we have chosen Ra = 3.3KOhms, Rb = 12KOhms + 4.7KOhms Potentiometer and C = 1.2nF.

The potentiometer will help us vary the frequency of the square wave output to match the resonance frequency of the LC Tank circuit that will be discussed later on. The theoretical lowest and highest value of the output frequency will be as follows calculated by the formula (1) :

Lowest frequency value : fL = 1.44 / ((3.3+2*(12+4.7))*1.2*10^(-9)) ≈32 698Hz

Highest frequency value : fH = 1.44 / ((3.3+2*(12+0))*1.2*10^(-9)) ≈ 43 956Hz

Since that the 4.7KOhms potentiometer never gets to 0 or 4.7, the output frequency range will vary from around 33.5Khz to 39Khz.

Here is the complete schematic of the generator circuit :


Eagle Generator Schematic

Eagle Generator Schematic

As you can see in the schematic, few additional components were added and will be discussed below. Here is the complete BOM :

  • R1 : 3.3 KOhms
  • R2 : 12 KOhms
  • R3 (Current limiting resistor): 47 Ohms (needs to be fairly large to dissipate heat with a 2W power rating should be enough)
  • R4 : 4.7 KOhm potentiometer
  • C2,C4 : 100nF
  • C3 : 1.2nF (1000pF will also do the job)
  • C5 : 1uF
  • J1: 2.5mm center positive barrel connector (5-15V DC)
  • J2 : Screw terminal (two positions)
  • IC1: NE555 Precision Timer

Additional parts added to the schematic includes A barrel jack (J1) for easy connection to a wall adapter (12V) and a screw terminal (12) to conveniently connect to the perimeter wire.

Perimeter Wire: Note that the longer the perimeter wire, the more the signal degrades. We tested the setup with roughly 100′ of 22 gauge multi-strand wire (pegged into the ground as opposed to buried).

Power Supply: A 12V wall adapter is incredibly common, and any current rating above 500mA should work well. You can also choose a 12V lead acid or 11.1V LiPo to keep it within the case, but be sure to weatherproof it and turn it off when not in use.

Here some parts we offer that you might need when building the generator circuit :

Here is what the generator circuit should look like on a breadboard :

Sensor Breadboard Fritzing

Fritzing Generator Breadboard


As shown in the below oscilloscope screenshot of the output of the generator circuit (taken with the Micsig 200 MHz 1 GS/s 4 Channels Tablet Oscilloscope), we can see a (rough) square wave with a frequency of 36.41KHz and an amplitude of 11.8V (using a 12V power adapter). The frequency can be varied slightly by adjusting the R4 potentiometer.


Generator Square Wave Output

Generator Square Wave Output

A solderless breadboard is rarely ever a long-term solution and is best used to create a quick prototype. Therefore, after confirming that the generator circuit is working as it should, generating a square wave with a frequency range 33.5Khz and 40KHz (variable through the R4 pot), we have designed a PCB (24mmx34mm) only with PTH (Plated-through Hole) components to make it a nice small square wave generator board. Since through-hole components were used for prototyping with a breadboard, the PCB could also use through-hole components as well (instead of surface mount), and allows for easy soldering by hand. Placement of the components is not exact, and you can likely find room for improvement. We have made the Eagle and Gerber files available for download so that you can make your own PCB. Files can be found in the “Files” section at the end of this article.

Here is some tips when designing your own board :

  • Have the barrel connector and screw terminal on the same side of the board
  • Place the components relatively close to each other and minimize traces/lengths
  • Have the mounting holes be a standard diameter, and located in an easy to reproduce rectangle.
Generator PCB on Eagle

Generator Board Eagle

Generator Board 3D

Generator Board 3D

Generator Board

Generator Board


Wire Installation

So how to install the wire? Rather than burying it, it’s easiest to simply use pegs to keep it in place. You’re free to use whatever you want to keep the wire in place, but plastic works best. A pack of 50 pegs used for robot lawn mowers tends to be inexpensive.
When laying the wire, be sure to have both ends meet at the same location to connect to the generator board through the screw terminal.


Perimeter Wire Installation 1

Perimeter Wire Installation 1

Perimeter Wire Installation 2

Perimeter Wire Installation 2

Perimeter Wire Installation 3

Perimeter Wire Installation 3


Generator Setup

Generator Setup


Weather Resistance

Since the system will most likely be left outside to be used outdoors. The perimeter wire needs a weather resistant coating, and the generator circuit itself housed in a waterproof case. You can use this cool Enclosure to protect the generator from rain and these Waterproof DC Power Cable Set

Not all wire is created equal. If you plan to leave the wire out, be sure to invest in the correct wire, for example, this Robomow 300′ Perimeter Wire
Shielding which is not UV / water resistant will degrade quickly over time and become brittle.



Now that we have built the generator circuit and make sure that it is operating as it supposed, it is time to start thinking about how to detect the signal going through the wire. For this, we invite you to read about the LC Circuit, also called Tank Circuit or Tuned Circuit.

An LC circuit is an electrical circuit based on an Inductor/Coil (L) and a capacitor (C) connected in parallel. This circuit is used in filters, tuners, and frequency mixers. Consequently, it is commonly used in wireless broadcast transmissions for both broadcast and reception. We won’t go into the theoretical details regarding LC circuits, but the most important thing to keep in mind to understand the sensor circuit used in this article, would be the formula for calculating the resonance frequency of an LC circuit, which goes like :

       f0 = 1/(2*π*√(L*C))          (2) 

Where L is the inductance value of the coil in H (Henry) and C is the capacitance value of the capacitor in F (Farads).

For the sensor to detect the 34kHz-40Khz signal that runs into the wire, the tank circuit we used should have the resonance frequency in this range. We chose L = 1mH and C = 22nF to obtain a resonance frequency of 33932KHz calculated using the formula (2).

The amplitude of the signal detected by our tank circuit will be relatively small (a maximum of  80mV when we tested our sensor circuit) when the inductor is at about 10cm from the wire, therefore, it will need some amplification. To do so, we have used the popular LM324 Op-Amp amplifier to amplify the signal with a gain of 100 in a non-inverting configuration 2 stages amplification to make sure to obtain a nice readable analog signal at a greater distance than 10cm in the output of the sensor. This article provides useful information about Op-Amps in general. Also, you can have a look at the LM324’s datasheet.

Here is a typical circuit schematic of an LM324 amplifier :

LM324 Non-inverting

Op-Amp in non-inverting configuration

Using the equation for a non-inverting gain configuration, Av = 1+R2/R1. Setting the R1 to 10KOhms and R2 to 1MOhms will provide a gain of 100, which is within the desired specification.

In order for the robot to be able to detect the perimeter wire in different orientations, it is more appropriate to have more than one sensor installed on it. The more sensors on the robot, the better it will detect the boundary wire.

For this tutorial, and since the LM324 is a quad-op amplifier (this means that one LM324 chip has 4 separate amplifiers), we will be using two detecting sensors on the board. This means using two LC circuits and each will have 2 stages of amplification. Therefore, just one LM324 chip is needed.

Schematic and Prototyping

As we discussed above, the schematic for the sensor board is pretty straight-forward. It is composed of 2 LC circuits, one LM324 chip and a couple of 10KOhms and 1MOhms resistors to set the gains of the amplifiers.


Sensor Schematic Eagle

Eagle Sensor Schematic

Here is a list of the components that you can use :

  • R1, R3, R5, R7 : 10KOhm Resistors
  • R2, R4, R6, R8 : 1MOhm Resistors
  • C1, C2 : 22nF Capacitors
  • IC: LM324N amplifier
  • JP3 / JP4: 2.54mm 3-pin M/M headers
  • Inductors 1, 2 : 1mH*

* 1mH Inductors with a current rating of 420mA and a Q factor of 40 @ 252kHz should work well. We have added screw terminals as inductor leads to the schematic in order for the inductors ( with leads soldered to wires) to be placed at convenient locations on the robot. Then, the wires (of the inductors) will be connected to the screw terminals.

Out1 and Out2 pins could be directly connected to a microcontroller’s analog input pins. For example, you could use an Arduino UNO Board or, better, a BotBoarduino Controller for a more convenient connection as it has analog pins broken-out into a row of 3 pins (Signal, VCC, GND) and it is also Arduino compatible. The LM324 chip will be powered through the microcontroller’s 5V, therefore, the analog signal (detected wave) from the sensor board will vary between 0V and 5V depending on the distance between the inductor and the perimeter wire. The closer the inductor is to the perimeter wire, higher the amplitude of the sensor circuit output wave.

Here is what the sensor circuit should look like on a breadboard :


Sensor Breadboard Fritzing

Fritzing Sensor Breadboard


As we can see in the oscilloscope’s screenshots below, the detected wave at the output of the LC circuit is amplified and saturates at 5V when the inductor is at 15cm to the perimeter wire :


20-sensor output before amplification

Tank Circuit Output (Inductor @ 15cm of wire)

Sensor Circuit Output

Sensor Circuit Output After Amplification (Inductor @ 15cm of wire)


Same as we did with the generator circuit, we have designed a nice compact PCB with through-hole components for the sensor board with two tank circuits, an amplifier, and 2 analog outputs. Files can be found in the “Files” section at the end of this article.


Sensor PCB Eagle

Sensor Board Eagle

Sensor Board 3D

Sensor Board 3D

Sensor Board

Sensor Board


Obtaining an optimal detection of the perimeter wire with the inductors of the sensor circuit will depend on how the inductors are placed into the robot. If you use a through hole radial inductor like we did, the inductor’s axis should be perpendicular to the perimeter wire as below :


17-wire detection-1

Perimeter Wire Detection


Arduino Code

The Arduino code that you could use for your perimeter wire generator and the sensor is very simple. As the output of the sensor board is two analog signals varying from 0V to 5V (one for each sensor/inductor), the AnalogRead Arduino example can be used. Just connect the two output pins of the sensor board to two analog input pins and read the appropriate pin by modifying the Arduino AnalogRead Example. Using the Arduino serial monitor, you should see a RAW value of the analog pin you are using vary from 0 to 1024 as you approach the inductor to the perimeter wire.


Arduino Sensor Analogread

Arduino Analog Read


If you are using the wire perimeter generator and sensor into a robot, you can set a threshold (that will correspond to a distance between the inductor and the perimeter wire) for the robot to get back or turn as soon as this threshold is reached. This way, the robot will keep moving within the delimited zone. So again, how cool is that!


The Eagle, Gerbers, Fritzing and 3D Step files of the Perimeter Wire Generator and Sensor can be downloaded through this link.

We would be happy to hear about your project on the RobotShop’s forum. Also, feel free to share your version of the Perimeter Wire Generator and Sensor in the comments section.


24 Responses to “DIY Perimeter Wire Generator and Sensor”

  1. Anna R Grow

    Thanks for putting this together, gave me a great idea on how to expand an already budding idea? One of the best posts I have read. I loved it. Thanks for sharing with us.

  2. Gary Croll

    Have you tried this setup in actual field use? I have serious doubts on the reliability in a real world situation. Since you did not use any kind of a pilot tone on the transmit side and a PLL like the LM567 on the receiver side, I am afraid normal 60 stray fields would swamp your receiver and render it deaf to the desired signal. Commercial versions of wireless loops always have a pilot tone. PS Where it asks for my website on your reply form, it will not accept my website, (, and keeps asking for my URL

    • Brahim Daouas

      @Gary Yes, we have actually tested this setup outdoor with a 100″ 22AWG wire forming a 625 Sq.ft surface area. The receiver (tank circuit) was able to detect a 36kHz square wave generated by the generator circuit at 6 inches from the wire by generating a sine wave with an amplitude of 2V and 36kHz frequency. By further approaching the receiver’s inductors to the wire, the amplitude of the output signal of the receiver becomes higher and saturates at 5V (the in inductors axis should be perpendicular to the loop wire axis).
      You are correct, a pilot tone on the transmitter and a tone decoder on the receiver would greatly improve the perimeter wire generator/receiver circuits. However, since our aim for using this setup is only to detect if a wire is present (or at most, how near the wire is to the receiver) to be used in robotic applications and not intended to transmit any data from the generator to the receiver, a simple NE555 generator and tank circuits would suffice.
      As for your website, please try to enter it as ”

  3. BAZEGA Haris

    Hello M.Daouas,
    Thanks you very much for your explication and sharing this great solution, I’m student from France sorry for my english. I have a question, I want to know, How we can program this on Arduino (the real code). I start on Arduino this year and in my project I want to change the direction of motor when he detect peripheral cable. You say, we put analog input on a analog pin of Arduino ?

    • Brahim Daouas

      @BAZEGA Haris Thank you for reading. Correct, the sensor board outputs two analog signals (0-5V) proportional to the distance between the inductor and the perimeter wire. By connecting the sensor board’s analog outputs to 2 analog pins, the Arduino will be able to read this signal and the RAW value will vary from 0 to 1023. Please refer to the analogRead() function for more information and a sample Arduino code.
      Depending on how you are controlling your motor from the Arduino (generally a PWM output pin is used for rotation speed and a digital output pin is used for direction, in case you are using a DC Motor driver with the Arduino board), you can reverse the direction of the motor in your code by changing the state of the direction pin based on a threshold from the sensor’s output. For example, if the outputs of the sensor board is connected to analog pin 0 and 1 on the Arduino, you can set a threshold based on the detection distance you want between the perimeter wire and the inductors. As soon as this threshold is reached on one of these pins, you can change the direction of rotation of the motors by changing the state of the direction pin as mentioned above. You can find online a lot of sample codes to help you start coding with Arduino and controlling a DC Motor.


    Thanks you for your answer. I have one question.
    I want to make your solution on PCB and the question is, the two capacitors on sensor board (LC circuit) have polarisation or not ?

    • Brahim Daouas

      @BAZEGA The capacitors on the sensor board are 2 x 22nF ceramic capacitors and they are not polarized.

  5. Bazega

    Hello M.Daouas where we can buy a 1mH Inductors with a current rating of 420mA and a Q factor of 40 @ 252kHz ?

  6. Mohamed Ben

    Can a 1mH Inductors with a current rating of 510mA and a Q factor of 20 @ 252kHz work well ?
    Or 1mH Inductors with a current rating of 420mA with a Self resonant frequencyof 1,6MHz Should be better?

    • Brahim Daouas

      @Mohamed In theory, both 1mH inductors should work since the only parameters that affect the receiver’s resonance frequency are the capacitance of the capacitor and the inductance of the coil (f0 = 1/(2*π*√(L*C))).
      As indicated in the article, L = 1mH and C = 22nF should provide a resonance frequency of 33 932 Hz which is in the range of the output square wave frequency (32 698Hz to 43 956Hz).
      However, for your information, the Q factor (quality factor) of an inductor is the ratio of its inductive reactance to its resistance, therefore, it measures the effeciency of an inductor in a given frequency. The higher the Q factor, the closer it approaches the behavior of an ideal inductor.

    • Brahim Daouas

      @Fredo We used an analogread on the sensor board output pins. You can find an Arduino example code for the analogread function through this link.

  7. Michael Levy

    Is it possible to buy these boards pre-made so I can throw into a project with the code?

    • Brahim Daouas

      @Michael We unfortunately don’t offer the generator and sensor boards. You can send the gerber files to any PCB manufacturer to produce it and assemble the components based on the provided BOM.

  8. Thomas

    I have a ~11 years old Robomow RL-1000 still working fine. Have not found out what signal is being sent by the charging/perimeter station and don’t have access to an oscilloscope, anyone knows the signal type?
    Could the sensor in this blog sense the signal from the charging/perimeter station?
    If so, I would not need to build the generator, only the sensor. The total length of the wire is by the way ~150 meters.

    • Philippe Jutras

      Hi Thomas,
      Unfortunately, the Robomow RL-1000 signal generator is a closed product design. We don’t know what type of signal and at which frequency is being sent from the generator into the perimeter wire. It would, most likely, be a specific signal that will only be detected by the sensors on the Robomow, therefore, it won’t work with the sensor discussed in this blog article.

  9. Deemoss

    Hi Brahim,
    Could the circuits be tuned to provide sub-millimetre accuracy? I would like to use this for alignment of mechanical components to a stretched conductor acting as a reference.


    • Brahim Daouas

      @Deemoss Unfortunately, this circuit is not intended to be used for precise (sub-millimeter accuracy) positioning. The sensor-generator setup will provide a rough idea if the robot (sensors) gets too close/far from the perimeter cable.

  10. Michael

    Hi Brahim,
    thanks for this brilliant post, I really appreciate it! 🙂

    One question: you stated that the perimeter wire may not be longer than 100 feet, right? Could you please short describe what would have to be done that the sender is able to power a longer wire?

    Best regards,


    • Brahim Daouas

      @Michael Thank you for your nice feedback, glad that you like the post.
      The perimeter wire we used to test the generator circuit was 100′ long. This doesn’t mean that the wire can’t be longer.
      From the datasheet of the NE555, the maximum recommended current output of the chip is 200mA. Therefore, with a VCC of 12V, the maximum power output would be 2.4 Watt.
      So theoretically, the total output resistance should be less than 60 Ohms. There is an output resistance of 47 Ohms in the generator circuit, so it leaves 13 Ohms for the loop wire resistance.
      A 22 AWG wire gauge is rated for 16.14 Ohms of resistance per 1000ft, therefore, the maximum theoretical length of the perimeter wire, would be approximately 805′.

  11. David Martin

    Hi Brahim

    Just like Michael I really appreciate this post and i’ve a question on perimeter wire length.
    If I was to increase the cross sectional area of the perimeter wire, therefore reducing the resistance of the wire, would I be able to run it over an even longer distance than 805′?
    Kind Regards and thank you

    • Brahim Daouas

      @David Thank you.
      Theoretically, yes but the square wave signal might be distorted at a certain length of the cable. This would be caused due to the self inductance which is caused by the magnetic field generated by the wire. In AC, the current switches its direction back and forth causing a changing field. This changing field reacts with the electrons in the wire opposing the current flow. This opposition is called inductive reactance and acts as resistance. Inductive reactance increases with the frequency of the square wave and the inductance of the wire by this formula : Xl = 2*π*f*L.
      Where L is the self inductance of a wire and is dependent on its length and radius. It can be calculated using this tool/formula
      Therefore, longer the wire, more the self inductance will be important and more this will have an effect on the generator signal.

Leave a Reply

  • (will not be published)