Basic Stamp- Keeping Track of Time
Archiver
Posts: 46,084
Hi Stamplist,
I'm looking for an accurate way to measure the elapse
time between a software event and a harware event
(input pin2 going high). The following code works but
it only has 1ms resolution at best. I'm using a BS2SX
and technically should be able to get a much better
resolution. Does anyone have a better way to do this?
Thanks in advance.
<SNIP>
MAIN:
ms = 0
LOW Relay 'make sure relay is off
PAUSE 100
HIGH Relay 'turn relay on (SOFTWARE EVENT)
Looking:
PAUSE 1
ms = ms + 1
if (ms > 200) THEN TimedOut
if (IN2 = 0) THEN Looking 'HARDWARE EVENT
LOW Relay
DEBUG "Time of event was: ", ms, "ms"
STOP
__________________________________________________
Do You Yahoo!?
Yahoo! Messenger - Talk while you surf! It's FREE.
http://im.yahoo.com/
I'm looking for an accurate way to measure the elapse
time between a software event and a harware event
(input pin2 going high). The following code works but
it only has 1ms resolution at best. I'm using a BS2SX
and technically should be able to get a much better
resolution. Does anyone have a better way to do this?
Thanks in advance.
<SNIP>
MAIN:
ms = 0
LOW Relay 'make sure relay is off
PAUSE 100
HIGH Relay 'turn relay on (SOFTWARE EVENT)
Looking:
PAUSE 1
ms = ms + 1
if (ms > 200) THEN TimedOut
if (IN2 = 0) THEN Looking 'HARDWARE EVENT
LOW Relay
DEBUG "Time of event was: ", ms, "ms"
STOP
__________________________________________________
Do You Yahoo!?
Yahoo! Messenger - Talk while you surf! It's FREE.
http://im.yahoo.com/
Comments
You would have to time it for calibration.
Ray McArthur
Original Message
From: Billy Gee <popcorn_speaker@y...>
To: <basicstamps@egroups.com>
Sent: Saturday, October 21, 2000 2:12 PM
Subject: [noparse][[/noparse]basicstamps] Basic Stamp- Keeping Track of Time
> Hi Stamplist,
>
> I'm looking for an accurate way to measure the elapse
> time between a software event and a harware event
> (input pin2 going high). The following code works but
> it only has 1ms resolution at best. I'm using a BS2SX
> and technically should be able to get a much better
> resolution. Does anyone have a better way to do this?
> Thanks in advance.
>
> <SNIP>
>
> MAIN:
> ms = 0
> LOW Relay 'make sure relay is off
> PAUSE 100
> HIGH Relay 'turn relay on (SOFTWARE EVENT)
>
> Looking:
> PAUSE 1
> ms = ms + 1
> if (ms > 200) THEN TimedOut
> if (IN2 = 0) THEN Looking 'HARDWARE EVENT
>
> LOW Relay
> DEBUG "Time of event was: ", ms, "ms"
>
> STOP
I thought of this but I don't know how long it takes
to execute each statement in the loop. I added the
1ms (smallest PAUSE increment) so that I have a known
elapse time for each loop. This does not take into
account the time to execute the other statement.
(compounding the error).
Does anyone know how long it takes to execute each of
the commands in the loop?
Thanks.
--- Ray McArthur <rjmca@u...> wrote:
> Couldn't you remove the "Pause 1" statement and have
> a much faster loop?
> You would have to time it for calibration.
>
> Ray McArthur
>
>
Original Message
> From: Billy Gee <popcorn_speaker@y...>
> To: <basicstamps@egroups.com>
> Sent: Saturday, October 21, 2000 2:12 PM
> Subject: [noparse][[/noparse]basicstamps] Basic Stamp- Keeping Track of
> Time
>
>
> > Hi Stamplist,
> >
> > I'm looking for an accurate way to measure the
> elapse
> > time between a software event and a harware event
> > (input pin2 going high). The following code works
> but
> > it only has 1ms resolution at best. I'm using a
> BS2SX
> > and technically should be able to get a much
> better
> > resolution. Does anyone have a better way to do
> this?
> > Thanks in advance.
> >
> > <SNIP>
> >
> > MAIN:
> > ms = 0
> > LOW Relay 'make sure relay is off
> > PAUSE 100
> > HIGH Relay 'turn relay on (SOFTWARE EVENT)
> >
> > Looking:
> > PAUSE 1
> > ms = ms + 1
> > if (ms > 200) THEN TimedOut
> > if (IN2 = 0) THEN Looking 'HARDWARE EVENT
> >
> > LOW Relay
> > DEBUG "Time of event was: ", ms, "ms"
> >
> > STOP
>
>
>
>
>
__________________________________________________
Do You Yahoo!?
Yahoo! Messenger - Talk while you surf! It's FREE.
http://im.yahoo.com/
I had a similar problem and allowed the loop to count for 65535 counts,
which allowed using a stopwatch to calibrate the timing...this was with a
BS1.
BTW...Tracy Allen has timing data for various statements. Don't know if he
covers the SX.
Ray McArthur
Original Message
From: Billy Gee <popcorn_speaker@y...>
To: <basicstamps@egroups.com>
Sent: Saturday, October 21, 2000 2:41 PM
Subject: Re: [noparse][[/noparse]basicstamps] Basic Stamp- Keeping Track of Time
> Thanks Ray,
> I thought of this but I don't know how long it takes
> to execute each statement in the loop. I added the
> 1ms (smallest PAUSE increment) so that I have a known
> elapse time for each loop. This does not take into
> account the time to execute the other statement.
> (compounding the error).
>
> Does anyone know how long it takes to execute each of
> the commands in the loop?
http://www.emesystems.com//BS2speed.htm
Toward the bottom of the page is a discussion of optimal timing loops.
The times for the BS2SX are 2.5 x faster than the BS2.
-- Tracy