Master Unit for PLC Network Management

Use ALPON X5 AI and ALPON X4 as a Modbus TCP/RTU master to poll PLCs, sensors, and energy meters — with Modpoll for quick tests and Pymodbus for custom workflows.

ALPON as a Modbus Master for PLC Networks

With support for Modbus TCP and RTU, your ALPON X5 AI or ALPON X4 can act as a reliable master unit for PLC networks — polling data from field devices, writing to their registers, and bridging a local PLC network to any platform. This guide covers Modpoll for quick tests and Pymodbus for custom workflows.

ALPON X5 AI ALPON X4 Modbus TCP · RTU Modpoll · Pymodbus
ALPON · Tutorial · Modbus · PLC
How do I use ALPON as a Modbus master?

Connect your ALPON X5 AI or ALPON X4 to the PLC network over Ethernet or serial. For a quick test, install Modpoll and run a single modpoll -m tcp command against the device IP. For production, use the Pymodbus Python library to build a custom master that reads holding registers and writes values on a schedule. Both approaches speak Modbus TCP and RTU, and run identically on ALPON X5 AI and ALPON X4.

Avoid overlapping subnets

Make sure your Modbus devices sit on the same subnet as the ALPON — or can reach it over TCP/IP — and that their addresses do not collide with the Sixfab platform's default subnets (100.0.0.0/16 and 10.42.0.0/24). An overlap can make either the Modbus devices or the platform services unreachable.

Overview

Acting as a Modbus master unit, an ALPON X5 AI or ALPON X4 can:

  • Poll data from one or more Modbus-compatible devices such as PLCs, sensors, or energy meters.
  • Control actuators and other devices by writing to their registers.
  • Bridge a local PLC network to any platform.

The sections below show two approaches: Modpoll, a lightweight command-line client for testing and polling, and Pymodbus, a Python library for building custom master applications. The procedure is identical on ALPON X4 and ALPON X5 AI.

Prerequisites

Hardware One or more Modbus-compatible devices (PLCs, sensors, energy meters), connected to the ALPON over Ethernet or serial.
Operating system ALPON X5 AI or ALPON X4 running the latest OS. Check for updates via Sixfab Connect.
Tools Modpoll (method 1) or Pymodbus (method 2).

Method 1 · Modpoll for basic master functionality

Modpoll is a straightforward command-line tool for testing and polling Modbus-compatible devices.

  1. 1

    Install Modpoll

    Download and extract Modpoll on the ALPON:

    bash · install modpoll
    wget https://www.modbusdriver.com/downloads/modpoll.tgz
    tar xzf modpoll.tgz
    cd modpoll/arm-linux-gnueabihf/
  2. 2

    Run Modpoll

    Read data from a PLC device:

    bash · poll a device
    ./modpoll -m tcp -a 1 -r 100 -c 10 -t 4:float <DEVICE_IP>

    Parameter reference

    -m tcp Uses Modbus TCP mode.
    -a 1 Sets the slave address to 1.
    -r 100 Starts reading from register 100.
    -c 10 Reads 10 consecutive registers.
    -t 4:float Interprets the data as floating-point values.
  3. 3

    Verify communication

    Confirm that the data returned from the device is accurate and matches the expected values.

Method 2 · Advanced configuration with Pymodbus

For advanced use cases, Pymodbus — a Python library — lets you build custom Modbus master applications.

  1. 1

    Install dependencies

    Create a virtual environment and install Pymodbus:

    bash · virtualenv + pymodbus
    python3 -m venv venv
    source venv/bin/activate
    pip3 install pymodbus
  2. 2

    Write a master application

    Save the following as modbus_master.py:

    python · modbus_master.py
    from pymodbus.client.sync import ModbusTcpClient
    
    # Configure Modbus TCP client
    
    client = ModbusTcpClient('<DEVICE_IP>', port=502)
    
    # Connect to the device
    if client.connect():
        # Read 10 holding registers starting from address 100
        response = client.read_holding_registers(100, 10, unit=1)
        if not response.isError():
            print("Data:", response.registers)
        else:
            print("Error:", response)
    
        # Write a value to register 200
        client.write_register(200, 42, unit=1)
        print("Value written successfully.")
    
        client.close()
    else:
        print("Connection failed.")
  3. 3

    Run the script

    bash · run
    python3 modbus_master.py
    Why Pymodbus for production
    • Flexible, customizable workflows.
    • Supports both Modbus TCP and RTU.
    • Easy integration with databases and cloud platforms for advanced analytics.

Best practices

Network configuration

  • Use a reliable Ethernet connection for Modbus TCP.
  • Keep Modbus devices on the same subnet as the ALPON, or reachable over TCP/IP.
  • Avoid overlapping the Sixfab default subnets (100.0.0.0/16 and 10.42.0.0/24) with your Modbus devices.

Security

  • Use a firewall to restrict access to critical ports (e.g. 502 for Modbus TCP).
  • Keep the ALPON updated with the latest patches.

Containerized deployment

  • Deploy Modbus master applications in isolated containers using the ALPON's container environment.

Troubleshooting

Error No response from devices

Fix

Verify the IP address, port, and slave ID, and check the cable connections between the ALPON and the Modbus device.

Error Data mismatch

Fix

Ensure the register type and starting address match the device's register map.

Debug Inspecting logs for error analysis

Fix

Follow the system log in real time to watch for connection and protocol errors:

bash · follow logs
tail -f /var/log/syslog