Configuration
Modbus Configure File
In order to communicate with modbus devices, a proper modbus configure file is required. It is mainly to describe the device address and register mappings.
Here is the basic structure of modbus configure file.
1# Modbus Configuration File
2# --------------------------
3# This configuration file is to describe the Modbus registers of target device(s) and defines poller(s) to help polling data.
4# The file format uses "csv" instead of json or yaml because many vendor's modbus registers are described in a table so it is easier to edit the information in excel and export to csv format.
5#
6# Configuration Types
7# --------------------------
8# device,<device_name>,<device_id>
9# poll,<object_type>,<start_address>,<size>,<endian>
10# ref,<ref_name>,<address>,<dtype>,<rw>,<unit>,<scale>
11#
12# Configuration Objects
13# --------------------------
14# <device_name>: any string without spaces to describe the device
15# <device_id>: integer 1 to 254 to describe device ID
16# <object_type>: coil/discrete_input/holding_register/input_register
17# <start_address>: integer 0 to 65535 (The start address of Modbus registers to poll)
18# <size>: integer 0 to 65535 (No. of registers to poll and value must not exceed the limits of Modbus)
19# <endian>: byte_order and word_order e.g. BE_BE/BE_LE/LE_LE/LE_BE
20# <ref_name>: any string without spaces to describe the reference
21# <address>: integer 0 to 65535 (the modbus address and should match the poller range)
22# <dtype>: uint16/int16/uint32/int32/float16/float32/bool8/bool16/stringXXX (defaults to uint16)
23# <rw>: read/write setting e.g. r/w/rw
24# <unit> (optional): the measurement unit of reference
25# <scale> (Optional): a float value to be multiplied with actual register reading
26#
27# Typical Structure
28# -----------------------------
29# device,dev001,1 <- the first device (dev001)
30# poll,... <- the first poller of dev001
31# ref,... <- the references in poller
32# ref,...
33# poll,... <- the second poller of dev001
34# ref,...
35# ref,...
36# device,dev002,2 <- the second device (dev002)
37# poll,... <- the first poller of dev002
38# ref,...
39#
40# Configuration Example
41# !!! Please remove all comments for your config file !!!
42# -----------------------------
43device,modsim001,1,,
44poll,coil,0,12,BE_BE
45ref,coil01-08,0,bool8,rw
46ref,coil09-12,1,bool8,rw
47poll,holding_register,40000,20,BE_BE
48ref,holding_reg01,40000,uint16,rw
49ref,holding_reg02,40001,uint16,rw
50ref,holding_reg03,40002,uint16,rw
51ref,holding_reg04,40003,uint16,rw
52ref,holding_reg05,40004,int16,rw
53ref,holding_reg06,40005,int16,rw
54ref,holding_reg07,40006,int16,rw
55ref,holding_reg08,40007,int16,rw
56ref,holding_reg09,40008,uint32,rw
57ref,holding_reg10,40010,uint32,rw
58ref,holding_reg11,40012,int32,rw
59ref,holding_reg12,40014,int32,rw
60ref,holding_reg13,40016,float32,rw
61ref,holding_reg14,40018,float32,rw
Example 1: Modsim device (Modbus TCP device)
This online Modbus TCP device simulator is designed for user to quickly test the modpoll functions.
Here is an example of modbus configure file for reading modsim device.
1device,modsim001,1,,
2poll,coil,0,16,BE_BE
3ref,coil01-08,0,bool8,rw
4ref,coil09-16,1,bool8,rw
5poll,discrete_input,10000,16,BE_BE
6ref,di01-08,10000,bool8,rw
7ref,di09-16,10001,bool8,rw
8poll,input_register,30000,20,BE_BE
9ref,input_reg01,30000,uint16,rw
10ref,input_reg02,30001,uint16,rw
11ref,input_reg03,30002,uint16,rw
12ref,input_reg04,30003,uint16,rw
13ref,input_reg05,30004,int16,rw
14ref,input_reg06,30005,int16,rw
15ref,input_reg07,30006,int16,rw
16ref,input_reg08,30007,int16,rw
17ref,input_reg09,30008,uint32,rw
18ref,input_reg10,30010,uint32,rw
19ref,input_reg11,30012,int32,rw
20ref,input_reg12,30014,int32,rw
21ref,input_reg13,30016,float32,rw
22ref,input_reg14,30018,float32,rw
23poll,holding_register,40000,20,BE_BE
24ref,holding_reg01,40000,uint16,rw
25ref,holding_reg02,40001,uint16,rw
26ref,holding_reg03,40002,uint16,rw
27ref,holding_reg04,40003,uint16,rw
28ref,holding_reg05,40004,int16,rw
29ref,holding_reg06,40005,int16,rw
30ref,holding_reg07,40006,int16,rw
31ref,holding_reg08,40007,int16,rw
32ref,holding_reg09,40008,uint32,rw
33ref,holding_reg10,40010,uint32,rw
34ref,holding_reg11,40012,int32,rw
35ref,holding_reg12,40014,int32,rw
36ref,holding_reg13,40016,float32,rw
37ref,holding_reg14,40018,float32,rw
Example 2: SCPM-S6 Power Meter (Modbus RTU device)
SCPM-S6 is designed as a sub-circuit power meter to monitor multiple electrical circuit power consumptions.
Here is an example of modbus configure file for SCPM-S6.
1device,scpm001,1,,,
2poll,holding_register,46001,6,BE_BE,
3ref,CT_TYPE,46001,uint16,rw,
4ref,CT_RATING,46002,uint16,rw,
5ref,DATA_SCALAR,46003,uint16,rw,
6ref,ReservedA,46004,uint16,rw,
7ref,ReservedB,46005,uint16,rw,
8ref,SIGNED_MODE,46006,uint16,rw,
9poll,holding_register,46011,92,BE_BE,
10ref,Hz,46011,int16,r,Hz
11ref,V,46012,int16,r,V
12ref,CH1_A,46013,int16,r,A
13ref,CH2_A,46014,int16,r,A
14ref,CH3_A,46015,int16,r,A
15ref,CH4_A,46016,int16,r,A
16ref,CH5_A,46017,int16,r,A
17ref,CH6_A,46018,int16,r,A
18ref,CH1_kWh,46019,uint32,r,kWh
19ref,CH2_kWh,46021,uint32,r,kWh
20ref,CH3_kWh,46023,uint32,r,kWh
21ref,CH4_kWh,46025,uint32,r,kWh
22ref,CH5_kWh,46027,uint32,r,kWh
23ref,CH6_kWh,46029,uint32,r,kWh
24ref,CH1_kWh_P,46031,uint32,r,kWh
25ref,CH2_kWh_P,46033,uint32,r,kWh
26ref,CH3_kWh_P,46035,uint32,r,kWh
27ref,CH4_kWh_P,46037,uint32,r,kWh
28ref,CH5_kWh_P,46039,uint32,r,kWh
29ref,CH6_kWh_P,46041,uint32,r,kWh
30ref,CH1_kWh_N,46043,uint32,r,kWh
31ref,CH2_kWh_N,46045,uint32,r,kWh
32ref,CH3_kWh_N,46047,uint32,r,kWh
33ref,CH4_kWh_N,46049,uint32,r,kWh
34ref,CH5_kWh_N,46051,uint32,r,kWh
35ref,CH6_kWh_N,46053,uint32,r,kWh
36ref,CH1_kVARh,46055,uint32,r,kVARh
37ref,CH2_kVARh,46057,uint32,r,kVARh
38ref,CH3_kVARh,46059,uint32,r,kVARh
39ref,CH4_kVARh,46061,uint32,r,kVARh
40ref,CH5_kVARh,46063,uint32,r,kVARh
41ref,CH6_kVARh,46065,uint32,r,kVARh
42ref,CH1_kVARh_P,46067,uint32,r,kVARh
43ref,CH2_kVARh_P,46069,uint32,r,kVARh
44ref,CH3_kVARh_P,46071,uint32,r,kVARh
45ref,CH4_kVARh_P,46073,uint32,r,kVARh
46ref,CH5_kVARh_P,46075,uint32,r,kVARh
47ref,CH6_kVARh_P,46077,uint32,r,kVARh
48ref,CH1_kVARh_N,46079,uint32,r,kVARh
49ref,CH2_kVARh_N,46081,uint32,r,kVARh
50ref,CH3_kVARh_N,46083,uint32,r,kVARh
51ref,CH4_kVARh_N,46085,uint32,r,kVARh
52ref,CH5_kVARh_N,46087,uint32,r,kVARh
53ref,CH6_kVARh_N,46089,uint32,r,kVARh
54ref,CH1_kVA,46091,int16,r,kVA
55ref,CH2_kVA,46092,int16,r,kVA
56ref,CH3_kVA,46093,int16,r,kVA
57ref,CH4_kVA,46094,int16,r,kVA
58ref,CH5_kVA,46095,int16,r,kVA
59ref,CH6_kVA,46096,int16,r,kVA
60ref,CH1_PF,46097,int16,r,
61ref,CH2_PF,46098,int16,r,
62ref,CH3_PF,46099,int16,r,
63ref,Reserved1,46100,int16,r,
64ref,Reserved2,46101,int16,r,
65ref,Reserved3,46102,int16,r,