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:

Sample IndexTime (s)Notes
00.000First sample of first read
10.010
20.020
30.030
40.040
50.050
60.060
70.070
80.080
90.090Last sample of first read
100.100First sample of second read
190.190Last sample of second read
200.200First 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