Simple Modbus Lua Script

Issue

Simple Modbus Lua Script

Product Line

SmartStruxure Lite

Environment

Lua Programming

Cause

Simple script to test modbus function

Resolution

The following samples provide simple read / write functions:

In each of the samples, the following needs to be observed:

1. The modbus port is closed and opened with the port settings. The samples can be combined but the port is only set once. The settings for the modbus RS485 port requires an address, in this instance 99 is used. This must be different from the slaves.

2. The nnn.MOD1 must be left unchecked so that it is not enabled, this will allow the LUA script modbus to work.

For added functionality the "Print" command is used.

The "print" command provides added functionality indicating a successful read / write in the output window. If the result = 0 then the read / write is successful anything else is an error code, please contact Product Support. The value = is the value that is either read in or written dependant on the function used.

Coil Registers

Digital Input Registers

Holding Registers

Input Registers

32bit Floating Point