Timer help
Chemkid
Posts: 2
Hi, first time user here and I am faced with a little problem.
I am quite new to using a STAMP(BS2SX) so I have not been able to figure this out on my own, and I was hoping one of you could help. I need to be able to identify the amount of time that has passed between two high signals that have been sent to two different input pins( obviously time has elapsed between each high signal) . I have looked through the manual and have not found a simple command which does this, and cant quite wrap my head around a code that can do this.
Any help would be appreciated.
Thanks in advance!
Chemkid
I am quite new to using a STAMP(BS2SX) so I have not been able to figure this out on my own, and I was hoping one of you could help. I need to be able to identify the amount of time that has passed between two high signals that have been sent to two different input pins( obviously time has elapsed between each high signal) . I have looked through the manual and have not found a simple command which does this, and cant quite wrap my head around a code that can do this.
Any help would be appreciated.
Thanks in advance!
Chemkid
Comments
do until inputpin2=1
timer=timer+1
PAUSE 1
loop
endif
As Mike suggested, putting a PAUSE in the loop will increase your elapsed time capability, but it won't actually produce an accurate millisecond count that you could convert directly to elapsed time because the loop execution time isn't accounted for. The more you put in the loop, the longer it will take to execute. If timer is a word variable, the max count number is 65,535 before you run into problems. Inserting a PAUSE 1, 2, or longer into the loop can reduce your count if needed. The PAUSE is not required if you are measuring very short time intervals. Once you get everything in the loop, run it for a fixed period of time and see what the count is. Use an equation to convert the timer value to actual elapsed time if required.
chemkid