Sprinkler & Water Usage Controller.

Board Layout files for the Olimex sponsored PCB contest


Circuit

Code:


This unit combines a 7 day, 7 event twentyfour hour timer with a water consumption/cost meter written using the Wiz-C C compiler from Forest Electronics www.fored.co.uk or www.dontronics.com.au and a two line LCD is used as the display.

The two units are not dependent on each other so it can be used as a liquid flow meter or as a timer . The duration ON time is a maximum of 4hours 45 minutes and the minutes increment in 15minute intervals.

The timer uses the Bresenham algorithm modified by Roman Black for accuracy, and the slightly weird 'C' function for this produces the assembler statements as per Roman's original for this particular compiler.

The solenoid and flow sensor were obtained from RS components and similiar flow sensors are available from Rapid Electronics in the UK. It may be possible to use a pre-built solenoid from gardening centres but this hasn't been tried. If a different flow sensor is used or you decided to roll your own the number of pulses per litre or gallon will need to be altered in the appropiate header file. Timer1 is used in compare mode and RC0 is the clock input for the flow sensor.

There are 3 buttons. Menu button advances throught the 6 different options and Whole_digits(button2) and Tenth_digit (button3) perform different functions depending on the menu choice.

The button format is

  Menu  Sub Menu      Button1             Button2                     Button3
   0         -    advance menu        view cost/usage totals           -
   1         0    Timer programming   increment On day              increment event
             1                        increment On Hour                 "       "
             2                           "     On Minute               "       "
             3                           "     Duration Hour           "       "
             4                           "     Duration Minutes        "       "
             5                        Next programming event         rolls over to sub menu 0
   2              Day setting         Increment clock day                 -
   3              Time setting        Increment clock time           Increment clock minutes
   4              Unit cost setting   Increment $/£                  Increment c/p
   5              Reset               Zero Klitres/Gallons used      Zero 


Total cost

The maximum unit cost is 9.99 of your favourite currency and the maximum volume is 999,999 Litres / Gallons.

The unit cost is stored in flash EEPROM. The current totals are only stored after a sprinkling event. Provision is made on the PCB for an external I2C EEPROM using address 0 in case a flow meter only version is required or if it is preferred to make more frequent writes to memory.

In the future it is intended to add on rain sensor to prevent sprinkling during rainy periods.

After a powercut the LED will flash to show that power has been lost and a press of the menu button will start the timer up again. If a powercut happens during an On period then the usage information is lost.

At start up the display will default to Day setting and you may need to zero the usage counters.

The PCB has been designed using EAGLE v 4.09r2 to allow extra additions if required.

The flyback diode is connected directly across the solenoid contacts.

The extra file LCD_1.c has been included because I wanted the ability to use any nibble for the data lines and the Wiz-C library file only allows for the upper nibble of a port and uses the WR line.

This board is available from Olimex