@@ -19,252 +19,10 @@ Consider using Mb2hal if:
1919* You have more than one device to connect. Mb2hal is very efficient managing multiple devices, transactions and links. Currently i am monitoring two axis drivers using a Rs232 port, a VFD driver using another Rs232 port, and a remote I/O using TCP/IP.
2020* You want a protocol to connect your Arduino to HAL. Look the included sample configuration file, sketch and library for Arduino Modbus.
2121
22- == Example config file.
23- ----
24- #This .INI file is also the HELP, MANUAL and HOW-TO file for mb2hal.
25-
26- #Load the modbus HAL userspace module as the examples below,
27- #change to match your own HAL_MODULE_NAME and .ini file name
28- #Using HAL_MODULE_NAME=mb2hal or nothing (default): loadusr -W mb2hal config=config_file.ini
29- #Using HAL_MODULE_NAME=mymodule: loadusr -Wn mymodule mb2hal config=config_file.ini
30-
31- #Common section
32-
33- [MB2HAL_INIT]
34-
35- #OPTIONAL: Debug level of init and INI file parsing.
36- # 0 = silent.
37- # 1 = error messages (default).
38- # 2 = OK confirmation messages.
39- # 3 = debugging messages.
40-
41- INIT_DEBUG=3
42-
43- #OPTIONAL: HAL module (component) name. Defaults to "mb2hal".
44-
45- HAL_MODULE_NAME=mb2hal
46-
47- #OPTIONAL: Insert a delay of "FLOAT seconds" between transactions in order
48- #to not to have a lot of logging and facilitate the debugging.
49- #Useful when using DEBUG=3 (NOT INIT_DEBUG=3)
50- #It affects ALL transactions.
51- #Use "0.0" for normal activity.
52-
53- SLOWDOWN=0.0
54-
55- #REQUIRED: The number of total Modbus transactions. There is no maximum.
56-
57- TOTAL_TRANSACTIONS=9
58-
59- #One transaction section is required per transaction, starting at 00 and counting up sequentially.
60- #If there is a new link (not transaction), you must provide the REQUIRED parameters 1st time.
61- #Warning: Any OPTIONAL parameter not specified are copied from the previous transaction.
62-
63- [TRANSACTION_00]
64-
65- #REQUIRED: You must specify either a "serial" or "tcp" link for the first transaction.
66- #Later transaction will use the previous transaction link if not specified.
67-
68- LINK_TYPE=tcp
69-
70- #if LINK_TYPE=tcp then REQUIRED (only 1st time): The Modbus slave device ip address.
71- #if LINK_TYPE=serial then IGNORED
72-
73- TCP_IP=192.168.2.10
74-
75- #if LINK_TYPE=tcp then OPTIONAL.
76- #if LINK_TYPE=serial then IGNORED
77- #The Modbus slave device tcp port. Defaults to 502.
78-
79- TCP_PORT=502
80-
81- #if LINK_TYPE=serial then REQUIRED (only 1st time).
82- #if LINK_TYPE=tcp then IGNORED
83- #The serial port.
84-
85- SERIAL_PORT=/dev/ttyS0
86-
87- #if LINK_TYPE=serial then REQUIRED (only 1st time).
88- #if LINK_TYPE=tcp then IGNORED
89- #The baud rate.
90-
91- SERIAL_BAUD=115200
92-
93- #if LINK_TYPE=serial then REQUIRED (only 1st time).
94- #if LINK_TYPE=tcp then IGNORED
95- #Data bits. One of 5,6,7,8.
96-
97- SERIAL_BITS=8
98-
99- #if LINK_TYPE=serial then REQUIRED (only 1st time).
100- #if LINK_TYPE=tcp then IGNORED
101- #Data parity. One of: even, odd, none.
102-
103- SERIAL_PARITY=none
104-
105- #if LINK_TYPE=serial then REQUIRED (only 1st time).
106- #if LINK_TYPE=tcp then IGNORED
107- #Stop bits. One of 1, 2.
108-
109- SERIAL_STOP=2
110-
111- #if LINK_TYPE=serial then OPTIONAL:
112- #if LINK_TYPE=tcp then IGNORED
113- #Serial port delay between for this transaction only.
114- #In ms. Defaults to 0.
115-
116- SERIAL_DELAY_MS=10
117-
118- #REQUIRED (only 1st time).
119- #Modbus slave number.
120-
121- MB_SLAVE_ID=1
122-
123- #REQUIRED: The first element address.
124-
125- FIRST_ELEMENT=0
126-
127- #REQUIRED: The number of elements.
128-
129- NELEMENTS=16
130-
131- #REQUIRED: Modbus transaction function code (see www.modbus.org specifications).
132- # fnct_02_read_discrete_inputs (02 = 0x02)
133- # fnct_03_read_holding_registers (03 = 0x03)
134- # fnct_04_read_input_registers (04 = 0x04)
135- # fnct_15_write_multiple_coils (15 = 0x0F)
136- # fnct_16_write_multiple_registers (16 = 0x10)
137-
138- #fnct_02_read_discrete_inputs: creates boolean output HAL pins.
139- #fnct_03_read_holding_registers: creates a floating point output HAL pins.
140- # also creates a u32 output HAL pins.
141- #fnct_04_read_input_registers: creates a floating point output HAL pins.
142- # also creates a u32 output HAL pins.
143- #fnct_15_write_multiple_coils: creates boolean input HAL pins.
144- #fnct_16_write_multiple_registers: creates a floating point input HAL pins.
145-
146- #The pins are named based on component name, transaction number and order number.
147- #Example: mb2hal.00.01 (transaction=00, second register=01 (00 is the first one))
148-
149- MB_TX_CODE=fnct_03_read_holding_registers
150-
151- #OPTIONAL: Response timeout for this transaction. In INTEGER ms. Defaults to 500 ms.
152- #This is how much to wait for 1st byte before raise an error.
153-
154- MB_RESPONSE_TIMEOUT_MS=500
155-
156- #OPTIONAL: Byte timeout for this transaction. In INTEGER ms. Defaults to 500 ms.
157- #This is how much to wait from byte to byte before raise an error.
158-
159- MB_BYTE_TIMEOUT_MS=500
160-
161- #OPTIONAL: Instead of giving the transaction number, use a name.
162- #Example: mb2hal.00.01 could become mb2hal.plcin.01
163- #The name must not exceed 32 characters.
164- #NOTE: when using names be careful that you dont end up with two transactions
165- #usign the same name.
166-
167- HAL_TX_NAME=remoteIOcfg
168-
169- #OPTIONAL: Maximum update rate in HZ. Defaults to 0.0 (0.0 = as soon as available = infinit).
170- #NOTE: This is a maximum rate and the actual rate may be lower.
171- #If you want to calculate it in ms use (1000 / required_ms).
172- #Example: 100 ms = MAX_UPDATE_RATE=10.0, because 1000.0 ms / 100.0 ms = 10.0 Hz
173-
174- MAX_UPDATE_RATE=0.0
175-
176- #OPTIONAL: Debug level for this transaction only.
177- #See INIT_DEBUG parameter above.
178-
179- DEBUG=1
180-
181- #While DEBUGGING transactions note the returned "ret[]" value correspond to:
182- #/* Modbus protocol exceptions */
183- #ILLEGAL_FUNCTION -0x01 the FUNCTION code received in the query is not allowed or invalid.
184- #ILLEGAL_DATA_ADDRESS -0x02 the DATA ADDRESS received in the query is not an allowable address for the slave or is invalid.
185- #ILLEGAL_DATA_VALUE -0x03 a VALUE contained in the data query field is not an allowable value or is invalid.
186- #SLAVE_DEVICE_FAILURE -0x04 SLAVE (or MASTER) device unrecoverable FAILUER while attemping to perform the requested action.
187- #SERVER_FAILURE -0x04 (see above).
188- #ACKNOWLEDGE -0x05 This response is returned to PREVENT A TIMEOUT in the master.
189- # A long duration of time is required to process the request in the slave.
190- #SLAVE_DEVICE_BUSY -0x06 The slave (or server) is BUSY. Retrasmit the request later.
191- #SERVER_BUSY -0x06 (see above).
192- #NEGATIVE_ACKNOWLEDGE -0x07 Unsuccessful programming request using function code 13 or 14.
193- #MEMORY_PARITY_ERROR -0x08 SLAVE parity error in MEMORY.
194- #GATEWAY_PROBLEM_PATH -0x0A (-10) Gateway path(s) not available.
195- #GATEWAY_PROBLEM_TARGET -0x0B (-11) The target device failed to repond (generated by master, not slave).
196- #/* Program or connection */
197- #COMM_TIME_OUT -0x0C (-12)
198- #PORT_SOCKET_FAILURE -0x0D (-13)
199- #SELECT_FAILURE -0x0E (-14)
200- #TOO_MANY_DATAS -0x0F (-15)
201- #INVALID_CRC -0x10 (-16)
202- #INVALID_EXCEPTION_CODE -0x11 (-17)
203-
204- [TRANSACTION_01]
205- MB_TX_CODE=fnct_02_read_discrete_inputs
206- FIRST_ELEMENT=1024
207- NELEMENTS=24
208- HAL_TX_NAME=remoteIOin
209- MAX_UPDATE_RATE=0.0
210- DEBUG=1
211-
212- [TRANSACTION_02]
213- MB_TX_CODE=fnct_15_write_multiple_coils
214- FIRST_ELEMENT=1280
215- NELEMENTS=8
216- HAL_TX_NAME=remoteIOout
217- MAX_UPDATE_RATE=0.0
218-
219- [TRANSACTION_03]
220- LINK_TYPE=serial
221- SERIAL_PORT=/dev/ttyS0
222- SERIAL_BAUD=115200
223- SERIAL_BITS=8
224- SERIAL_PARITY=none
225- SERIAL_STOP=2
226- SERIAL_DELAY_MS=50
227- MB_SLAVE_ID=1
228- MB_TX_CODE=fnct_03_read_holding_registers
229- FIRST_ELEMENT=1
230- NELEMENTS=2
231- HAL_TX_NAME=XDrive01
232- MAX_UPDATE_RATE=0.0
233- DEBUG=1
234-
235- [TRANSACTION_04]
236- MB_TX_CODE=fnct_03_read_holding_registers
237- FIRST_ELEMENT=4
238- NELEMENTS=3
239- HAL_TX_NAME=XDrive02
240- MAX_UPDATE_RATE=0.0
241- DEBUG=1
242-
243- [TRANSACTION_05]
244- MB_TX_CODE=fnct_03_read_holding_registers
245- FIRST_ELEMENT=9
246- NELEMENTS=1
247- HAL_TX_NAME=XDrive03
248- MAX_UPDATE_RATE=0.0
249-
250- [TRANSACTION_06]
251- MB_TX_CODE=fnct_03_read_holding_registers
252- FIRST_ELEMENT=1024
253- NELEMENTS=1
254- HAL_TX_NAME=XDrive04
255- MAX_UPDATE_RATE=0.0
256-
257- [TRANSACTION_07]
258- MB_TX_CODE=fnct_03_read_holding_registers
259- FIRST_ELEMENT=1030
260- NELEMENTS=2
261- HAL_TX_NAME=XDrive05
262- MAX_UPDATE_RATE=0.0
26322
264- [TRANSACTION_08]
265- MB_TX_CODE=fnct_03_read_holding_registers
266- FIRST_ELEMENT=1033
267- NELEMENTS=1
268- HAL_TX_NAME=XDrive06
269- MAX_UPDATE_RATE=0.0
23+ == Example config file
24+ Click link:mb2hal_HOWTO.ini[here] to download.
25+ [source,ini]
27026----
27+ include::../../../src/hal/user_comps/mb2hal/mb2hal_HOWTO.ini[]
28+ ----
0 commit comments