ReferenceDriverModbusRead Task

Modbus Read Task

Read data from Modbus servers with read tasks.

Read tasks are the primary method for acquiring data from a Modbus server and storing it in Synnax.

Prerequisites

Before configuring the task, you’ll need to have connected to a Modbus server.

A Short Primer on Tasks

Tasks are the primary method for communicating with devices in Synnax. Tasks can be used for both control and data acquisition purposes. In the context of Modbus, a read task defines a background process that reads data from your server at a specified sampling rate.

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

Important Rules for Read Tasks

Sample Rates and Timing

All channels in a read task are sampled at the same rate. If you’d like to sample different channels at different rates, create a separate task to do so.

Synnax uses software timing to read from your Modbus server, and typically delivers precision on the order of 100 μs. Under heavy load, this timing precision may degrade.

For low rate (<50 Hz) tasks, we recommend setting the stream rate to the same value as the sample rate. For higher rate tasks, lowering the stream rate can significantly improve performance.

One Running Task per Channel

Synnax can only accept live data from a channel from one source at a time. If you have a task running that reads from a pressure channel, you cannot create another task that also reads from pressure.

Open the Task Configuration Dialog

To configure a read task, open the Synnax Console and click on the Search and Command Palette at the top. You can also open this palette with Ctrl+Shift+P on Windows or Cmd+Shift+P on macOS.

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

You can also open the dialog by clicking in the top-right corner of the window and selecting the add icon (), or opening the context menu on a Modbus server from the Devices Toolbar.

Task Configuration Parameters

FieldDescription
NameA name for your read task.
Modbus ServerWhich Modbus server the task will read from.
Auto Start Start task data acquisition immediately on configuration.
Sample RateHow often, in Hz, Synnax polls data from the Modbus server.
Stream RateHow often, in Hz, Synnax streams data to the Synnax database. For example, if the sample rate is 10 Hz and the stream rate is 1 Hz, Synnax will collect 10 samples before forwarding them to the database.

Sample Rate vs. Stream Rate

There are two parameters to control the timing of the task: the sample rate and the stream rate. The sample rate defines how often Synnax will poll the Modbus server for new data, while the stream rate defines how often the task will stream data into Synnax.

For example, if you set the sample rate to 10 Hz and the stream rate to 1 Hz, Synnax will poll the Modbus server every 100 ms, collect 10 samples, and then forward these samples to the server.

For very low rate tasks (<50 Hz), we recommend setting the stream rate to the same value as the sample rate. For higher rate tasks, lowering the stream rate can significantly improve performance. It’s best to keep the stream rate below 50 Hz unless you need to quickly process incoming data in real-time.

Modbus Register Types

Modbus supports four types of data storage areas, each with a specific purpose:

Register TypeDescriptionAccessData Width
Coil

Discrete outputs that can be read and written. Used for binary control signals.

Read/Write1 bit (boolean)
Discrete InputDiscrete Inputs that can only be read. Used for binary sensor inputs.Read Only1 bit (boolean)
Holding Register

Analog outputs that can be read and written. Used for control values like setpoints.

Read/Write16 bits (configurable data type)
Input Register

Analog inputs that can only be read. Used for sensor values like temperatures or pressures.

Read Only16 bits (configurable data type)

For read tasks, you can read from all four register types:

  • Coil Input - Read binary outputs from coils
  • Discrete Input - Read binary inputs
  • Holding Register Input - Read analog output values
  • Input Register - Read analog input values

Data Types for Registers

For Holding Registers and Input Registers, you can specify the data type for each channel. Synnax supports the following data types:

Data TypeDescriptionSize
int1616-bit signed integer1 register (2 bytes)
uint1616-bit unsigned integer1 register (2 bytes)
int3232-bit signed integer2 registers (4 bytes)
uint3232-bit unsigned integer2 registers (4 bytes)
float3232-bit IEEE 754 floating point2 registers (4 bytes)

Coils and Discrete Inputs are always boolean values and do not require a data type specification.

For multi-register data types (int32, uint32, float32), make sure the byte and word ordering matches your server’s configuration. Use the “Swap Bytes” and “Swap Words” settings in the device connection configuration if needed.

Adding Channels to a Task

To add a channel to a task, click the “Add Channel” button in the task configuration dialog. For each channel, you’ll need to specify:

  1. Register Type - Select from Coil Input, Discrete Input, Holding Register Input, or Input Register
  2. Address - The Modbus register address (e.g., 0, 100, 40001)
  3. Data Type - For register types, select the data type (int16, uint16, int32, uint32, float32)
  4. Channel Name - A descriptive name for the channel

You can enable or disable individual channels using the toggle button to the right of each channel. This is useful for temporarily stopping data acquisition from specific channels without removing them from the task.

Configuring the Task

Once you’ve added all your channels and configured the task parameters, click the “Configure” button to save the task configuration. This will create Synnax channels for each of your Modbus channels and prepare the task for execution.

After configuration, you can start and stop the task at any time. The task configuration is permanently stored, so you can easily resume data acquisition later.

Stopping and Starting Tasks

To stop and start a task, you can open up the Tasks Toolbar on the left-hand side and click play and pause. You can also click the play/pause icon in the bottom of the task configuration window.