NI Analog Write Task
Learn how to create an analog write task for NI hardware.
An analog write task is used for sending commands to the analog outputs of your NI cards. In this guide, we’ll walk you through the steps to create an analog write task using the Synnax Console.
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, an analog wirte task defines a background process that writes to the analog outputs of your device based on values written to Synnax command channels.
An analog 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 an analog output. To set an analog output to a specific value, you would write the desired value to the command channel.
A command channel for an analog output might be my_temp_card_ao_0_1_cmd
, where
my_temp_card
is the device identifier, ao_0_1
is the port and line of the analog
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_ao_0_1_cmd
, the index channel would be
my_temp_card_ao_0_1_cmd_time
.
State channels represent the current state of the analog output. When you send a command, the corresponding analog 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 setpoint in the schematic
to write to an analog output, you would set the command
field to the command channel
of the analog output. Setting the setpoint would send a command to the analog output.
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 an analog 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 Analog Write Task”.
From the Command Palette
To create an analog 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 and Cmd+Shift+P
on macOS.
In command mode (enabled when the first character in the input is ”>”), type “NI”. You’ll see an option called “Create a New Analog Write Task”. Select this option to open the write task configuration dialog.
From The Layout Selector
To create an analog write task from the layout selector, click on the ”+” button in the top right corner and select “NI Analog 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. Once you have a channel, you can select the channel type, scaling, and other details in the form on the right.
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.