Shop OBEX P1 Docs P2 Docs Learn Events
How to make a precision timer in STAMP? — Parallax Forums

How to make a precision timer in STAMP?

lee_hanclee_hanc Posts: 4
edited 2010-11-05 07:31 in BASIC Stamp
Hi,

I'm new in STAMP. I have a project that need a timer like a stopwatch and need to be precise as 0.1 ms. Like a timer, I set a time and then turn on. Whatever the program run, when the time is reaching the value that I set, I need to interrupt my program and know the time is out. Does anyone can help me for this? If I need another IC or stuff, what kind of stuff that I need to connect to STAMP? Thank u so much for the help

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-11-04 18:48
    You are not going to be able to do this with a Stamp. There is no accessible timer inside with anything at all like the kind of accuracy you want and the instruction execution time for most Stamp instructions is on the order of the timing you need (100s of microseconds).

    The Propeller could do this easily though, just not a Stamp. Even if you had an external timer with the sort of accuracy you want, the Stamp couldn't react to the end of the time interval fast enough to be useful for you.

    What are you trying to do?
  • lee_hanclee_hanc Posts: 4
    edited 2010-11-04 23:17
    Thanks for the reply...I try to build a "potentiostat" - for chemical sensor. It needs a voltage scan in a certain time. Actually I don't need that precise, I just wonder it will be best if I could have that precise. However, I wonder if I can have a timer like that, maybe no need that precise...does stamp able to do it?
    for an example, I want to change my voltage (using DAC) every 10 ms without affected by the length of the programming code, just as below:


    voltage_scan:

    Timer = 1 ' starting the timer 10 ms

    programming code ' there will be some code here
    ... ' which I don't need to know
    ... ' how long it will take,
    ... ' but surely less than 10ms


    wait: ' wait for the timer to reach 10 ms
    IF Timer =10ms THEN ' ex: if the code take 8ms, then
    GOTO voltage_scan ' it just need to wait for 2 ms
    ELSE
    GOTO wait
    ENDIF


    does stamp able to do something like this? do you have any suggestion for my application like this? Btw, does propeller much more advanced than stamp could do? Thanks
  • Mike GreenMike Green Posts: 23,101
    edited 2010-11-05 07:31
    It is possible to do what you want with a Stamp although the Stamp doesn't have a built-in timer. You have to write your program so that you know how long it takes to execute, then add delays to make up the difference.

    The Propeller is much faster and has a very precise built-in clock that programs can use to create delays (resolution on the order of 10ns).
Sign In or Register to comment.