2.9.1.9 - Timer Stop Input (Mode 9)
This mode should only be assigned to Timer1. On every rising edge seen by the
external pin
, this mode increments a 16-bit
register. When that register matches the specified timer value (stop count value), Timer0 is stopped. The range for the stop count
value is 1-65535. Generally, the signal applied to Timer1 is from Timer0, which is configured in some output timer mode. One
place where this might be useful is for stepper motors, allowing control over a certain number of steps.
Note that the timer is counting from the external pin like other input timer modes, so you must connect something to the stop timer
input pin. For example, if you are using Timer1 to stop Timer0 which is outputting pulses, you must connect a jumper from Timer0
to Timer1.
Once this timer reaches the specified stop count value, and stops the adjacent timer, the timers must be reconfigured to restart the
output.
When Timer0 is stopped, it is still enabled but just not outputting anything. Thus rather than returning to whatever previous digital
I/O state was on that terminal, it goes to the state "digital-input" (which has a 100 kΩ pull-up to 3.3 volts). That means the best
results are generally obtained if the terminal used by Timer0 was initially configured as digital input (factory default), rather than
output-high or output-low. This will result in negative going pulses, so if you need positive going pulses consider using a simple
inverter IC such as the CD74ACT540E from TI.
The MSW of the read from this timer mode returns the number of edges counted, but does not increment past the stop count value.
The LSW of the read returns edges waiting for.
2.9.1.10 - System Timer Low/High Read (Modes 10 & 11)
The LabJack U3 has a free-running internal 64-bit system timer with a frequency of 4 MHz. Timer modes 10 & 11 return the lower
or upper 32-bits of this timer. An FIO line is allocated for these modes like normal, even though they are internal readings and do
not require any external connections. This system timer cannot be reset, and is not affected by the timer clock.
If using both modes 10 & 11, read both in the same low-level command and read 10 before 11.
Mode 11, the upper 32 bits of the system timer, is not available for stream reads. Note that when streaming on the U3, the timing is
known anyway (elapsed time = scan rate * scan number) and it does not make sense to stream the system timer modes 10 or 11.
Note that system timer runs at 2MHz on U3 hardware 1.20.
2.9.1.11 - Period Measurement (16-Bit, Modes 12 & 13)
Similar to the 32-bit edge-to-edge timing modes described above (modes 2 & 3), except that hardware capture registers are
used to record the edge times. This limits the times to 16-bit values, but is accurate to the resolution of the clock, and not subject to
any errors due to firmware processing delays.
Note that the minimum measurable period is limited by the edge rate limit discussed in Section 2.9.2.
2.9.1.12 - Line-to-Line Measurement (Mode 14)
This timer mode requires firmware 1.30 or later.
Introduction:
The Line-to-Line timer mode uses two timers to measure the time between specified edges on two different lines. For instance,
you can measure the time between a rising edge on Timer0 and a falling edge on Timer1. When the LabJack sees the specified
edge on Timer0 it starts counting until it sees the specified edge on Timer1. High resolution up to 20.8ns can be achieved with this
mode.
Configuring:
To configure a LabJack for Line-to-Line mode set an even timer and the next (odd) timer to mode 14. The timer values determine
the edge that the timer will respond to, 1 being rising, 0 being falling. So, if Timer0's value is 0 and Timer1's is 1 then the LabJack
will measure the time between a falling edge on Timer0 to a rising edge on Timer1.
Readings:
Once configured the timer will return zero until both specified edges have been detected. The time difference in TimerClock
periods is then returned by both timers until they are reset. Both timers will return the same reading, so it is only necessary to read
one or the other. To convert to time, divide the value returned by the timer clock. This mode returns 16-bit values, so care should be
taken to be sure that the specified condition does not exceed the maximum time. The maximum time can be calculated by (2^16-
1)/TimerClock.
Resetting:
Once a measurement has been acquired the even timer needs to be reset before the LabJack will measure again. Values
specified when resetting have no effect. Once reset the even timer will return zero until a new measurement has been completed.
Resetting the odd timer is optional, if not reset it will continue to return the last measurement until a new one has been completed.
2.9.1.12 - Line-to-Line (Mode 14)
2.9.2 - Timer Operation/Performance Notes
Note that the specified timer clock frequency is the same for all timers. That is, TimerClockBase and TimerClockDivisor are
singular values that apply to all timers. Modes 0, 1, 2, 3, 4, 7, 12, and 13, all are affected by the clock frequency, and thus the
simultaneous use of these modes has limited flexibility. This is often not an issue for modes 2 and 3 since they use 32-bit
registers.
The output timer modes (0, 1, and 7) are handled totally by hardware. Once started, no processing resources are used and other
U3 operations do not affect the output.
19