PDA

View Full Version : Introducing timed delays


Sangfroid
06-03-04, 03:11 AM
Hi,
I would like to know "How to wait for 1 sec or so in a particular state?" i.e I would like to waste 1 sec or so while my servo moves every 10 degrees.
It shud b smthng like-
The servo moves----It waits for some time---moves----waits---until it spans 180 degrees.

Simple delay loops (DO LOOP) are not helping me. I need precise timing.

Thanx in advance

nmitech
06-03-04, 09:14 AM
Here is an example from the download page,
http://www.newmicros.com/store/product_details/download.html

\ TIMING EXAMPLE USING TCFTICKS
\ TCFTICKS is a counter variable which is incremented once per IsoMax cycle.
\ Unless otherwise specified with CYCLES or PERIOD, the default rate is
\ 100 Hz. TCFTICKS is an unsigned 16-bit value which rolls over from FFFF to 0.

DECIMAL 100 CONSTANT 1-SECOND \ 100 counts of a 100 Hz clock

: WAIT-1-SECOND ( -- ) TCFTICKS @ \ starting time
BEGIN
TCFTICKS @ OVER - \ elapsed time since start
1-SECOND > UNTIL
DROP ; \ discard starting time