Function Description
The EXCH_QX
function is used to perform data transfers
(Modbus) to and from Modbus slaves connected
to a Modicon X80 serial communication module
(BMX NOM) located in an EIO drop.
The additional parameters EN
and ENO
can be configured.
The communication function blocks use one data transaction path and require multiple cycles to complete an operation. The number of transaction paths available by module and by MAST cycle depends on the communication port used:
Modbus Plus embedded port or NOM modules support up to 4 blocks at the same time.
TCP/IP Ethernet embedded port support up to 4 blocks at the same time.
TCP/IP Ethernet NOE, NOC, and 140 CRP 312 00 modules support up to 16 blocks at the same time.
More communication function blocks may be programmed on the same communication port. However, a communication block exceeding the maximum number on that port is not serviced until one of the transaction paths is available. Then, the next block on the same port becomes active and begins using an available path.
FBD Representation
Representation:

LD Representation
Representation:

IL Representation
Representation:
CAL EXCH_QX_Instance (ENABLE:=ExchQxEnable, ABORT:=ExchQxAbort,
ADDR:=ModuleAddress, SEND_BYTE:=NbBytesToSend, SEND_BUFFER:=ExchQxDataSource,
DONE=>ExchQxSuccessfull, ACTIVE=>ExchQxActive, ERROR=>ExchQxFaulty,
STATUS=>ErrorCode, REC_BYTE=>NbBytesReceived, REC_BUFFER=>ReceivedBuffer)
ST Representation
Representation:
EXCH_QX_Instance (ENABLE:=ExchQxEnable, ABORT:=ExchQxAbort,
ADDR:=ModuleAddress, SEND_BYTE:=NbBytesToSend, SEND_BUFFER:=ExchQxDataSource,
DONE=>ExchQxSuccessfull, ACTIVE=>ExchQxActive, ERROR=>ExchQxFaulty,
STATUS=>ErrorCode, REC_BYTE=>NbBytesReceived, REC_BUFFER=>ReceivedBuffer)
Parameter Description
The following table describes the input parameters:
Parameter |
Type |
Comment |
---|---|---|
|
|
Set to 1 to perform data transfers. |
|
|
Set to 1 to abort the current operation. |
|
|
Array containing the Modbus slave address, result of ADDMX function. |
|
|
Number of bytes to be sent. |
|
|
Source data field. A data structure must be declared as a located variable for the source file. |
The following table describes the output parameters:
Parameter |
Type |
Comment |
---|---|---|
|
|
Set to 1 when the execution of the function is completed successfully. |
|
|
Set to 1 when the execution of the function is in progress. |
|
|
Set to 1 if an error is detected by the function block. |
|
|
Provides the error code if an error is detected by the function block. |
|
|
Number of bytes to be received from the Modbus slave. |
|
|
Received data (For the file to be read a data structure must be declared as a located variable.) |
ST Example
(* Example:
we want to read the %MW1000 on slave number 5 (a M340 PLC for instance)
wired to channel 0 of the NOM in
slot 2 of which IP address is 192.168.10.17,
the Quantum CRP is in slot 5 for instance.
First of all you should declare in
the data editor the following variables:
data_to_send as an ARRAY [0..4] OF BYTE (or more if
you want to send more bytes)
bytes_to_send as a WORD
slave_addres
as a STRING[40]
received_data
as an ARRAY [0..3] OF BYTE (or more if you need)
enable_sending as a BOOL
and you should
create an instance of EXCH_QX EFB named for instance EXCH_QX_6 *)
(* initialize the data to send *)
data_to_send[0]:=16#03; (* Modbus function
code read Holding register *)
data_to_send[1]:=16#03; (* MSB of the first register address *)
data_to_send[2]:=16#E8; (* LSB of the
first register address, 16#03E8 = 1000*)
data_to_send[3]:=16#00; (* MSB of the quantity of registers
to read *)
data_to_send[4]:=16#01;
(* LSB of the quantity of registers to read *)
(* initialize the number of byte to send
*)
bytes_to_send:=5;
(* initialize the address of
the slave *)
slave_address:='1.5.1{192.168.10.17}\\0.2.0.5';
(* CRP slot 5, Drop address 192.168.10.17,
NOM in slot 2 of main drop rack. *)
EXCH_QX_6 (ENABLE := enable_sending,
ADDR := addmx(slave_address),
SEND_BYTE := bytes_to_send,
SEND_BUFFER := data_to_send,
REC_BUFFER => received_data);
(* to start the EFB EXCH_QX_6 set enable_sending,
then
received_data[0] will
contain the function code sent (3)
received_data[1] will contain the number of bytes received (2)
received_data[2] and received_data[3]
will contain the value of %MW1000 from the slave number 5*)