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
AINport. - Digital input -> the state of a
DIOport, as 0 or 1. - Thermocouple -> a temperature from a thermocouple on an
AINport. 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
Console
Python
TypeScript
- In the devices toolbar, right-click the device and select Create read task.
- Set Sample rate and Stream rate.
- 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.
- Select a channel. In Source, select the type of channel, then click a port in the Port grid.
- 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.
Python does not create channels. Create them first.
import synnax as sy
from synnax import labjack
dev = client.devices.retrieve(key="<serial number>")
time = client.channels.create(
name="lj1_time", is_index=True, data_type=sy.DataType.TIMESTAMP
)
pressure = client.channels.create(
name="lj1_AIN0", index=time.key, data_type=sy.DataType.FLOAT32
)
switch = client.channels.create(
name="lj1_DIO4", index=time.key, data_type=sy.DataType.UINT8
)
task = labjack.ReadTask(
name="Test stand inputs",
device=dev.key,
sample_rate=1000,
stream_rate=25,
channels=[
labjack.AnalogReadChannel(port="AIN0", channel=pressure.key),
labjack.DigitalReadChannel(port="DIO4", channel=switch.key),
],
)
client.tasks.configure(task)
task.start()For a thermocouple on a T7 or a T8, use
labjack.ThermocoupleReadChannel(port="AIN2", thermocouple_type="K", units="C", channel=...).
TypeScript does not create channels. Create them first.
import { labjack } from "@synnaxlabs/client";
const dev = await client.devices.retrieve({ key: "<serial number>" });
const time = await client.channels.create({
name: "lj1_time",
isIndex: true,
dataType: "timestamp",
});
const pressure = await client.channels.create({
name: "lj1_AIN0",
index: time.key,
dataType: "float32",
});
const task = await client.tasks.create({
name: "Test stand inputs",
rack: dev.rack,
type: "labjack_read",
config: labjack.readConfigZ.parse({
device: dev.key,
sampleRate: 1000,
streamRate: 25,
channels: [{ type: "analog", port: "AIN0", channel: pressure.key }],
}),
});
await task.start();Tare channels
Tare sets the current value of an analog channel to zero. The task must be running.
- In the channel list, click Tare on an analog channel. To tare several channels, select them, right-click, and select Tare.
- The values of those channels start from zero.
Task options
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.
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:
Troubleshooting
- Cause
The Driver cannot send the samples as fast as the device makes them.
- Fix
Lower the Stream rate, or lower the Sample rate.
- Cause
The buffer of the device filled, so the device skipped samples. The Driver writes no value for a skipped sample.
- Fix
Lower the Sample rate, or check the USB cable or the network.
- Cause
The voltage of the thermocouple is outside the range of its Thermocouple type. The thermocouple is open, a wire is loose, or the type is wrong. The Driver writes NaN until the voltage is in range.
- Fix
Check the wires of the thermocouple and its Thermocouple type.
- Cause
Above 250 Hz, the T8 cannot read the temperature at its terminals, which the Driver needs to convert thermocouples.
- Fix
Set the Sample rate to 250 Hz or less.
- Cause
The firmware of the T8 cannot stream the temperature at its terminals.
- Fix
Update the firmware of the T8 with Kipling.
- Cause
The LJM library on the computer that runs the Driver cannot stream the temperature at the terminals of a T8.
- Fix
Install the latest LJM, then restart the Driver.
- Cause
The calibration constants of the device are not valid. LJM uses default constants, so readings may be inaccurate. The task continues to record data.
- Fix
Contact LabJack support.
- Cause
The T4 has no thermocouple inputs.
- Fix
Use a T7 or a T8 for thermocouple channels.
- Cause
The CJC source of a thermocouple is the port of another thermocouple channel. A thermocouple port has no CJC sensor.
- Fix
Set CJC source to Device, or to the
AINport of a CJC sensor.
- Cause
The Max voltage of the channel is larger than the largest input range of the device: ±10 V on a T7, and ±11 V on a T8.
- Fix
Lower the Max voltage of the channel.
- A T7 task fails to start after a change to Max voltage.
- Cause
On a T7, a small range takes longer to settle. A task with more than one channel and a Max voltage of 1 V or less can then not stream at its Sample rate.
- Fix
Lower the Sample rate, or set Max voltage back to 10. See LabJack’s stream rates.
- Cause
Two enabled channels use the same port.
- Fix
Select a different port for one of the channels, or disable one of them.
- Cause
Another read task streams from the same device. A LabJack runs one stream at a time.
- Fix
Add the channels of this task to the running task, then delete this task.
For other problems, see Configure a LabJack device and Troubleshoot hardware.