« Close

Datasheets and User Guides

App Notes

Software & Driver - Line-to-Line Measurement (Mode 14)



This timer mode requires firmware 1.16 or later.



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.

Line-to-Line mode is also available on timers 2 and 3.



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.



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 65535/TimerClock, and resolution is 1/TimerClock, so some examples are:

TimerClock,  MaxTime,  Resolution
     48 MHz,       1.3ms,      20.8ns
       1 MHz,        65ms,          1µs
     3906 Hz,       16.7s,       256µs



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.





To reset in mode 14, does one PUT_CONFIG,  PUT_TIMER_MODE, PUT_TIMER_VALUE?  I ask since QUAD mode is reset with 

PUT_TIMER_VALUE and 0 on one of the timer channels, and the paragraph on resetting mode 14 seems ambiguous ie "Values specified when resetting have no effect.".


To reset mode 14, you use LJ_ioPUT_TIMER_VALUE.

The part about the value having no effect basically means that when you use LJ_ioPUT_TIMER_VALUE that part will be ignored.  I.e. if you pass a 0 or 1 it will not change between measuring a rising or falling edge.  That can only be set when the timer is originally configured.

It happens all the time that I have mistakes in the line-to-line measuring. All other signals are all right, just the line-to-line measuring caused problems. I am not sure what it could be, but it seems that it always happens when the PC can't get every signal. Is it possible that the measurement increases at a following Timer0 even if there was no reset before?



Hi JS,

The Line-2-Line mode disables itself after receiving the two control pulses.

I think we are going to need to troubleshoot your program and system further. Please start a forum topic describing your problem and setup.