LabJack Write Task

Learn how to create a write task for Labjack hardware.

A write task is used for sending commands to your digital outputs and writing analog signals out from your LabJack. In this guide, we’ll walk you through the steps to create a write task in Synnax.

Prerequisites

Before configuring the task, you’ll need to have connected and configured a LabJack device and created the relevant channels in Synnax. Check out the Configure Device guide for more information.

A Short Primer on Tasks

Tasks are the primary method for communicating with hardware devices in Synnax. Tasks can be used for both control and data acquisition purposes. In the context of the LabJack driver, a write task defines a background process that writes data to the analog or digital outputs on a particular LabJack device.

A write task can be started, stopped, and re-configured at any time. Synnax permanently stores the configuration of each task, so it’s easy to set up multiple tasks for different purposes.

How Commands Work in Synnax

Commands in Synnax require two types of channels: a command channel and state channel. Command channels signal a task to set the value of a digital output. To set a digital output to high, you would write a 1 to the command channel. To set it to low, you would write a 0.

A command channel for a digital output might be my_temp_card_do_0_1_cmd, where my_temp_card is the device identifier, do_0_1 is the port and line of the digital output, and _cmd indicates that it’s a command channel.

Command channels also have an associated index channel that stores the timestamps at which commands were sent. This channel is suffixed with _cmd_time. For the command channel my_temp_card_do_0_1_cmd, the index channel would be my_temp_card_do_0_1_cmd_time.

State channels represent the current state of the digital output. When you send a command, the corresponding digital write task will process the command and update the value in the state channel.

State channels are typically suffixed with _state. A state channel maintains the same format as its corresponding command channel, but suffixed with _state instead of _cmd.

As an example, to configure a valve in a schematic to write to a digital output, you would set the command field to the command channel of the digital output and the state field to the state channel of the digital output. Clicking the valve would send a command to the digital output, and the valve would turn solid or transparent based on the state channel.

Using two channels provides a guarantee that a particular command was acknowledged by a running task.

Open the Task Configuration Dialog

From the Resources Toolbar

To create a write task from the resources toolbar, open the Synnax Console and click on the resources () toolbar in the left sidebar. Find the device you’d like to create the task for, right-click on it, and select “Create Write Task”.

From the Command Palette

To create a write task from the command palette, open the Synnax Console and click on the Command Palette at the top. You can also open this palette with Ctrl+Shift+P on Windows/Linux and Cmd+Shift+P on macOS.

In command mode (enabled when the first character in the input is “>”), type “LabJack”. You’ll see an option called “Create a LabJack Write Task”. Select this option to open the read task configuration dialog.

From The Layout Selector

To create a write task from the layout selector, click on the Add () button in the top right corner and select “LabJack Write Task”.

Configure the Task

Step 1 Select your LabJack Device

The first step is to select the Labjack device you’d like to write to the outputs of. Use the dropdown menu in the top left corner to do so.

Step 2 Add Channels to the Task

Next, you’ll need to add the channels you’d like to write to. Click the Add () button in the channels section. Then, click on the new channel in the list to configure it.

You’ll need to select an output port to write to. You’ll also need to select the command channel the task will listen to, and the state channel that will be updated when the command is processed.

Step 3 Configure the State Update Rate

The state update rate determines how often the state channels in the task are updated. Set the rate higher in scenarios that require quick response times.

Start the Task

Once you’ve added all of the channels you need and have configured sampling rates, hit the “Configure” button. If there are no errors, Synnax will acknowledge the configured task and enable the Play () button in the dialog. Click this button to start the task.

Starting and stopping a task does not re-apply the task configuration. If you’ve made changes to the configuration, you’ll need to re-configure the task by hitting the “Configure” button.