WolkWriter
Published © GPL3+

Connecting Modbus TCP/IP Slave to the Cloud

Visualise and control Modbus TCP/IP slave (server) device from the Cloud using WolkAbout IoT Platform

IntermediateFull instructions provided45 minutes294
Connecting Modbus TCP/IP Slave to the Cloud

Things used in this project

Hardware components

Raspberry Pi 3 Model B+
Raspberry Pi 3 Model B+
×1
Ethernet Cable, Cat5e
Ethernet Cable, Cat5e
×1
Compulab fitlet2
×1
IEI DM-F08A
×1
AC/DC Power Supply - MEAN WELL NDR-75-12
×1
DC/DC Power Supply - DDR-15G-5
×1
USB 2.0 Male to USB Male
×1
HDMI to DVI-D cable
×1
Custom made Cables for Power Supply
×1

Software apps and online services

WolkAbout IoT Platform
WolkAbout IoT Platform

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver

Story

Read more

Code

modbusRegisterMapping.json

JSON
Mapping of Modbus registers that fits the Offset printing simulator covered here: https://github.com/Wolkabout/offset-printing-machine-simulator-application
{
   "modbusRegisterMapping":[
      {
         "name": "Machine Status",
         "reference": "STAT",
         "address": 0,
         "registerType": "INPUT_CONTACT",
         "dataType": "BOOL",
         "slaveAddress": 1
      },
      {
         "name": "Emergency Stop Alarm",
         "reference": "ESTOPA",
         "address": 24,
         "registerType": "INPUT_CONTACT",
         "dataType": "INT16",
         "slaveAddress": 1,
         "mappingType": "ALARM"
      },
      {
         "name": "Paper Jam Alarm",
         "reference": "PJAM",
         "address": 25,
         "registerType": "INPUT_CONTACT",
         "dataType": "INT16",
         "slaveAddress": 1,
         "mappingType": "ALARM"
      },
      {
         "name": "Default Values",
         "reference": "DV",
         "description": "These are default values for Feeder, Tempo, Delivery",
         "minimum": 0,
         "maximum": 17000,
         "labelMap": {
            "Feeder": 22,
            "Tempo": 23,
            "Delivery": 24
         },
         "registerType": "HOLDING_REGISTER_ACTUATOR",
         "dataType": "INT16",
         "slaveAddress": 1,
         "mappingType": "CONFIGURATION"
      },
      {
         "name": "Cyan Default Value",
         "reference": "DVC",
         "description": "Default Value for Cyan color",
         "minimum": 0,
         "maximum": 10000,
         "address": 25,
         "registerType": "HOLDING_REGISTER_ACTUATOR",
         "dataType": "INT16",
         "slaveAddress": 1,
         "mappingType": "CONFIGURATION"
      },
      {
         "name": "Magenta Default Value",
         "reference": "DVM",
         "description": "Default Value for Magenta color",
         "minimum": 0,
         "maximum": 10000,
         "address": 26,
         "registerType": "HOLDING_REGISTER_ACTUATOR",
         "dataType": "INT16",
         "slaveAddress": 1,
         "mappingType": "CONFIGURATION"
      },
      {
         "name": "Yellow Default Value",
         "reference": "DVY",
         "description": "Default Value for Yellow color",
         "minimum": 0,
         "maximum": 10000,
         "address": 27,
         "registerType": "HOLDING_REGISTER_ACTUATOR",
         "dataType": "INT16",
         "slaveAddress": 1,
         "mappingType": "CONFIGURATION"
      },
      {
         "name": "Black Default Value",
         "reference": "DVB",
         "description": "Default Value for Cyan color",
         "minimum": 0,
         "maximum": 10000,
         "address": 28,
         "registerType": "HOLDING_REGISTER_ACTUATOR",
         "dataType": "INT16",
         "slaveAddress": 1,
         "mappingType": "CONFIGURATION"
      },
      {
         "name": "Machine Running",
         "reference": "RUN",
         "address": 0,
         "registerType": "COIL",
         "dataType": "BOOL",
         "slaveAddress": 1
      },
      {
         "name": "Conveyor Max Prints Per Hour",
         "reference": "MAXPPH",
         "minimum": 0,
         "maximum": 20000,
         "address": 1,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Conveyor Min Prints Per Hour",
         "reference": "MINPPH",
         "minimum": 0,
         "maximum": 20000,
         "address": 2,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Conveyor Current Prints Per Hour",
         "reference": "CPPH",
         "minimum": 0,
         "maximum": 20000,
         "address": 3,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Conveyor Prints Per Hour",
         "reference": "PPH",
         "minimum": 0,
         "maximum": 20000,
         "address": 3,
         "registerType": "HOLDING_REGISTER_ACTUATOR",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Feeder Capacity",
         "reference": "FCAP",
         "minimum": 0,
         "maximum": 20000,
         "address": 4,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Feeder Percentage Full",
         "reference": "FPER",
         "minimum": 0,
         "maximum": 20000,
         "address": 5,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Feeder Current Count",
         "reference": "FCC",
         "minimum": 0,
         "maximum": 20000,
         "address": 6,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Feeder Count",
         "reference": "FC",
         "minimum": 0,
         "maximum": 20000,
         "address": 6,
         "registerType": "HOLDING_REGISTER_ACTUATOR",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Delivery Capacity",
         "reference": "DCAP",
         "minimum": 0,
         "maximum": 20000,
         "address": 7,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Delivery Percentage Full",
         "reference": "DPER",
         "minimum": 0,
         "maximum": 20000,
         "address": 8,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Delivery Current Count",
         "reference": "DCC",
         "minimum": 0,
         "maximum": 20000,
         "address": 9,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Delivery Count",
         "reference": "DC",
         "minimum": 0,
         "maximum": 20000,
         "address": 9,
         "registerType": "HOLDING_REGISTER_ACTUATOR",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Cyan Capacity",
         "reference": "PSCCAP",
         "minimum": 0,
         "maximum": 20000,
         "address": 10,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Cyan Percentage Full",
         "reference": "PSCPER",
         "minimum": 0,
         "maximum": 20000,
         "address": 11,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Cyan Current Count",
         "reference": "PSCCC",
         "minimum": 0,
         "maximum": 20000,
         "address": 12,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Cyan Count",
         "reference": "PSCC",
         "minimum": 0,
         "maximum": 20000,
         "address": 12,
         "registerType": "HOLDING_REGISTER_ACTUATOR",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Magenta Capacity",
         "reference": "PSMCAP",
         "minimum": 0,
         "maximum": 20000,
         "address": 13,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Magenta Percentage Full",
         "reference": "PSMPER",
         "minimum": 0,
         "maximum": 20000,
         "address": 14,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Magenta Current Count",
         "reference": "PSMCC",
         "minimum": 0,
         "maximum": 20000,
         "address": 15,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Magenta Count",
         "reference": "PSMC",
         "minimum": 0,
         "maximum": 20000,
         "address": 15,
         "registerType": "HOLDING_REGISTER_ACTUATOR",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Yellow Capacity",
         "reference": "PSYCAP",
         "minimum": 0,
         "maximum": 20000,
         "address": 16,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Yellow Percentage Full",
         "reference": "PSYPER",
         "minimum": 0,
         "maximum": 20000,
         "address": 17,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Yellow Current Count",
         "reference": "PSYCC",
         "minimum": 0,
         "maximum": 20000,
         "address": 18,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Yellow Count",
         "reference": "PSYC",
         "minimum": 0,
         "maximum": 20000,
         "address": 18,
         "registerType": "HOLDING_REGISTER_ACTUATOR",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Black Capacity",
         "reference": "PSKCAP",
         "minimum": 0,
         "maximum": 20000,
         "address": 19,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Black Percentage Full",
         "reference": "PSKPER",
         "minimum": 0,
         "maximum": 20000,
         "address": 20,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Black Current Count",
         "reference": "PSKCC",
         "minimum": 0,
         "maximum": 20000,
         "address": 21,
         "registerType": "INPUT_REGISTER",
         "dataType": "INT16",
         "slaveAddress": 1
      },
      {
         "name": "Paint Station Black Count",
         "reference": "PSKC",
         "minimum": 0,
         "maximum": 20000,
         "address": 21,
         "registerType": "HOLDING_REGISTER_ACTUATOR",
         "dataType": "INT16",
         "slaveAddress": 1
      }
   ]
}

modbus_module.service

Plain text
Service file used to run WolkGatewayModule-Modbus on system boot. Edit with your username and adjust path if needed.
[Unit]
 Description=WolkAbout Gateway Module for Modbus devices
 After=multi-user.target

[Service]
 Type=idle
 WorkingDirectory=/home/<USER_NAME>/WolkGatewayModule-Modbus/out/
 ExecStart=/home/<USER_NAME>/WolkGatewayModule-Modbus/out/modbusModule deviceConfiguration.json modbusConfiguration.json modbusRegisterMapping.json
 Restart=always

[Install]
 WantedBy=multi-user.target

wolk_gateway.service

Plain text
Service to run WolkGateway at system boot. Edit the username and adjust path if needed.
[Unit]
 Description=Gateway for connecting non-IP enabled devices to WolkAbout IoT Platform
 After=multi-user.target

[Service]
 Type=idle
 WorkingDirectory=/home/<USER_NAME>/WolkGateway/out/
 ExecStart=/home/<USER_NAME>/WolkGateway/out/WolkGatewayApp gatewayConfiguration.json
 Restart=always

[Install]
 WantedBy=multi-user.target

WolkGateway

WolkGatewayModule-Modbus

Offset printing machine simulator - Modbus TCP/IP slave

Used to represent a real-world working machine that exposes its data through Modbus registers.

Credits

WolkWriter

WolkWriter

17 projects • 24 followers
With WolkAbout IoT Platform, we give you proven technology to develop powerful IoT applications and control your business ecosystem.

Comments