Coils; Data Types; Unsigned 16-Bit Integer - Campbell CR300 Series Product Manual

Compact datalogger
Hide thumbs Also See for CR300 Series:
Table of Contents

Advertisement

19.2.7.2 Coils

Discrete digital I/O channels in Modbus are referred to as coils. The term coil has its roots in
digital outputs operating solenoid coils in an industrial environment. Coils may be read only or
read/write. A read only coil would be a digital input. A read/write coil is used as an output. Coils
are read and manipulated with their own function codes, apart from the registers. Many modern
devices do not use coils at all.
When working with coils, the data logger 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.

19.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
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 data logger, 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.
ModbusClient()
instruction
19. Communications protocols     117

Advertisement

Table of Contents
loading

Table of Contents