User`s manual

Western Reserve Controls 1782-JDM User’s Manual
PUB 24.0
10
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 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. The JDM will then wait for a reply from the addressed device.
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, 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)
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
E1
hex
Bad Checksum
E2
hex
Response Address Mismatch
E3
hex
Response Function Code Mismatch
E4
hex
Truncated Message received from device
E5
hex
No Data received from device
E6
hex
Not Enough Data Received
E7
hex
Unused