FB_EXCH: Exchange Function Block

Overview

The following graphic shows the pin diagram of the function block FB_EXCH:

G-SE-0033413.1.jpg

 

 

The M221 controller can communicate with a Modbus slave device or can send/receive messages in character mode (ASCII).

Twido and EcoStruxure Machine Expert - Basic provide the following functions for communication:

oEXCH instruction to transmit/receive messages

oExchange control function block (MSG) to control the data exchanges

The TwidoEmulationSupport library handles the communication with the function block FB_EXCH. This function block uses the function block SEN.SEND_RECV_MSG of the PLCCommunication library. This has the functionality to send and receive user-defined messages and waits for a response.

I/O Variables Description

The table describes the input variables of the function block in the TwidoEmulationSupport library:

Input

Data Type

Description

i_xExecute

BOOL

The functionality starts on rising edge.

i_xReset

BOOL

The current message transmission stops on rising edge and the communication reinitializes.

i_byPort

BYTE

[1..3] communication port

1 = Serial port 1

2 = Serial port 2

3 = Ethernet

i_pbyBuffer

POINTER TO BYTE

Pointer to send and/or receive buffer. The first 2 words are control words.

First 2 words: 4 control bytes:

1.Control byte length: The length byte contains the length of the transmission table in bytes (250 maximum), which is overwritten by the number of characters received at the end of the reception (if reception is requested).

2.Control byte command: [0..2]

0 = Transmission only

1 = Send/receive

2 = Reception only

3.Control byte SndBytePosDiscard: Byte position is not sent.

4.Control byte RcvBytePosDiscard: Received byte position is discarded.

i_uiLengthInByte

UINT

Length of send/receive buffer + 2 control words

i_xAsciiMode

BOOL

TRUE = ASCII mode configured.

FALSE = Modbus TCP configured.

The table describes the output variables of the function block in the TwidoEmulationSupport library:

Output

Data Type

Description

q_xBusy

BOOL

q_xBusy is set to TRUE while the function is ongoing.

q_xDone

BOOL

q_xDone is set to TRUE when the function is completed successfully.

q_xError    

BOOL

q_xError is set to TRUE when the function stops because of a detected error.

q_etExchDiag

ET_ExchDiag

Diagnostic code.

q_sMsg

STRING [80]

Diagnostic message.

The function block FB_EXCH has the following error codes:

G-SE-0032392.1.gif-high.gif