Shop OBEX P1 Docs P2 Docs Learn Events
Timer for dispensing system — Parallax Forums

Timer for dispensing system

waynelwaynel Posts: 2
edited 2013-01-21 12:28 in BASIC Stamp
Hello All
I am building a drinks dispensing systems. I have four solenoid valves driven with four MOSFETs, via a BS2. Also I have LCD03 display.
I would like to activate the solenoid all at one but switch them off at different times. For example Valve1=200sec, Valve2=203sec, Valve3=196sec and Valve4=210sec.
The problem I find with the BS2 is that there is no interruptible timer or timer registers. Is there another device I can add such as a timer ic with registers and comm via serial?
Cheers
WayneL

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2013-01-21 11:05
    Hi and welcome to the Forums.

    You could indeed add an external timer module such as a DS1307.

    But an easier way might be to add a short subroutine to your program which will give a delay of say, 100 mSec.

    Now, each part of your solenoid program can call the subroutine repeatedly. The solenoid code just has to track how many times it called the delay subroutine to figure out the seconds delayed.

    Cheers,
  • Prophead100Prophead100 Posts: 192
    edited 2013-01-21 12:28
    Perhaps it would be slightly less exact but you could use a basic counter loop with using a tiny delay to keep your loops the right length then have four "IF TIMER>X THEN turnoff solenoid X" statements in your loops check if each has exceeded its limit. You may also want to add a little time in for the lag of the time it takes the solenoid to close.
Sign In or Register to comment.