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 only.
With no thermocouple channels, the device samples the inputs on its own clock. With one or more thermocouple channels, the Driver reads one sample of each channel at a time, and the Stream rate has no effect. See timing.
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.
- Click Add channel, then select the type of channel and the Port.
- 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()Python creates the task on the embedded Driver of the Core. For a device on another Driver, use the Console or TypeScript.
For a thermocouple on a T7, 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.
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.
- Thermocouple values are wrong.
- Cause
The device is not a T7. The Driver sets up thermocouples on the T7 only.
- Fix
Use a T7 for thermocouple channels.
- Cause
Two channels use the same port.
- Fix
Select a different port for one of them.
For other problems, see Configure a LabJack device and Troubleshoot hardware.