Please enable JavaScript to view this site.

DAQFactory User's Guide

Navigation: 17 Devices > 17.7 LabJack UE9 / U6 / U3 > 17.7.6 Counters and Timers > 17.7.6.5 Setting up Specific Timer Modes

17.7.6.5.9 System Timer In

Scroll Prev Top Next More

This mode allows you to read the free-running internal 64 bit system timer.  The frequency of this timer is 750khz for the UE9 and 4MHz for the U3.  Since DAQFactory's clock is precise to 1 microsecond (1 MHz), and there is a built in latency of a few milliseconds to actually read the LabJack, there are really only two uses for this timer.  The first is when doing triggered stream.  Here, DAQFactory has no way of determining the time of each scan, so we can use the system timer to apply a high precision time stamp as long as we include the timer in the stream.  This is described in the section on Triggered Streaming.  

The other use is when you need a high precision time stamp on another timer or counter read.  Since all the timer and counter reads are done with a single call to the device, there is no software latency if the desired timers and the timer setup as system timer are read at the same time.  This is as simple as making sure all your LJ_ioGET_TIMER_VALUE requests are together.  This can also be achieved if you are using Channels to retrieve your timer readings as long as your timers all have the same Timing and Offset.

Depending on how long your experiment runs, you may be able to get away with only SYSTIMERLOW.  For the UE9 at 750khz, the low timer will roll over every 5726 seconds, while the U3 at 4MHz rolls over in 1073 seconds.  Here's the script to do both low and high system timers for longer experiments:

 

AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chNUMBER_TIMERS_ENABLED, 2, 0, 0)
//Configure Timer0 as timer low.
AddRequest(ID, LJ_ioPUT_TIMER_MODE, 0, LJ_tmSYSTIMERLOW, 0, 0)
//Configure Timer1 as timer high.
AddRequest(ID, LJ_ioPUT_TIMER_MODE, 1, LJ_tmSYSTIMERHIGH, 0, 0)
GoOne(ID)

Of course you'll probably have more than 2 timers enabled, or perhaps a counter or two.  

If you actually need the high double-word of the system timer, you are going to end up with the time spread across two channels.  You'll have to combine them.  The easiest way is probably to use a calculated V channel.  Here's how to do it, plus convert the counts to actual seconds:

1) Right click on CHANNELS: under V: in the Workspace and select Add V Channel.  Give it a name, such as LJSystemClock.

2) In the Expression area enter the following and click Apply:

 

(SysTimerLow + SysTimerHigh << 32) / 4e6

This assumes you named your timer channels SysTimerLow and SysTimerHigh.  It also assumes a U3 with a 4Mhz clock.  For the UE9, change the 4e6 (4 million) to 750e3 (750 thousand).

You can now use this V channel anywhere you would a regular channel.  You just have to prepend V. in front of the channel name:

V.LJSystemClock

Note: that DAQFactory uses 64 bit double precision floating point for all numbers.  This representation has 52 bits of precision on the integer side, so you can only really store up to 52 bits of this counter.  As the counter gets above 2 ^ 52, you will lose precision in the low order bits.