How do I time processor events?
Tony-
Plans for building a timer for your Stamp and sample programs are
shown on my site as indicated in Reg's email. This is a reasonably
versatile timer with good (1 microsecond) resolution. If you don't
need that much precision, one of the other suggested solutions may
better suit your purposes. The timer chip also has a built in
HD44780-compatible LCD interface, so you get a timer and an LCD
driver without using up a lot of Stamp I/O pins.
If you don't have the means or desire to program your own SX18 I can
send you a programmed chip and oscillator--please contact me
off-list if interested.
Regards,
Steve
On 13 Feb 02 at 9:37, Reginald Neale wrote:
> >Hi how do I get these timing chips from Steve Parkis, and about how much are
> >they? I see how the second Stamp could work, but if there is a cheaper way
> >then that would be better.
>
> go to http://home.earthlink.net/~parkiss/
Plans for building a timer for your Stamp and sample programs are
shown on my site as indicated in Reg's email. This is a reasonably
versatile timer with good (1 microsecond) resolution. If you don't
need that much precision, one of the other suggested solutions may
better suit your purposes. The timer chip also has a built in
HD44780-compatible LCD interface, so you get a timer and an LCD
driver without using up a lot of Stamp I/O pins.
If you don't have the means or desire to program your own SX18 I can
send you a programmed chip and oscillator--please contact me
off-list if interested.
Regards,
Steve
On 13 Feb 02 at 9:37, Reginald Neale wrote:
> >Hi how do I get these timing chips from Steve Parkis, and about how much are
> >they? I see how the second Stamp could work, but if there is a cheaper way
> >then that would be better.
>
> go to http://home.earthlink.net/~parkiss/
Comments
code. I've done this several times, including one commercial application
that required reasonably tight timing.
You'll need an extra output pin. Connect this pin to a second Stamp. Just
before the test section you make this pin go high. At the end of the test
you make that pin go low. The second Stamp has a program running that is
using PULSIN to measure the width of the test pulse. It's easy and effective.
-- Jon Williams
-- Parallax
In a message dated 2/12/02 9:53:36 PM Central Standard Time,
tonys@o... writes:
> Hi I'm trying to time how long it takes to run a certain group of
> operations. It seems simple, I think its the 555 chip that can do this but
> I'm not sure how it can work the way I need it to. I need a chip thats
> counts up an integer by itself, so it won't bog down the processor, which is
> the thing I'm timing, so the processor can't be counting.
>
> For example, I need to time how long it takes to read the thermometer 100x,
> the pseudo-code would look something like this, assuming there is such thing
> as a chip that just counts up as fast as it can:
>
> 1) Reset "timing" chip to zero
> 2) Set "timing" chip to start counting up
> 3) Get the thermometer value 100x, timer is counting up by itself while this
> is happening
> 4) Stop the "timing" chip and get an 16-bit integer value in microseconds
> (or faster)
>
> If you can give some sample code or how to hook up the 555 chip to do this,
> I would very much appreciate it.
>
> Thanks for any help,
> Tony
>
[noparse][[/noparse]Non-text portions of this message have been removed]
operations. It seems simple, I think its the 555 chip that can do this but
I'm not sure how it can work the way I need it to. I need a chip thats
counts up an integer by itself, so it won't bog down the processor, which is
the thing I'm timing, so the processor can't be counting.
For example, I need to time how long it takes to read the thermometer 100x,
the pseudo-code would look something like this, assuming there is such thing
as a chip that just counts up as fast as it can:
1) Reset "timing" chip to zero
2) Set "timing" chip to start counting up
3) Get the thermometer value 100x, timer is counting up by itself while this
is happening
4) Stop the "timing" chip and get an 16-bit integer value in microseconds
(or faster)
If you can give some sample code or how to hook up the 555 chip to do this,
I would very much appreciate it.
Thanks for any help,
Tony
[noparse][[/noparse]Non-text portions of this message have been removed]
stamps by offloading time/pulse measurements. Prices are very
reasonable.
Reg
>Depending on the length of your events, you can use a second Stamp to time
>code. I've done this several times, including one commercial application
>that required reasonably tight timing.
>
>You'll need an extra output pin. Connect this pin to a second Stamp. Just
>before the test section you make this pin go high. At the end of the test
>you make that pin go low. The second Stamp has a program running that is
>using PULSIN to measure the width of the test pulse. It's easy and effective.
>
>-- Jon Williams
>-- Parallax
>
>
>In a message dated 2/12/02 9:53:36 PM Central Standard Time,
>tonys@o... writes:
>
>
> > Hi I'm trying to time how long it takes to run a certain group of
> > operations. It seems simple, I think its the 555 chip that can do this but
> > I'm not sure how it can work the way I need it to. I need a chip thats
> > counts up an integer by itself, so it won't bog down the
>processor, which is
> > the thing I'm timing, so the processor can't be counting.
> >
> > For example, I need to time how long it takes to read the thermometer 100x,
> > the pseudo-code would look something like this, assuming there is
>such thing
> > as a chip that just counts up as fast as it can:
> >
> > 1) Reset "timing" chip to zero
> > 2) Set "timing" chip to start counting up
> > 3) Get the thermometer value 100x, timer is counting up by itself
>while this
> > is happening
> > 4) Stop the "timing" chip and get an 16-bit integer value in microseconds
> > (or faster)
> >
> > If you can give some sample code or how to hook up the 555 chip to do this,
> > I would very much appreciate it.
> >
> > Thanks for any help,
> > Tony
> >
>
>
>
>
>[noparse][[/noparse]Non-text portions of this message have been removed]
>
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed. Text in the
>Subject and Body of the message will be ignored.
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Have a look at:
http://www.emesystems.com/BS2speed.htm
(which has a link to http://www.phanderson.com/timer_1_2.html)
Stephan
On 13.2.2002 16:47, Tony Suriyathep <tonys@o...> wrote:
> Hi how do I get these timing chips from Steve Parkis, and about how much are
> they? I see how the second Stamp could work, but if there is a cheaper way
> then that would be better.
>
>
>
Original Message
> From: Reginald Neale [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ZooIb75mBy4D9vhSzuhfdSreUAivthcmSx3NYREDLj7ynID8L7b6s0LW_ohOZUBOrdRMbJGcLiUvd5-Wh3NcRA]rneale@m...[/url
> Sent: Wednesday, February 13, 2002 2:13 AM
> To: basicstamps@yahoogroups.com
> Subject: Re: [noparse][[/noparse]basicstamps] How do I time processor events?
>
>
> Steve Parkis has designed and made available chips to work with
> stamps by offloading time/pulse measurements. Prices are very
> reasonable.
>
> Reg
>
>
>> Depending on the length of your events, you can use a second Stamp to time
>> code. I've done this several times, including one commercial application
>> that required reasonably tight timing.
>>
>> You'll need an extra output pin. Connect this pin to a second Stamp. Just
>> before the test section you make this pin go high. At the end of the test
>> you make that pin go low. The second Stamp has a program running that is
>> using PULSIN to measure the width of the test pulse. It's easy and
> effective.
>>
>> -- Jon Williams
>> -- Parallax
>>
>>
>> In a message dated 2/12/02 9:53:36 PM Central Standard Time,
>> tonys@o... writes:
>>
>>
>>> Hi I'm trying to time how long it takes to run a certain group of
>>> operations. It seems simple, I think its the 555 chip that can do this
> but
>>> I'm not sure how it can work the way I need it to. I need a chip thats
>>> counts up an integer by itself, so it won't bog down the
>> processor, which is
>>> the thing I'm timing, so the processor can't be counting.
>>>
>>> For example, I need to time how long it takes to read the thermometer
> 100x,
>>> the pseudo-code would look something like this, assuming there is
>> such thing
>>> as a chip that just counts up as fast as it can:
>>>
>>> 1) Reset "timing" chip to zero
>>> 2) Set "timing" chip to start counting up
>>> 3) Get the thermometer value 100x, timer is counting up by itself
>> while this
>>> is happening
>>> 4) Stop the "timing" chip and get an 16-bit integer value in
> microseconds
>>> (or faster)
>>>
>>> If you can give some sample code or how to hook up the 555 chip to do
> this,
>>> I would very much appreciate it.
>>>
>>> Thanks for any help,
>>> Tony
>>>
>>
>>
>>
>>
>> [noparse][[/noparse]Non-text portions of this message have been removed]
>>
>>
what you want.
One thing I've done in the past where I need a cheap time is to use a
large RC network (can't get much cheaper than that). The Stamp
discharges the cap, does its thing, and then uses RCTime to measure how
long it takes the RC to cross threshold. You could compute the time
required to do the operations by computing Top=Ttotal-Trc where you
could determine Ttotal mathematically or experimentally. The
disadvantage is you always require Ttotal time to go through the loop.
If the operation is short, you will still require a constant amount of
time (and Ttotal>Top+overhead for the longest possible Top).
This is a really good technique where you want to time out. For example,
one of the projects of the month awhile back was a combination lock. If
you kept pressing buttons, it wouldn't time out. But if you didn't press
a button for a few seconds, the lock would reset to its original state.
Good luck!
Al Williams
AWC
* Control 8 servos at once
http://www.al-williams.com/awce/pak8.htm
>
Original Message
> From: Tony Suriyathep [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=rvWicQLMKt3aBrGPmsEFVQGnZYBSJqz_cfKh_6F1UmIDTqkG3Zvrlke3jZsONf7TC-nnkxIsyxjJYTVr]tonys@o...[/url
> Sent: Wednesday, February 13, 2002 12:54 AM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] How do I time processor events?
>
>
> Hi I'm trying to time how long it takes to run a certain
> group of operations. It seems simple, I think its the 555
> chip that can do this but I'm not sure how it can work the
> way I need it to. I need a chip thats counts up an integer
> by itself, so it won't bog down the processor, which is the
> thing I'm timing, so the processor can't be counting.
>
> For example, I need to time how long it takes to read the
> thermometer 100x, the pseudo-code would look something like
> this, assuming there is such thing as a chip that just counts
> up as fast as it can:
>
> 1) Reset "timing" chip to zero
> 2) Set "timing" chip to start counting up
> 3) Get the thermometer value 100x, timer is counting up by
> itself while this is happening
> 4) Stop the "timing" chip and get an 16-bit integer value in
> microseconds (or faster)
>
> If you can give some sample code or how to hook up the 555
> chip to do this, I would very much appreciate it.
>
> Thanks for any help,
> Tony
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the
> Subject and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
that life without one is like life without a decent set of hex
wrenches. And as a result of EBay, you can buy a decent used scope
for less than the cost of a pair of stamps.
Toggle a pin at the beginning and end of a loop. Measure time
interval.
--- In basicstamps@y..., "Tony Suriyathep" <tonys@o...> wrote:
> Hi I'm trying to time how long it takes to run a certain group of
> operations. It seems simple, I think its the 555 chip that can do
this but
> I'm not sure how it can work the way I need it to. I need a chip
thats
> counts up an integer by itself, so it won't bog down the processor,
which is
> the thing I'm timing, so the processor can't be counting.
>
> For example, I need to time how long it takes to read the
thermometer 100x,
> the pseudo-code would look something like this, assuming there is
such thing
> as a chip that just counts up as fast as it can:
>
> 1) Reset "timing" chip to zero
> 2) Set "timing" chip to start counting up
> 3) Get the thermometer value 100x, timer is counting up by itself
while this
> is happening
> 4) Stop the "timing" chip and get an 16-bit integer value in
microseconds
> (or faster)
>
> If you can give some sample code or how to hook up the 555 chip to
do this,
> I would very much appreciate it.
>
> Thanks for any help,
> Tony
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
>they? I see how the second Stamp could work, but if there is a cheaper way
>then that would be better.
go to http://home.earthlink.net/~parkiss/
the TLC551 which draws much less power) and an RC network for
the kind of timing you're looking to do. I let a capacitor build up a
charge on the control pin of the 551, and the pulse widths output from
the 551 are then a function of how long it's been since the cap was last
dumped. The nice thing about this method is that you can manipulate
the nominal pulse widths output by the 551 to optimize your program
speed and desired timing resolution. In other words, I can measure
time on the order of seconds with a quick pulsin command. I think the
551 is a buck or so.
Clark Hughes
they? I see how the second Stamp could work, but if there is a cheaper way
then that would be better.
Original Message
From: Reginald Neale [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ncJdH_px3NCq-QGMgKU1rmJd14uyVgdOg2Yn5SgSiIHf5ovdCtYqKUb_OyahPmOnBsijLUzpJMojrRrZveyWWw]rneale@m...[/url
Sent: Wednesday, February 13, 2002 2:13 AM
To: basicstamps@yahoogroups.com
Subject: Re: [noparse][[/noparse]basicstamps] How do I time processor events?
Steve Parkis has designed and made available chips to work with
stamps by offloading time/pulse measurements. Prices are very
reasonable.
Reg
>Depending on the length of your events, you can use a second Stamp to time
>code. I've done this several times, including one commercial application
>that required reasonably tight timing.
>
>You'll need an extra output pin. Connect this pin to a second Stamp. Just
>before the test section you make this pin go high. At the end of the test
>you make that pin go low. The second Stamp has a program running that is
>using PULSIN to measure the width of the test pulse. It's easy and
effective.
>
>-- Jon Williams
>-- Parallax
>
>
>In a message dated 2/12/02 9:53:36 PM Central Standard Time,
>tonys@o... writes:
>
>
> > Hi I'm trying to time how long it takes to run a certain group of
> > operations. It seems simple, I think its the 555 chip that can do this
but
> > I'm not sure how it can work the way I need it to. I need a chip thats
> > counts up an integer by itself, so it won't bog down the
>processor, which is
> > the thing I'm timing, so the processor can't be counting.
> >
> > For example, I need to time how long it takes to read the thermometer
100x,
> > the pseudo-code would look something like this, assuming there is
>such thing
> > as a chip that just counts up as fast as it can:
> >
> > 1) Reset "timing" chip to zero
> > 2) Set "timing" chip to start counting up
> > 3) Get the thermometer value 100x, timer is counting up by itself
>while this
> > is happening
> > 4) Stop the "timing" chip and get an 16-bit integer value in
microseconds
> > (or faster)
> >
> > If you can give some sample code or how to hook up the 555 chip to do
this,
> > I would very much appreciate it.
> >
> > Thanks for any help,
> > Tony
> >
>
>
>
>
>[noparse][[/noparse]Non-text portions of this message have been removed]
>
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed. Text in the
>Subject and Body of the message will be ignored.
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>RCTime to measure how
>long it takes the RC to cross threshold. You could compute the time
>required to do the operations by computing Top=Ttotal-Trc where you
>could determine Ttotal mathematically or experimentally.
That's a neat idea, to subtract the RCtime accumulated during the
test routine from an independently measured total time
Say a 0.1 uf capacitor connected from +5 to P0, and a 909kohm
resistor from P0 to ground, which will allow measurement of test
routines up to ~0.12 second.
Ttest var word
Ttotal var word
total: ' find total time, without the test routine
high 0
pause 20
rctime 0,1,Ttotal ' should be around 0.12 second,
' 60000 counts with R=909k, C=0.1uf
test:
high 0 ' discharge capacitor
pause 20
input 0 ' allow capacitor to start charging
' **** do the special test routine here ****
rctime 0,1,Ttest ' this time will be shorter than Ttotal
debug dec Ttotal, tab, dec Ttest,cr
end
Turning P0 to an input prior to entering the test routine allows the
RCcharging cycle to start early, so when the program does finally hit
the RCtime command, the time it measures will be shorter than Ttotal.
I'm confused right now before morning coffee about whether you can
simply subtract Ttest from Ttotal to get the time taken by the test
routine, or whether you have to do some more math with markers on the
exponential discharge curve
1.3 = 5*exp(-T/(R*C)) ' 1.3 volt Stamp threshold, 5 volt Vdd
It would certainly be linear if the capacitor were charged by a stiff
current source instead of a resistor.
-- Tracy