Issue
Modbus device in hand does not have a pre-configured widget in the device list of Building Expert. A script is required to communicate with the device
Product Line
EcoStruxure Building Expert
Environment
- SmartStruxure Lite Multi-Purpose Manager
- Any modbus device
Cause
Pre-configured widget not available in the device list of Building Expert
Resolution
The MPM can only be a Modbus Master; meaning it can request information from other slave modbus devices, or write to them.
Terminals A and B on the MPM correspond to modbus terminals (Serial +) and (Serial -) respectively.
When using a script to communicate with modbus devices, the "Enable" box in the ModBus configuration object (MOD1) must be disabled to allow the MPM to communicate with the devices using a script.
The modbus port should then be closed (in case it was left open) and re-opened using the following functions
********************************************************
@@@ Lua.modbus.close (Description and example here)
********************************************************
@@@ Lua.modbus.open (Description and example here)
********************************************************
The following are the standard modbus functions and their corresponding Lua functions used in the MPM
Modbus Function Code | Lua Function in MPM |
Function Code 01 | modbus.coil_read |
Function Code 02 | modbus.di_read |
Function Code 03 | modbus.hr_read (16-bit) |
Function Code 04 | modbus.in_read |
Function Code 05 | N/A |
Function Code 15 | modbus.coil_write |
Function Code 06 | modbus.hr_write |
The following are the 8 different modbus functions that can be used to read/write to registers from/to modbus devices
********************************************************
@@@ Lua.modbus.coil_read (Description and example here)
This function is equivalent to : [Function Code 01 (01 HEX)]
********************************************************
@@@ Lua.modbus.coil_write (Description and example here)
This function is equivalent to : [Function Code 15 (0F HEX)]
********************************************************
@@@ Lua.modbus.di_read (Description and example here)
This function is equivalent to : [Function Code 02 (02 HEX)]
********************************************************
@@@ Lua.modbus.hr_read (Description and example here)
This function is equivalent to : [Function Code 03 (03 HEX)]
********************************************************
@@@ Lua.modbus.hr_write (Description and example here)
This function is equivalent to : [Function Code 06 (06 HEX)]
********************************************************
@@@ Lua.modbus.in_read (Description and example here)
This function is equivalent to : [Function Code 04 (04 HEX)]
********************************************************
@@@ Lua.modbus.fp_read (Description and example here)
********************************************************
@@@ Lua.modbus.fp_write (Description and example here)
********************************************************
To read a floating-point (32-bit) value, the fp_read() function can be used. (Download script)
To read an unsigned long (32-bit) value the hr_read() function can be used, however, some data manipulation is required (Download script)
To read a floating-point (64-bit) value, the hr_read() function can be used. (Download script)
Modbus errors can be found here