Modbus Protocol Operation Flow

Modbus is a single master, multiple slaves communication protocol that is widely used and is
popular among many industrial devices. It is a request/reply protocol that offers services
specified by function codes. Two main flavours of the Modbus Protocol are Modbus over serial
RS485 lines (called as Modbus RTU), and Modbus over ethernet connection (called Modbus TCP).

Modbus TCP uses a reserved system port 502. Slave addresses for Modbus RTU range from 1 to 247. Addresses 0 and 248 to 255 are
reserved. Modbus TCP uses a pseudo slave address 255, since all it’s communication is addressed by IP addresses and port 502.

Modbus Protocol Processor is compatible with IAP/MQ. The total number of slaves allowed are 10 for Modbus RTU and 10 for Modbus TCP.
The functionality of the Modbus Protocol Processor on Apollo and IOX is very similar, with few
differences. For example, the IAP/MQ protocol identifier of the Modbus Engine on Apollo is
“modbus”, however, the protocol on IOX is iox.<id>. As a result, a Modbus request topic on
Apollo might look like this: “ glp/0/SID/rq/dev/modbus/nippon/do ”, but the same request topic
will look like this on IOX: “ glp/0/SID/rq/dev/iox.409e7c/nippon/do ”. In both cases, this request
will produce the same result, and the same object will be published by the Modbus Protocol
Processor. Also note that IOX does NOT support Modbus TCP.


Following are the operations request and response collected: create, provision, Monitoring object configuration, deprovision, delete.

Flow of operations are

  1. Modbus Device Creation and setting device location
  2. Modbus Device Provisioning
  3. Modbus device send monitoring configuration on request channel.
  4. Response from modbus engine
  5. Publications to monitoring service
  6. Modbus device deprovision
  7. Modbus device delete


1. Modbus Device Creation and Setting Device Location

This will creates the IAP modbus device.

Request: Modbus Device Creation & Setting Device Location topics

mosquitto_pub -t glp/0/T6tWyga/rq/dev/modbus/pm_rtu/do -m '{"action":"create","args":{"unid":"01:1","type":"900014150040DB00"}}'
mosquitto_pub -t glp/0/T6tWyga/rq/dev/modbus/pm_rtu/cfg -m '{"name":"rv-test-cfg","desc":"description","loc":{"desc":"","lat":27.68353,"lng":76.64063,"ele":null}}'


In the response modbus engine will publishes its status and configuration objects in the feedback channel

Response: Modbus Device Creation & Setting Device Location

Topic: glp/0/T6tWyga/fb/dev/modbus/pm_rtu/sts
Data:
{
"state": "unprovisioned",
"unid": "01:1",
"health": "normal",
"cat": "i/o",
"type": "900014150040DB00",
"interfaceType": "static",
"usage": "controller",
"version": "PowerLogic 820 Series Digital P",
"product": "PM820RTU",
"manufacturer": "Schneider-Electric",
"mru": "2019-03-19 05:44:40.000 UTC"
}

Topic: glp/0/T6tWyga/fb/dev/modbus/pm_rtu/cfg
Data: {"name":"rv-test-cfg","desc":"description","motion_zone":0,"motion_radius":0,"motion_timeout":0,"loc":{"lat":27.683530807495117,"lng":76.640632629394531,"ele":0},"mru":"2019-03-19 07:45:51.000 UTC"}


2. Modbus Device Provisioning

Provisioning will bring the device into the fully operational state.

Request: Modbus Device Provisioning
mosquitto_pub -t glp/0/T6tWyga/rq/dev/modbus/pm_rtu/do -m '{"action":"provision"}'


Response: Modbus Device Provisioning

On successful completion leaves the device in the provisioned state. The device’s interface are fully reported when the device enters the provisioned state, and data about profile, datapoint and property types are available at this time.

Response: Modbus Device Provision
Type objects:
Topic: glp/0/T6tWyga/fb/res/type/blk.900014150040DB00/0 
Data: {"id":0,"name":"blk","class":"profile","datapoint":{"Voltage_A-N":{"id":"Voltage_A-N","mandatory":true,"type":"0000000000000000-0/SNVT_volt","direction":"output","service":"any"},"Voltage_B-N":{"id":"Voltage_B-N","mandatory":true,"type":"0000000000000000-0/SNVT_volt","direction":"output","service":"any"},"Voltage_C-N":{"id":"Voltage_C-N","mandatory":true,"type":"0000000000000000-0/SNVT_volt","direction":"output","service":"any"},"Current_Phase_A":{"id":"Current_Phase_A","mandatory":true,"type":"0000000000000000-0/SNVT_amp","direction":"output","service":"any"},"Current_Phase_B":{"id":"Current_Phase_B","mandatory":true,"type":"0000000000000000-0/SNVT_amp","direction":"output","service":"any"},"Current_Phase_C":{"id":"Current_Phase_C","mandatory":true,"type":"0000000000000000-0/SNVT_amp","direction":"output","service":"any"},"Frequency":{"id":"Frequency","mandatory":true,"type":"0000000000000000-0/SNVT_freq_hz","direction":"output","service":"any"}}}

Topic: glp/0/T6tWyga/fb/res/type/blk.900014150040DB00/1 
Data: {"id":1,"name":"blk","class":"profile","datapoint":{"Voltage_A-B":{"id":"Voltage_A-B","mandatory":true,"type":"0000000000000000-0/SNVT_volt","direction":"output","service":"any"},"Voltage_B-C":{"id":"Voltage_B-C","mandatory":true,"type":"0000000000000000-0/SNVT_volt","direction":"output","service":"any"},"Voltage_C-A":{"id":"Voltage_C-A","mandatory":true,"type":"0000000000000000-0/SNVT_volt","direction":"output","service":"any"},"Voltage_L-L_Avg":{"id":"Voltage_L-L_Avg","mandatory":true,"type":"0000000000000000-0/SNVT_volt","direction":"output","service":"any"},"Voltage_L-N_Avg":{"id":"Voltage_L-N_Avg","mandatory":true,"type":"0000000000000000-0/SNVT_volt","direction":"output","service":"any"},"Current_3-Phase_Average":{"id":"Current_3-Phase_Average","mandatory":true,"type":"0000000000000000-0/SNVT_amp","direction":"output","service":"any"},"Current_Neutral":{"id":"Current_Neutral","mandatory":true,"type":"0000000000000000-0/SNVT_amp","direction":"output","service":"any"},"Real_Power_Total":{"id":"Real_Power_Total","mandatory":true,"type":"0000000000000000-0/SNVT_power_k","direction":"output","service":"any"},"Reactive_Power_Total":{"id":"Reactive_Power_Total","mandatory":true,"type":"0000000000000000-0/SNVT_power_k","direction":"output","service":"any"},"Apparent_Energy_Delivered":{"id":"Apparent_Energy_Delivered","mandatory":true,"type":"0000000000000000-0/SNVT_power","direction":"output","service":"any"},"Apparent_Energy_Received":{"id":"Apparent_Energy_Received","mandatory":true,"type":"0000000000000000-0/SNVT_power","direction":"output","service":"any"},"Active_Power_A":{"id":"Active_Power_A","mandatory":true,"type":"0000000000000000-0/SNVT_power_k","direction":"output","service":"any"},"Active_Power_B":{"id":"Active_Power_B","mandatory":true,"type":"0000000000000000-0/SNVT_power_k","direction":"output","service":"any"},"Active_Power_C":{"id":"Active_Power_C","mandatory":true,"type":"0000000000000000-0/SNVT_power_k","direction":"output","service":"any"},"Reactive_Power_A":{"id":"Reactive_Power_A","mandatory":true,"type":"0000000000000000-0/SNVT_power_k","direction":"output","service":"any"},"Reactive_Power_B":{"id":"Reactive_Power_B","mandatory":true,"type":"0000000000000000-0/SNVT_power_k","direction":"output","service":"any"},"Reactive_Power_C":{"id":"Reactive_Power_C","mandatory":true,"type":"0000000000000000-0/SNVT_power_k","direction":"output","service":"any"},"Apparent_Power_A":{"id":"Apparent_Power_A","mandatory":true,"type":"0000000000000000-0/SNVT_amp","direction":"output","service":"any"},"Apparent_Power_B":{"id":"Apparent_Power_B","mandatory":true,"type":"0000000000000000-0/SNVT_amp","direction":"output","service":"any"},"Apparent_Power_C":{"id":"Apparent_Power_C","mandatory":true,"type":"0000000000000000-0/SNVT_amp","direction":"output","service":"any"},"Apparent_Power_Total":{"id":"Apparent_Power_Total","mandatory":true,"type":"0000000000000000-0/SNVT_amp","direction":"output","service":"any"},"True_Power_Factor_A":{"id":"True_Power_Factor_A","mandatory":true,"type":"0000000000000000-0/SNVT_pwr_fac","direction":"output","service":"any"},"True_Power_Factor_B":{"id":"True_Power_Factor_B","mandatory":true,"type":"0000000000000000-0/SNVT_pwr_fac","direction":"output","service":"any"},"True_Power_Factor_C":{"id":"True_Power_Factor_C","mandatory":true,"type":"0000000000000000-0/SNVT_pwr_fac","direction":"output","service":"any"},"True_Power_Factor_Total":{"id":"True_Power_Factor_Total","mandatory":true,"type":"0000000000000000-0/SNVT_pwr_fac","direction":"output","service":"any"}}}


Interface objects:
Topic: glp/0/T6tWyga/fb/dev/modbus/pm_rtu/if/block/0 
Data: {"type":"blk.900014150040DB00/0","Voltage_A-N":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_volt","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Voltage_B-N":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_volt","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Voltage_C-N":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_volt","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Current_Phase_A":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_amp","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Current_Phase_B":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_amp","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Current_Phase_C":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_amp","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Frequency":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_freq_hz","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"mru":"2019-03-19 05:46:32.000 UTC"}


Topic: glp/0/T6tWyga/fb/dev/modbus/pm_rtu/if/block/1 
Data: {"type":"blk.900014150040DB00/1","Voltage_A-B":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_volt","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Voltage_B-C":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_volt","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Voltage_C-A":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_volt","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Voltage_L-L_Avg":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_volt","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Voltage_L-N_Avg":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_volt","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Current_3-Phase_Average":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_amp","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Current_Neutral":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_amp","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Real_Power_Total":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_power_k","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Reactive_Power_Total":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_power_k","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Apparent_Energy_Delivered":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_power","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Apparent_Energy_Received":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_power","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Active_Power_A":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_power_k","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Active_Power_B":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_power_k","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Active_Power_C":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_power_k","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Reactive_Power_A":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_power_k","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Reactive_Power_B":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_power_k","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Reactive_Power_C":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_power_k","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Apparent_Power_A":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_amp","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Apparent_Power_B":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_amp","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Apparent_Power_C":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_amp","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Apparent_Power_Total":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_amp","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"True_Power_Factor_A":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_pwr_fac","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"True_Power_Factor_B":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_pwr_fac","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"True_Power_Factor_C":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_pwr_fac","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"True_Power_Factor_Total":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_pwr_fac","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"mru":"2019-03-19 05:46:32.000 UTC"}


Status object:
Topic: glp/0/T6tWyga/fb/dev/modbus/pm_rtu/sts 
Data: {"state":"provisioned","unid":"01:1","health":"normal","cat":"i/o","type":"900014150040DB00","interfaceType":"static","usage":"controller","version":"PowerLogic 820 Series Digital P","product":"PM820RTU","manufacturer":"Schneider-Electric","mru":"2019-03-19 05:46:32.000 UTC"}


3. Modbus device send monitoring configuration on request channel.

This request set the monitoring configuration periodic update rate to 20 sec and send the response on feedback channel. Modbus engine also publishes configuration update to the monitoring service.

Request: Set monitoring rate configuration value
mosquitto_pub -t glp/0/T6tWyga/rq/dev/modbus/pm_rtu/if/block/0/Voltage_A-N/monitor/rate -m '20'


4. Response from modbus engine

Response message shows the updated value for monitoring rate configuration.

Response: Set Monitoring rate configuration value

Topic: glp/0/T6tWyga/fb/dev/modbus/pm_rtu/if/block/0
Data: {"type":"blk.900014150040DB00/0","Voltage_A-N":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_volt","value":16,"monitor":{"rate":20,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":16}}},"Voltage_B-N":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_volt","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Voltage_C-N":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_volt","value":17,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":17}}},"Current_Phase_A":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_amp","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Current_Phase_B":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_amp","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Current_Phase_C":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_amp","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"Frequency":{"cat":"out","property":false,"type":"0000000000000000-0/SNVT_freq_hz","value":0,"monitor":{"rate":0,"cat":"data","inFeedback":true,"report":"change","throttle":0},"values":{"level":17,"levels":{"17":0}}},"mru":"2019-03-19 05:58:08.000 UTC"}


5. Publications to monitoring service

Modbus engine publishes updated monitoring configurations to monitoring service.

Publish topic to Monitoring Service from Modbus
Topic: glp/0/./=monitoring/service
Data: {"topic":"glp/0/T6tWyga/fb/dev/modbus/pm_rtu/if/block/0","datapoint":"Voltage_A-N","value":16,"monitor":{"rate":20,"cat":"data","inFeedback":true,"report":"change","throttle":0}}


6. Deprovision Modbus device

Modbus deprovisioning will stop the polling of the modbus slave.

Request: Deprovision Modbus Device
mosquitto_pub -t glp/0/T6tWyga/rq/dev/modbus/pm_rtu/do -m '{"action":"deprovision"}'


Deprovisioning will change the state of the device back to "unprovisioned".

Response: Deprovision Modbus Device

Topic: glp/0/T6tWyga/fb/dev/modbus/pm_rtu/sts
Data: {"state":"unprovisioned","unid":"01:1","health":"normal","cat":"i/o","type":"900014150040DB00","interfaceType":"static","usage":"controller","version":"PowerLogic 820 Series Digital P","product":"PM820RTU","manufacturer":"Schneider-Electric","mru":"2019-03-19 05:59:58.000 UTC"}


7. Delete Modbus device

Modbus engine will delete the memory data allocated during the device creation and also delete all monitoring service configuration data. Deleted device will no more exists in GLP.

Request: Delete Modbus Device
mosquitto_pub -t glp/0/T6tWyga/rq/dev/modbus/pm_rtu/do -m '{"action":"delete"}'


Response: Delete Modbus Device

Topic: glp/0/T6tWyga/fb/dev/modbus/pm_rtu/sts
Data: {"state":"deleted","unid":"01:1","health":"normal","cat":"i/o","type":"900014150040DB00","interfaceType":"static","usage":"controller","version":"PowerLogic 820 Series Digital P","product":"PM820RTU","manufacturer":"Schneider-Electric","mru":"2019-03-19 06:02:05.000 UTC"}