Christian Hornung's Software Development Pages


Menu

Watering robot with LEGO RCX

In summer 2008, I built this fully functional watering robot with LEGO and the LEGO Mindstorms RCX.
(You can click on all images to view them in full size.)

Watering robot with LEGO RCX

The Hardware

The robot is driven by a standard LEGO 9V power motor, located underneath the RCX and geared down in two stages. This drive provides enough force to pull the hose if it is laid out in parallel to the lane before starting.

The robot drives in a simple lane made of shelves and slats, which you can see more clearly in the following picture:

Watering robot in its lane

The lane consists of pieces with a length of 1.2m each which can be combined as necessary. However, the robot is only capable of driving straight. Only the axle below the RCX is driven, while the other axle has a rotation sensor which is used to measure the travelled distance.

As its power source, the robot carries an 8-cell NiCd accumulator with a nominal voltage of 9.6V which you can see in the next picture. This is done because I did not want to use non-rechargeable batteries and putting rechargeable ones into the battery case of the RCX does not work well because it is built for 6 cells and then the voltage is too low. The accumulator is located at the bottom of the robot and held in place by the two cyan beams. With the crank you can turn those beams upwards to open the accumulator tray.

Watering robot from the side

The robot is equipped with a motoized valve which I got from dismantling a cheap electronic water timer. The green plate you can see in the above picture at the water inlet is a remaining part of the case of the water timer which I could not remove. The water timer required two 1.5V battery cells, so I built a 3V regulator using an LM317T to provide the correct voltage for the valve motor. It is located on the small circuit board which you can see in the following picture.

Watering robot from the other side

The input of the regulator is connected to a motor output of the RCX. This works because the valve is designed so that the motor only needs to run in one direction and the valve cycles repeatedly between open and closed.

The last gear of the valve already came with maze-like conductors on it and three contacts mounted. These can be used to sense the current position of the valve. As I found out, the first contact is common ground, the second one reports the absolute position of the valve (open/closed) and the third one gives a short pulse at the points where the motor should stop for the valve to be fully open or closed. I connected these to two RCX sensor inputs.

In the following picture you can see a close-up of the RCX and a part of the gearing of the valve:

Watering robot: RCX and valve

The Software

I am using the brickOS operating system for the RCX which allows user programs to be written in C and compiled to native code for the target processor.

My program for this robot provides the ability to enter operation sequences using the LEGO remote control and execute them. The available instructions are:

  • Drive to a specific position (relative to starting point)
  • Wait for a specific amount of time
  • Open or close the valve

This allows for flexible programming as necessary.

The entered sequences can also be downloaded to the PC using LNP so that they can be saved when the RCX program must be changed, for example.

Of couse the program also has error detection features, so that it stops the robot and attempts to close the valve when an unexpected condition occurs, for example when it gets stuck or when the valve sensors are not working correctly.

You can download the complete source code here (some parts are in German though):


Modified: 2008-09-23 Copyright © 2006-2008 Christian Hornung - chhornung@googlemail.com