Skip to content

05. The Controller

JonasForssell edited this page Aug 4, 2017 · 17 revisions

The controller consists of minimum three parts that are stacked on top of each other. The stacking creates a connection between the boards though the analog and digital pins.

The Signal

To understand how the reciever functions we must first explain a little about the signal. The wire you place in the garden is connected to a transmitter in the base station. The transmitter sends a current through the wire.

The current will generate a magnetic field according the right hand rule you maybe recall from school

The coils in the mower will not sense this field, but they will sense changes to the field. If the field increases or decreases, it will generate a little voltage in the coil. The voltage will be positive or negative depending on the direction of the field as well as if it increases or decreases.

In the figure you can see the BWF wire placed in the garden and how the magnetic field is generated. If the mower is inside the BWF, the magnetic field will pass down through the coils if the current is running in clockwise direction (black) or up through the coils if it is running in the other direction.

The transmitter now controls the current by turning it on and off according to a pattern.

The figure above shows the current in the BWF. In the middle, the current is shut off. Above the middle, we are sending the current in positive direction and below, it is going the other way. We control the BWF current exactly in the same way we control a DC motor and making it run backwards or forwards.

The reciever is designed to sense the change in only one direction. If it is inside, it will sense if the current goes up and when it is outside it will sense if the current goes down. Remember that it only can sense CHANGES in the magnetic field.

We can use this now to create different signals. The arduino in the mower will measure the time passed between the signals. If the mower is inside, it will be the time you see on the top in the figure and is the mower outside, it will see the time shown in the lower part of the figure.

Inside, it will get a number sequense of 2, 101, 100 Outside it will get 101, 102

The signal is repeated so these numbers will come back over and over again.

The current program has simplified the number sequence to 2 for inside and 102 for outside. In the latest design, these numbers are different (If I recall right it is 86 and 4, but the principle still applies.

The numbers are actually time expressed in milliseconds. Most of the time the current in the wire is shut off and this is for a reason. The motor shield would be very hot otherwise and we significantly reduce the power needed to generate the signal.


The reciever is custom made by the group. It is originally based on a design by P-O Johansson which we have adopted to work in an arduino enviroment. It has been slightly extended to handle up to four different BWF sensors.

Here is an outtake of the design, showing the reciever part of the circuit.

The sensor signal comes in from top left at BWF Sensor A, B The first step is an amplification of the signal. The capacitor in C8 provides a filter function at the same time to eliminate spikes.

The amplified signal now goes in the the second OpAmp where it is translated into an On - Off signal (squared).

The squared signal is now passed through a diode. This eliminates all negative pulses and allows only the positive to pass. It is important step because this is the key component that allows us to understand if we are inside or outside the wire.

Next, the pulse is referenced to a holding value to make it more stable (Hold)

This value finally fed into the arduino. The pulse will trigger an interrupt inside the arduino and run a timing routine which notes the time since the last pulse.

Controller & related pins

The controller does not only receve and interpret the signal from the BWF, but performs a range of other functions as well.

We have chosen to define all the pins in the controller as follows

Pin Name Used for
A0 WHEEL_MOTOR_A_CURRENT_PIN Sensing the load on the wheel motor
A1 WHEEL_MOTOR_B_CURRENT_PIN Sensing the load on the wheel motor
A2 SOC_PIN Sensing the battery voltage level
A3 CUTTER_CURRENT_PIN Sensing the load on the cutter motor
A4 I2C_SDA_PIN Communication to other stuff
A5 I2C_SDL_PIN Communication to other stuff
D0 RX_PIN Communication to BT and USB
D1 TX_PIN Communication to BT and USB
D2 BWF_SENSOR_INPUT_PIN This is where the BWF signal is read
D3 WHEEL_MOTOR_A_PWM_PIN Speed on the wheelmotor
D4 BWF_SELECT_A_PIN Select which of the coils should be used
D5 DOCK_PIN Goes high if the mower is docking with the charge plates
D6 CUTTER_PWM_PIN Speed control of the cutter motor
D7 BWF_SELECT_B_PIN Select with of the four coils should be used
D8 BUMPER Connect this via a switch to GND to make a bumper
D9 LIFT Connect this via a switch to GND to sense a lifted mower
D10 LED_PIN Turn LED on or off
D11 WHEEL_MOTOR_B_PWM_PIN Speed of wheel motor
D12 WHEEL_MOTOR_A_DIRECTION_PIN Direction of wheel motor
D13 WHEEL_MOTOR_B_DIRECTION_PIN Direction of wheel motor

Note: when using D8 or D9, remember to cut the trace for the brakes on the motor shield. The features attached to these pins must also be enabled in the code before working

Motor shield

The wheel motors must be controlled by the arduino, but the current they need is too high for the arduino to handle right away. We need a separate shield to do this.

There are many different shields available but we use the most popular, based around a chip called L298.

The motors are attached to this shield. In normal case, we would also attach the battery to the shield, but we have found that for smaller motors like the ones we use, we can supply the current via the top shield instead. It will run down through the VIN pin to the motor shield in this case.

The shield is then snapped onto the arduino like a lego brick. This way we can control the motors via some of the pins on the side. Look at the table above to see which ones are used.

If you get a clone shield for example on EBAY, make sure that the current sensing is included (using pins A0 and A1). Some cheap clones have emitted this.

If you are using a bumper, you need to disable the brake pins D8 and D9. Use a sharp knife and cut the trace close to the pins at the designated area


We use the Arduino UNO as a base design. Reason being that is is available at a low cost from most sources.

The UNO is not fast so we are discussing upgrades in the future. Some boards considered are:

Board Advantage
MEGA Pin compatible and with a very low cost. More memory, many expansion possibilities but not faster
101 Pin compatible (except from PWM on D4). Includes accelerometer and BT! Fast but high cost. Recent news that Intel has pulled the plug on this one makes it less interesting
Zero Successor of UNO. Fast! Can only handle 3.3V maximum so it needs a different top shield


You can’t perform that action at this time.