We have configured an Ignition system to allow the customer to add new machinery through the user interface. Using a script we can add a new Modbus TCP/IP device using system.device.addDevice.
Is it also possible to set up address mapping in the script as well? This would allow us to refer to addresses using the PLC registers and just use Modbus as the transport mechanism.
Address mapping is optional for Modbus TCP devices. It’s purpose is to give users something to see in the OPC browser. If you are automating, you can just create the tags with the appropriate addresses and data formats.
Yes, but workers on site are much more familiar with the PLC native addressing, so it would be one less layer for them to learn about if they ever have to maintain the system.
For example, if they are dealing with register D210, they will see an OPC item path like
ns=l;s=[Device]1.D210
instead of a Modbus OPC item path like
ns=l;s=[Device]1.HR211
(including an annoying offset!)
Address mapping works well so it would be a shame not to be able to use it when we automate the process.
Ah, OK. Well, the entire address map for the device is stored as a string in a property named “AddressMap”, so try to set that in the driver’s deviceProps. You might have to dig around in the SDK example (the modbus driver is published code) for the format. Look at its ModbusStringParser.toParseableString(). From a quick look, it’s fairly predictable. You can get some samples, too, if you look in your server’s internal database at the table ModbusTcpDriverSettings.
@AlThePal Now in 2021, I have taken a look at the internal database containing ModbusDriverSettings. It’s still quite dangerous when we make address mapping via Script. However, I think we still can do that if we defined a flexible structure. In addition, we can import and export the Modbus address to the CSV file in the Gateway at the moment.