NI Digital Write Task

Learn how to create a digital write task for NI hardware.

The Digital Write Task is used for sending commands to the digital outputs of your NI cards. In this guide, we’ll walk you through the steps to create a Digital Write Task in Synnax.

Prerequisites

Before configuring the task, you’ll need to have connected and configured an NI 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 NI Driver, a digital write task defines a background process that writes to the digital outputs of your device based on values written to Synnax command channels.

A digital write task can be started, stopped, and re-configured at any time. We permanently store the configuration of the task in Synnax, 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 the console 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 digital 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 Digital write Task”.

From the Command Palette

To create a digital write task from the command palette, open the Synnax Console and click on the Quick Search & 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 moe (enabled when the first character in the input is ”>”), type “NI”. You’ll see an option called “Create a New Digital write Task”. Select this option to open the read task configuration dialog.

From The Layout Selector

To create a digital write task from the layout selector, click on the ”+” button in the top right corner and select “NI Digital write Task”.

Configure the Task

Step 1 Select your NI Device

The first step is to select the NI 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 ”+” button in the channels section. Then, click on the new channel in the list to configure it.

You’ll need to select both a digital output port and line 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.