Stop Watch
The a/d nodes have a 5GHz counter that can be read to time durations.
I use node 512 to generate green text. So it's convenient for 612 to act as a timer. It can talk via 712, 711 and 710 to 709 and read its counter. Then tell 512 to display it, in big decimal numerals.
Three words go thru the down port to 712
- ! to read and start the counter
- ! to read and stop
- @ to return the count
The wire nodes must be bi-directional, sending 2 words and returning one.
In order to isolate the significant duration:
- First a delay is measured that includes any overhead (analogous to tare offset on a scale)
- Then the desired delay is measured and offset subtracted
- And at some time the counter speed must be calibrated. I've measured the counts during a scan line (25 us).
time
Actually measures the delay
- Offset on stack (dup)
- Save register a (might be used by code)
- Send start
- Execute code to be timed
- Restore a
- Send stop
- Receive count
- Subtract offset
cal
Apply calibration to count
- Save a which is used by */
- Move count over ns/count (.1782) so the unsigned count becomes the multiplier for */. This extends the maximum count to 262,143
- Restore a
tare
Similar to time but timing overhead code. The line marked 'x' is where such code is placed. Leaves offset on stack.
go
An infinite loop
- Times the code
- Applies calibration
- Sends to node 512
This is only done once per frame. Synchronization is managed by hanging on the !b.
Calibration
To measure the counts in a scan line
- Un-comment the ; in time
- Comment the cal in go
- Comment go and un-comment cal in init for node 709
Such editing of source code is much easier than having separate calibration code.
init
Two items of note
- It reads a word from up (512) before starting. 612 is loaded before 512, so must delay
- Starts at tare which falls into go. Thus tare is run only once.
Typically, code is edited and loaded. Measurements are observed. Code re-edited, etc. This interactive process is essential to getting a credible measurement.