User`s manual

Western Reserve Controls 1782-JDM User’s Manual
PUB 24.0
11
3
rd
Register data (2 byes)
2.5 How to Write ModBus Device Output Data
1. Configure the port to send output data by setting the size of the poll output buffer at the Master to
reflect the number of output bytes that will be sent to the ModBus device (default is 48 bytes).
2. Perform a poll function that has the first byte of the field as the “record number”, which the host
application must increment each time a new record is to sent to the ModBus device. The next byte will
contain the length of the subsequent ModBus data field. The bytes following this will be the ModBus
output command string in binary format, to be sent to the ModBus device, less the leading colon,
checksum, and carriage return/linefeed.
3. The JDM will check the record number, and if different from the last received record number, will
compute the checksum, add the leading colon and convert the command string to ASCII (in ASCII
mode), and add the carriage return/linefeed. This message is then sent out the serial port to the
addressed ModBus device.
4. If data is to be returned as a result of the command, the JDM will respond with a response with the
waiting bit set, and then with waiting bit reset after receiving the ModBus response.
5. When a response is received from the addressed device, the JDM will check the checksum, and if
OK, will strip the leading colon and convert the message to binary (in ASCII mode), strip the
checksum and carriage return/linefeed.
6. A new record number is generated and placed in the 1
st
byte of the poll response. The 2
nd
byte is the
receiver error byte and the 3
rd
byte is the length byte, with the stripped binary reply following. If no
error occurs, the error byte will be zero. Otherwise the status byte (2
nd
byte in the poll response) will
have one of the error values shown in Table 2-3.
The data sent to the JDM will typically contain the following info:
Record sequence number (1 byte)
Status byte (1 byte)
Length byte (1 byte)
Device’s ModBus address (1 byte)
ModBus command number (1 byte)
Beginning Register number (2 byes)
Number of registers (2 bytes)
Output data (2 bytes per datum value)
Table 2-3 Poll Response Status Byte Codes
Error Number Definition
08
hex
CRC or LRC error
04
hex
ModBus response time-out; a response from the ModBus device did not occur within
the time set by the time-out parameter.
02
hex
Invalid data received from the ModBus device; data internal to ModBus string is
invalid for some reason.