v0.61.3
ReferenceHardwareLabJackRead task

LabJack read task

Read analog, digital, and thermocouple inputs from a LabJack into channels.

A LabJack read task reads the inputs of one LabJack device into channels. For example, it can record a pressure transducer on AIN0 and a switch on DIO4 at 1 kHz.

Before you start, you need a configured device.

Channels and timing

A read task has three types of channels:

  • Analog input -> a voltage on an AIN port.
  • Digital input -> the state of a DIO port, as 0 or 1.
  • Thermocouple -> a temperature from a thermocouple on an AIN port. Thermocouples work on the T7 and the T8.

A task streams: the device samples the inputs on its own clock. A T7 task with thermocouple channels polls instead: the Driver reads one sample of each channel at a time, on its own clock. See timing.

A T8 task with thermocouple channels samples at 250 Hz or less. It needs T8 firmware 1.0038 or later and LJM 1.2304 or later.

A LabJack runs one stream at a time and cannot read AIN ports during a stream, so a streaming task must be the only read task on its device. Add more channels to that task instead of starting a second one.

A T7 with a Mux80 adds the analog inputs AIN48 to AIN127. Each connector of the Mux80 holds a group of them: X3 holds AIN48 to AIN71, X4 holds AIN72 to AIN95, X5 holds AIN96 to AIN119, and X2 holds AIN120 to AIN127. In the Port grid of a T7, select the tab of a connector to see its ports.

Create a LabJack read task

  1. In the devices toolbar, right-click the device and select Create read task.
  2. Set Sample rate and Stream rate.
  3. The task starts with one analog input channel. To add more, click Add channel, or select Ports above the channel list and click a free port. See ports.
  4. Select a channel. In Source, select the type of channel, then click a port in the Port grid.
  5. Click (Start).

The Console creates the channels. For a device with the identifier lj1, the channel for AIN0 is lj1_AIN0, with the index channel lj1_time. To use a different name, enter it in the channel list before you start the task.

Tare channels

Tare sets the current value of an analog channel to zero. The task must be running.

  1. In the channel list, click Tare on an analog channel. To tare several channels, select them, right-click, and select Tare.
  2. The values of those channels start from zero.

Task options

Console label Python field Default Notes
Device device The serial number of the device.
Sample rate sample_rate 10 Hz Up to 50,000 Hz in the Console.
Stream rate stream_rate 5 Hz See read tasks.
Data saving data_saving_disabled On See data saving.
Auto start auto_start Off Starts the task each time the Driver starts.

Channel reference

Each channel has a channel, the Synnax channel that records the value. Each table shows the Console label of a setting, with its Python field under it.

Analog input

Python AnalogReadChannelTypeScript analog

Reads a voltage.

Setting Default Notes
Port port AIN0 An AIN port.
Max voltage range 10 The input uses the smallest range of the device that covers this voltage. Not on the T4.
Negative channel neg_chan Ground Absent for ground, or the pair of the port for a differential reading. On the T7 only.
Scale scale None See scale.

Scale

Analog input and thermocouple channels can scale the value before the Driver writes it. In the Console, the options are in the Scale section of the channel. In code, set scale to one of these classes from synnax.labjack:

Console option Python class Fields
None NoneScale No scaling. This is the default.
Linear LinearScale Slope (slope, 1) and Offset (offset, 0).
Map MapScale Pre-scaled min and max to Scaled min and max (pre_scaled_min, pre_scaled_max, scaled_min, scaled_max).
Polynomial PolynomialScale Coefficients (coeffs), from c0 up.
Table TableScale Pre-scaled and Scaled pairs (pre_scaled_vals, scaled_vals). A CSV file can fill them.

Troubleshooting

For other problems, see Configure a LabJack device and Troubleshoot hardware.