Knowledge Base

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.

ByteSlave RTUMaster RTUNotes
012 
1DevAddr0 
2CharProfileCharProfile 
3BaudRateBaudRate 
4Not used – set to 255 
5Not used – set to 255 
6Not used – set to 255 
7Not used – set to 255 
8Not used – set to 255 
9MessageGapMessageGap 
100QryTimeout 
110QryAttempts 
12Not used – set to 255 
13Not used – set to 255 
14Not used – set to 255 
15Not used – set to 255 
16Not used – set to 255 
17Not used – set to 255 
18Not used – set to 255 
19Not 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.

ByteSlave RTUExample value
011
1DevAddr3
2CharProfile0 (8,1,N)
3BaudRate5 (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
9MessageGap10 (x10mS = 100mS)
10QryTimeout0 (Not used in slave)
11QryAttempts0 (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 data
ModBusCCB:
NV0Byte 1 ;Protocol
NV0Byte 3 ;Address
NV0Byte 0 ;Character = 8,1,N
NV0Byte 5 ;9600
NV0Byte 255 ;Not used - set to 255
NV0Byte 255 ;Not used - set to 255
NV0Byte 255 ;Not used - set to 255
NV0Byte 255 ;Not used - set to 255
NV0Byte 255 ;Not used - set to 255
NV0Byte 10 ;Message gap 100mS
NV0Byte 100 ;Query timeout 1S
NV0Byte 3 ;Query attempts
NV0Byte 255,255,255,255,255,255,255,255 ;Not used - set to 255