When working with coils, the datalogger requires Boolean variables. When reading coils, each
Boolean in an array will hold the state of one coil. A value of True will set the coil, a value of
False will unset the coil.
7.2.7.3 Data Types
Modbus does not restrict what data types may be contained within holding and input registers.
Equipment manufacturers need to indicate what binary data types they are using to store data.
Registers are 16-bit, so 32-bit data types use 2 registers each. Some devices combine more
registers together to support longer data types like strings. The
ModbusMaster()
instruction
has a
ModbusOption
parameter that supports several different data types.
When data types use more than 1 register per value, the register order within the data value is
important. Some devices will swap the high and low bytes between registers. You can
compensate for this by selecting the appropriate
ModbusOption
.
Byte order is also important when communicating data over Modbus. Big Endian byte order is
the reverse of Little Endian byte order. It may not always be apparent which a device uses. If you
receive garbled data, try reversing the byte order. Reversing byte order is done using the
MoveBytes()
instruction. There is an example in CRBasic help for reversing the bytes order of
a 32-bit variable.
After properly reading in a value from a Modbus device, you might have to convert the value to
proper engineering units. With integer data types, it is common to have the value transmitted in
hundredths or thousandths.
Unsigned 16-bit integer
The most basic data type used with Modbus is unsigned 16-bit integers. It is the original Modbus
data type with 1 register per value. On the datalogger, declare your destination variable as type
Long. A Long is a 32-bit signed integer that contains the value received. Select the appropriate
ModbusOption
to avoid post-processing.
Signed 16-bit integer
Signed 16-bit integers use 1 register per value. On the datalogger, declare your destination
variable as type Long. A Long is a 32-bit signed integer that contains the value received . Select
the appropriate
ModbusOption
to avoid post-processing.
Signed 32-bit integer
Signed 32-bit integers require two registers per value. This data type corresponds to the native
Long variable type in Campbell dataloggers. Declare your variables as type Long before using
7. Communications Protocols
89
Summary of Contents for CR1000X
Page 1: ...Revision 02 21 2019 Copyright 2000 2019 Campbell Scientific ...
Page 2: ......
Page 4: ......
Page 6: ......
Page 8: ......
Page 16: ...Appendix A Glossary 176 Appendix B Index 214 Table of Contents viii ...
Page 192: ......