basic stamp2 to start a timer

This is the place for any magazine-related discussions that don't fit in any of the column discussion boards below.
Post Reply
bonesdub
Posts: 4
Joined: Mon Nov 24, 2003 1:01 am
Contact:

basic stamp2 to start a timer

Post by bonesdub » Mon Dec 15, 2003 2:38 am

i was wondering if it could be possible to use the basic stamp2 to start a timer which could output a square wave ie 101010101 ect for a period tof time
i was wondering if anyone could suggest a way of doing this thanks
eoinf

wd5gnr
Posts: 104
Joined: Wed Dec 19, 2001 1:01 am
Contact:

Re: basic stamp2 to start a timer

Post by wd5gnr » Mon Dec 15, 2003 6:10 am

In general, yes. The Stamp is not fantastically accurate over long periods of time, so depending on your definition of "timer" you might need to provide a little extra information. A simplistic approach would be:<p>ctr var word
ctr=0<p>XLoop:
High 0 ' turn on square wave
Pause 5 ' pause 5mS
Low 0 ' turn off square wave
PAUSE 5 ' 5 more mS
ctr=ctr+1
if ctr<500 then Xloop
StopIt: ' end of program
Goto StopIt<p>You would think this would produce 500 10mS squares (5 seconds of pulses). However, it would actually be more because of the overhead of the instructions. You'd have to determine the time emperically and adjust the pauses to suit. You could also use a higher resolution time command to get finer control. For example, you could use a PULSOUT on an unused pin:<p>PULSOUT 15,100 ' nominal delay: 200uS<p>Again, this will be more than 200uS because of internal delays associated with fetching instructions.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests