[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Oct 12 15:56:24 1993 
Subject:Re: Threaded Interpretive Languages 
From:Penio Penev 
Volume-ID:931015.14 

On 11 Oct 1993 00:11:10 GMT Nathan Stratton (nstn@quercus.gsfc.nasa.gov) wrote:
| In article <1993Oct10.132809.24377@rockyd.rockefeller.edu> penev@venezia.rockefeller.edu writes:
| >On 10 Oct 1993 13:14:30 GMT Nathan Stratton (nstn@quercus.gsfc.nasa.gov) wrote:
| >| Hi, I am a little new to forth I am building a ultrasonic ranger board for
| >| my robot. To send a ping you need to load a 1 into 768. When the ping is 
| >| recived it sets bit 1 of 772 high. My question could forth count the delay
| >| between sending a ping and receiving a ping. How accurately can I measure
| >| the delay can get get below a ms ????
| >
| >The answer to this question depends on many things. 
| >What is your processor?
| >Do you have an onboard clock? 
| >Can you use interrupts?
| >Do you mant to do multitasking, while waiting to receive the ping?

| I am using a 386 40 Mhz motherboard, and would like it if I could have a
| rutine running in the background that would ping and then wait for the ping. 
| Then If the rutine could put it time it took for the ping to return in a 
| variable.

The notes bellow assume, that you want to run other tasks, while
waiting for the ping to come.

If you are using a whole motherboard, then you have a timer and
interrupts. The most accurate way is to 
- init the timer and the interrupt routine
- disable interrupts
- send the ping
- start the timer
- enable interrupts

/this depends on what system You are using, I assume polyFORTH here/

- STOP the task
- read the timer to TOS
- exit

The interrupt routine:

- stop the timer
- WAKE the task
- reti


Make sure, that you don't have the interrupts disabled for too long
time from other sources (notably floppy transfer). You can measute the
interrupt - response time for your system, if you need that accuracy.

If you cannot set up things so that the ping receive interrupts you,
things a little bit more complicated. You decide the accuracy with
which you want to measure. Divide the interval by two, and set the
timer to generate the interrupts at this delay. Now, in the interrupt
routine you check the status of 772, and if ON, stop the clock and
WAKE the task.

There are a few more variants with varing accuracies and system loads.
Note, that if you can afford 100% system load, you can just disable
the interrupts and count-loop in asssembler untill the 772 is ON.

--
Penio Penev  x7423 (212)327-7423 (w) Internet: penev@venezia.rockefeller.edu

Disclaimer: All oppinions are mine.