Skip to content

PLC ModbusTCP

Deprecated

This block is deprecated. Use the PLC Reader / PLC Writer blocks (set Connection mode to 'Direct - Modbus') instead. Note the outputs differ: instead of a single modbus_results list, the PLC Reader returns tag_values (a tag->value dict) and the PLC Writer returns write_result, each alongside an error_status flag.

Class: ModbusTCPBlockV1

Source: inference.enterprise.workflows.enterprise_blocks.sinks.PLC_modbus.v1.ModbusTCPBlockV1

This Modbus TCP block integrates a Roboflow Workflow with a PLC using Modbus TCP. It can: - Read registers from a PLC if mode='read'. - Write registers to a PLC if mode='write'. - Perform both read and write in a single run if mode='read_and_write'.

Parameters depending on mode: - If mode='read' or mode='read_and_write', registers_to_read must be provided as a list of register addresses. - If mode='write' or mode='read_and_write', registers_to_write must be provided as a dictionary mapping register addresses to values.

If a read or write operation fails, an error message is printed to the terminal, and the corresponding entry in the output dictionary is set to "ReadFailure" or "WriteFailure".

Type identifier

Use the following identifier in step "type" field: roboflow_core/modbus_tcp@v1to add the block as as step in your workflow.

Properties

Name Type Description Refs
name str Enter a unique identifier for this step..
plc_ip str IP address of the target PLC..
plc_port int Port number for Modbus TCP communication..
mode str Mode of operation: 'read', 'write', or 'read_and_write'..
registers_to_read List[int] List of register addresses to read. Applicable if mode='read' or 'read_and_write'..
registers_to_write Dict[str, int] Dictionary mapping register addresses to values to write. Applicable if mode='write' or 'read_and_write'..

The Refs column marks possibility to parametrise the property with dynamic values available in workflow runtime. See Bindings for more info.

Available Connections

Compatible Blocks

Check what blocks you can connect to PLC ModbusTCP in version v1.

Input and Output Bindings

The available connections depend on its binding kinds. Check what binding kinds PLC ModbusTCP in version v1 has.

Bindings
  • input

    • plc_ip (string): IP address of the target PLC..
    • registers_to_read (list_of_values): List of register addresses to read. Applicable if mode='read' or 'read_and_write'..
    • registers_to_write (list_of_values): Dictionary mapping register addresses to values to write. Applicable if mode='write' or 'read_and_write'..
    • depends_on (*): Reference to the step output this block depends on..
  • output

Example JSON definition of step PLC ModbusTCP in version v1
{
    "name": "<your_step_name_here>",
    "type": "roboflow_core/modbus_tcp@v1",
    "plc_ip": "10.0.1.31",
    "plc_port": 502,
    "mode": "read",
    "registers_to_read": [
        1000,
        1001
    ],
    "registers_to_write": {
        "1005": 25
    },
    "depends_on": "$steps.some_previous_step"
}