Shop OBEX P1 Docs P2 Docs Learn Events
Timer — Parallax Forums

Timer

walt9285walt9285 Posts: 1
edited 2010-05-06 19:55 in BASIC Stamp
Hi everyone,

I am doing a project for school and I have to build a titration system, I am using a Stamp program to turn pumps on and off by using LEDs and Photo-diodes. I was wondering if there was a way to count the seconds one of the pumps is on and then save it to a file?

Thanks for the help,

Travis

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-05-06 19:55
    It's possible to get an approximation to the time by using PAUSE as a time "tick". It depends on how complex your pump control program logic is and what the timing resolution might be. The general idea looks like this:

    Set time count to zero
    Turn on pump
    OnLoop:
    PAUSE 10 (to give you a 10ms time "tick"
    Increment count
    See if you want to turn pump off, GOTO OnLoop if not
    Count now gives on time in units of 10ms
    Turn off pump

    Another alternative is to used some kind of external timer like a DS1302 Real Time Clock
Sign In or Register to comment.