ModBus: Communication Control Blocks
Since this was written we have introduced Hash commands. The Open_Serial hash command make this much simpler to do.
ModBus is selected and configured via a suitable Communications Control Block (CCB). The following table summarizes the various parameters in the CCBs for ModBus. Entries are hyper-linked to detailed descriptions. If you are using a ModBus protocol you must set up a CCB with the specified parameters and then invoke it in your program with a ComSetCCB instruction.
The table contains a spare column so you can print it out and use it as a work sheet. Click on each entry to get a detailed expose.
| Byte | Slave RTU | Master RTU | Notes |
|---|---|---|---|
| 0 | 1 | 2 | |
| 1 | 0 | ||
| 2 | |||
| 3 | |||
| 4 | Not used - set to 255 | ||
| 5 | Not used - set to 255 | ||
| 6 | Not used - set to 255 | ||
| 7 | Not used - set to 255 | ||
| 8 | Not used - set to 255 | ||
| 9 | |||
| 10 | 0 | ||
| 11 | 0 | ||
| 12 | Not used - set to 255 | ||
| 13 | Not used - set to 255 | ||
| 14 | Not used - set to 255 | ||
| 15 | Not used - set to 255 | ||
| 16 | Not used - set to 255 | ||
| 17 | Not used - set to 255 | ||
| 18 | Not used - set to 255 | ||
| 19 | Not used - set to 255 | ||
Examples
The following table is a copy of the one above (with the master column removed) used as a worksheet for a slave.
| Byte | Slave RTU | Example value |
|---|---|---|
| 0 | 1 | 1 |
| 1 | 3 | |
| 2 | 0 (8,1,N) | |
| 3 | 5 (9600) | |
| 4 | Not used - set to 255 | |
| 5 | Not used - set to 255 | |
| 6 | Not used - set to 255 | |
| 7 | Not used - set to 255 | |
| 8 | Not used - set to 255 | |
| 9 | 10 (x10mS = 100mS) | |
| 10 | 0 (Not used in slave) | |
| 11 | 0 (Not used in slave) | |
| 12 | Not used - set to 255 | |
| 13 | Not used - set to 255 | |
| 14 | Not used - set to 255 | |
| 15 | Not used - set to 255 | |
| 16 | Not used - set to 255 | |
| 17 | Not used - set to 255 | |
| 18 | Not used - set to 255 | |
| 19 | Not used - set to 255 |
In your SPLat program this configuration would look like this:
NVEM0 ;Start of NVEM dataModBusCCB:NV0Byte 1 ;ProtocolNV0Byte 3 ;AddressNV0Byte 0 ;Character = 8,1,NNV0Byte 5 ;9600NV0Byte 255 ;Not used - set to 255NV0Byte 255 ;Not used - set to 255NV0Byte 255 ;Not used - set to 255NV0Byte 255 ;Not used - set to 255NV0Byte 255 ;Not used - set to 255NV0Byte 10 ;Message gap 100mSNV0Byte 100 ;Query timeout 1SNV0Byte 3 ;Query attemptsNV0Byte 255,255,255,255,255,255,255,255 ;Not used- set to 255
