Accurate Programmable Solenoid Timer

Pictured below is a timer which we made today – designed to energise a solenoid valve for a user-programmable duration after the on board button is pressed.

accurate user programmable timer

In our article Making Very Accurate Timers we looked at some ways in which accurate timers can be made – much more accurate than timer circuits based around 4060B counters and 555 ICs for example.

For this timer though since the accuracy required was +/-1 second in five minutes, we just used a microcontroller (PICAXE), making it much easier to set things up to enable user programming of the timer.

The common way to make such a timer is to have it run for a given number of seconds, and repeatedly call pause 1000 which makes the circuit wait for 1000ms (=1 second). The timing accuracy of microcontroller without external clock crystals can be quite poor, but they tend to be consistent.

Therefore to calibrate the timer we simply set it to run for 30 minutes, measured how long it actually took using a stopwatch (which turned out to be 10 seconds less than 30 minutes (so 1790 seconds instead of 1800). As it was therefore fast by 100*(1800/1790)-100 = 0.558%, we increased the 1000ms pause by 0.588% giving 1006 of the microcontroller milliseconds for 1000 real milliseconds. This slowed the timer down a fraction giving it the required accuracy.

For user programming, the button is used to set first the number of minutes the timer is to run, and then the number of seconds (in 10 second steps). The entered minutes and seconds value is then stored in memory and the timer runs for that time whenever the user subsequently pressed the button to turn on the output.


Leave a Reply