BACRouter has a powerful Modbus master module, but there are still some scenarios that it can not handle well, for examples:
- Point’s value is read from register 3×00001, but has to write to register 4×00001.
- Value 1 read from Modbus mapping to BACnet 1.0, but writing BACnet value 1.0 to Modbus has to write 10. (Lua script for Modbus master module can do asymmetrical conversion for customized Analog object)
- Analog/Multistate object mapping to several Modbus coils or discrete inputs.
- Write only Modbus data address, read from it will report timeout or exception.
Fortunately, we have free client module which can implement a most versatile Modbus gateway by Lua script. We host the modbus.lua scripts on github.com
For modbus.lua, all devices under a bus share same baudrate/parity/timeout property. For Modbus master module, each device under a bus has independent timing property.
User should try Modbus master module at first, because of the test feature of Modbus master module, user can rapidly verify the mapping setting.
After all normal points have been setup, there may leave some weird points, you should test read for those points.
Then the “Read Group” will verify the grouping.
Then you should export the device’s setting.
There is a fcmbconv.py python program on github repository, install python and run it, it will promote you to choose modbus.lua, then the device config file you had exported, then it will create a free client bus config file for the device.
Then import the created config into BACRouter under “Free Client Module”.
At last you have to modify the special settings for those weird points.
Example:
We assume there is a device, has several normal points, and
1. Analog output objects “lamp1” and “lamp2” get on/off status from bit 0 and bit 1 of Register 4×00032, value 1 on the corresponding bit means on, value 0 means off. To turn on/off of lamps, register 4×00031 should be written, but the value 1 on the corresponding bit means turning off, value 0 means turning on.
2. 8 bits from 1×00008 map to analog input object “temperature3”.
3. Write-only register 4×00100(Read will report timeout), low byte maps analog output object “load1”, high byte maps to analog output object “load2”.
Setup a Modbus device: ExampleModbusDevice, verify the grouping by “Read Group”
Using fcmbconv.py to convert it to: FCModbus
Import it into free client module:
Modify setting for weird points.
For lamp1:
Finally, verify its behavior by Yabe. If the script fails, please check the log.
The final config file for the free client bus is: FCModbusFinal