Sunday, November 15, 2009

Moving

Hi, please note that this blog has now moved to http://marcel.carrietech.com.

Wednesday, November 4, 2009

RainDance - Sprinkler Controller


I am nearing completion of my first actual brought-to-completion microcontroller project. The application: to control sprinklers and drip hoses in the back yard through a web interface, with multiple timers for each valve and power back-up. This was accomplished by creating a custom electronic platform, along with a dynamic website for the user interface.



Hardware
The hardware consists of a SitePlayer network module, a PIC 18LF2321, a 3V coin cell battery, and glue logic. The valves that control the waterflow are turned on and off with relays that switch 24VAC power. The relays themselves are driven from the PIC I/O pins using driver ICs. Twelve valves in total are in use for this project, the number being limited mainly by the memory of the PIC device selected.

The SitePlayer module implements all the handling of network devices. It includes a flash memory that stores all the web site files. In the files, strings of the form ^foo are replaced by the content of the variable 'foo', which is one of a number of data types, automatically when the website is served by the site player. A UART (RS232) link between the PIC and the SitePlayer allows the PIC to read and write the variables in the SitePlayer's on-board memory.

Additionally, a serial I2C eeprom is available for logging events.

Software & Logical Design
The logical design of the device is as follows: the SitePlayer serves up a website with information regarding the current configuration of the system (current time, day, status of the valves, etc.). Most of the dynamic information is retrieved via AJAX. When the user makes a change to the web interface, a specially formatted string is written to the SitePlayer (again, using AJAX), and the SitePlayer module toggles an I/O pin, raising an interrupt on the PIC. The PIC notices this interrupt, reads the command string out of the SitePlayer, updates its internal parameters, and then updates the SitePlayer's memory, reflecting the changes. Then, the SitePlayer propagates the changes back to the browser.

Furthermore, the PIC reacts to a timer interrupt generated every 2 seconds, and updates its internal clock. On every minute roll-over, it checks whether any valves need to be turned on or off.

There is a back-up battery, which makes sure all the settings (which are stored in PIC RAM) are preserved across power losses. In battery mode, the valves are not being activated, nor is the SitePlayer running. The PIC wakes up every 2 seconds, updates the internal time, and goes back to sleep, so minimal power is consumed. When power is restored, the SitePlayer is re-initialized with data, and can be accessed via the network again.