DiData = (bool)MAKEWORD(MsgBuf[4], MsgBuf[3]);
// Step 2: Repeat Step 1 for getting another DO data
}
8.3.9 Read External Function
bool ReadExtData(void)
{
unsigned char MsgBuf[128];
unsigned char Addr = 1; /* Slave Id */
unsigned short StartRegAdd = 401;
unsigned short RegQuantities = 20;
unsigned short ExtData;
// Read register data from remote device
ReadData(Addr, StartRegAdd, RegQuantities, MsgBuf);
// Step 1: Parsing data for Ext1
DiData = MAKEWORD(MsgBuf[4], MsgBuf[3]);
// Step 2: Repeat Step 1 for getting another Ext data
Note:
*1: Above sample code is according to the PR20 setting, if user need changing the MsgBuf size and
RegQuantities value from PR10 or PR30, please refer to the user manual.
Because the Input Register Ext data is same like Holding Register Ext data, so the data type of
the ExtData must according to the setting of real case, if the data type of ExtData is 4 bytes, please
refer to "ReadMathData" function in Step 1, Step 2, Step 4 and Step 5 to convert data type of
customer
Requirement (Such as: Int32 or UInt32 or float data type).
}
8.4 Appendix
8.4.1
Modbus RTU Slave / TCP Server Register data type table
Field Name
AI
Math
DI
AO
DO
External
8.4.2 Inquire AI range
The Modbus scale range for each AI channel is available in the channel configuration page as
shown below.
Data Size
2 Bytes
4 Bytes
2 Bytes
2 Bytes
2 Bytes
2 Bytes / 4 Bytes
Page 473 of 479
Data Type
WORD
UINT32
WORD
WORD
WORD
WORD / DWORD
Note
Little Endian
Little Endian
Little Endian
Little Endian
Little Endian
Little Endian