User`s manual

Western Reserve Controls 1782-JDM User’s Manual
PUB 24.0
10
2.4 How to Read ModBus Device Input Data
1. Set up the poll input data field size in your Master’s scan table to be equal to or greater than the
number of bytes required for the largest ModBus message received from your device(s). (Default size
is 48 bytes).
2. Set up a Poll Connection (Allocate Connection Instance 2) to the 1782-JDM from the Master.
3. Configure the serial port to read input data by setting the appropriate values in the Parameter Data,
described in Section 4.
4. Perform a poll function to the JDM using one of the ModBus read command strings. This will contain
the “record number” in the 1
st
byte (which must be different than the last sent message), followed by a
length byte and then the command string as shown in the ModBus RTU specification, WITHOUT the
leading colon, the checksum, or the carriage return/linefeed. The JDM will translate this command to
the proper ModBus format, compute the checksum, add the colon, carriage return/linefeed (ASCII
mode), and send the message out the serial port. The JDM will then return a response with an
updated record number (indicating that it has received and processed the previous command) and
with the “waiting” bit set in the status byte (indicating that a response to that command has not yet
been received from the ModBus device).
5. Once the device’s response is received by the JDM, the JDM will check the checksum, and if ok will
strip the leading colon, the checksum, and the carriage return/linefeed from the message (in ASCII
mode). It will then produce a poll response with the “waiting” bit reset.
6. The response includes three extra bytes of data in addition to the ModBus data. The first byte of the
response will be a “record counter” which is a counter generated by the JDM to mark the message
with a sequential count value. Each time a new message is received at the JDM from the ModBus
network, it will increment the internal record number counter.
7. The second byte of the record will be a status byte. This is the status of the ModBus transaction. It will
be non-zero if an error occurred, or zero if OK. See for specific values.
8. The third byte is length, indicating the number of valid ModBus data bytes in the following data field.
9. The response Modbus data bytes will be returned in the mapped poll response data field. The data will
be in binary hexadecimal format (ASCII ‘A’ = 41 hex,
etc) and will represent the complete ModBus
message, less checksum / carriage return/linefeed and the leading “:” (colon) (for ASCII mode). This
data will also be formatted such that each data word contains the least significant byte in the low byte
and the most significant byte in the high byte. (This is commonly referred to as “little endian” format.)
A typical response is as follows:
Record count or sequence number (1 byte)
Status / error data (1 byte)
Modbus Message Length (1byte)
Device’s ModBus address (1 byte)
ModBus command number (1 byte)
Starting ModBus register address (2 bytes)
Number of data bytes (1 byte)
1
st
Register data (2 byes)
2
nd
Register data (2 byes)