ReferenceDriverTask Basics

Task Basics

Learn the fundamentals of working with tasks in Synnax.

Prerequisites

Before creating any tasks, you’ll need to have connected and configured a hardware device:

What Are Tasks?

Tasks are the primary method for communicating with hardware devices in Synnax. Tasks can be used for both control and data acquisition purposes. A task defines a background process that either reads data from or writes data to your hardware.

Tasks 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 and switch between them as needed.

Creating a Task

Task Lifecycle

The task form saves every edit. Click play () to send the configuration to the Driver and start the task. Click stop () to stop it.

Edits made while a task is running are saved but not applied. Click Redeploy to apply them.

Read Tasks

A read task samples hardware inputs and streams the values into Synnax channels. Every channel in a task shares one sample rate, and a channel can be fed by only one running task at a time.

For tasks under 50 Hz, set the stream rate equal to the sample rate. For faster tasks, keep the stream rate under 50 Hz. See Timing for how samples are timestamped.

Write Tasks

A write task listens on command channels (_cmd) and writes each value to the hardware. Outputs that report back also get a state channel (_state), refreshed at the task’s state rate. Only one running task can listen on a given command channel.

Modbus, OPC UA, and HTTP write tasks have no state channels. Configure a read task on the same target to read the state back.

Timing

Hardware Timed Tasks

Where the acquisition module has a sample clock, the Driver uses it and interpolates the time between samples. NI analog read tasks, NI digital read tasks with a timing source, and LabJack read tasks without thermocouple channels are hardware timed. A task sampling at 100 Hz and streaming at 10 Hz acquires 10 samples per read:

Table

Sample Index Time (s) Notes
0 0.000 First sample of first read
1 0.010
2 0.020
3 0.030
4 0.040
5 0.050
6 0.060
7 0.070
8 0.080
9 0.090 Last sample of first read
10 0.100 First sample of second read
19 0.190 Last sample of second read
20 0.200 First sample of third read

Clock drift accumulates over time. On a non-real-time operating system acquisition loops run early or late, the hardware clock and the configured rate differ slightly, and transports skip samples under load. A skew correction algorithm periodically adjusts the spacing between samples so timestamps stay aligned with the host system clock and with software timed tasks on the same Driver. Valve commands from a digital write task, for example, stay lined up with the analog samples they caused.

Skew correction is on by default. Disable it with timing.correct_skew: false in the Driver configuration file, --correct-skew=false on the command line, or SYNNAX_DRIVER_CORRECT_SKEW=false in the environment.

Software Timed Tasks

Without a hardware clock, the Driver timestamps samples when it receives them, which is less accurate. NI digital read tasks without a timing source, NI counter read tasks, LabJack read tasks with thermocouple channels, Modbus read tasks, HTTP read tasks, and all write tasks are software timed.

How-To