Setup
Modbus/TCP requires an Ethernet connection between master and slave. Modbus/TCP also requires that all
slaves communicate with their masters over port 502. See the IH command to setup port communication for
the RIO.
Raw Modbus Send/Receive
Firmware revisions Rev D and newer support raw Modbus read/write functionality. This provides the user
with the most flexibility for interfacing to modbus devices. Specifying a -1 for the Modbus function code
enables the raw read/write of Modbus functions.
See the MB command in the RIO Command Reference for further details.
Modbus Read/Write to Array Table
Firmware revisions Rev D and newer support the ability to read from and write to array data on the RIO. Up
to 1000 elements are available in the RIO-471x2 and 400 in the RIO-47xx0. Each element is accessible as a
16 bit unsigned integer (Modbus register 1xxx) -OR- as a 32 bit floating point number (Modbus registers
2xxx).
See the ME command in the RIO Command Reference for further details.
Sending Modbus Packets
The RIO programming language provides 3 ways of issuing Modbus packets as a master.
1) Issue the MB command of type Mbh = -1,len,array[]
This Galil command allows the user complete control over the creation of their Modbus packet.
len is the number of bytes to be included in the packet, and array[ ] is the name of the array
containing the Modbus packet. Each element of array[] may contain only one byte, and array[] must
contain the entire Modbus packet, including transaction identifiers, protocol identifiers, length field,
Modbus function code, and data specific to that function code.
2) Issue the MB command of type Mbh = addr, x, m, n, array[]
This Galil command allows the user to send a Modbus command easily by allowing the user to
select a few key parameters, and allowing the controller to do the rest. addr is the Unit ID field,
which if not set, Galil will automatically set to the value of the handle the communication is over
(Handle A=$01, B=$02, etc). Also, as a slave the RIO ignores the Unit ID field. x is the function
code of the Modbus command. m is the address at which to begin reading or writing. n is either the
number of coils or the number of registers to read/write. array[] is the array in which data from a
read gets stored or where data to write is stored. See individual function code descriptions in the
command reference for specifics of this command.
3) Issue another Galil command that supports Modbus
The following Galil commands support Modbus, and are an easy way to use the Modbus protocol:
SB,CB,AO,OB,@IN[],@OUT[],@AN[],@AO[]. The I/O number (variable) to use with these
commands when using Modbus can be calculated as follows:
I/O Number = (HandleNum*1000) + (bitNum)
Modbus Exceptions
An RIO configured as a slave will return an exception response if it receives an invalid request (e.g. An
invalid function code, or a communication error). As a class 1 Modbus device the RIO-47xxx can respond
with exception codes $01 or $02. Exception code $01 is returned when a request referencing an Illegal
RIO-47xxx
Chapter 3 Communication
●
15
Содержание RIO-47120
Страница 2: ......
Страница 93: ...RIO Dimensions RIO 471xx Units in centimeters RIO 47xxx Appendix 87...
Страница 94: ...RIO 472xx Units in millimeters 88 Appendix RIO 47xxx...
Страница 107: ...Internal 56 64 Zero Stack 53 RIO 47xxx Index 101...