FB_ReadVar: Read Data Function Block
The following graphic shows the pin diagram of the function block FB_ReadVar:
The function block FB_ReadVar reads data from an external device using the Modbus SL or Modbus TCP protocol.
The table describes the input variables of the function block in the TwidoEmulationSupport library:
Input |
Data type |
Description |
---|---|---|
i_xExecute |
BOOL |
The function is executed on the rising edge of this input. NOTE: When ixExecute is set to TRUE at the first task cycle in RUNNING after a cold or warm reset, the rising edge is not detected. |
i_xAbort |
BOOL |
Stops the ongoing operation at the rising edge. |
i_iLink |
INT |
Indicates the port used to communicate. o1 = Serial port 1 o2 = Serial port 2 o3 = Ethernet / Modbus TCP |
i_iId |
INT |
Device identifier of targeted external device: oSerial line slave address: 1...247 or oEthernet index: 1...16 (Depends on the link configuration). |
i_iTimeout |
INT |
Set the maximum time to wait to receive a response from the modem. Specified in ms. A value of 0 means no timeout is enforced. |
i_etObjType |
SEN.ObjectType |
Value of enumerated data type (SEN.ObjectType) contains the object types that are available for writing: oMW: Read holding register (16 bit) oI: Read digital input (1 bit) oQ: Read coils (1 bit) oIW: Read input register (16 bits) |
i_diFirstObj |
DINT |
Address of the first object from which values are read. |
i_iQuantity |
INT |
Number of objects to read. |
i_pbyBuffer |
POINTER TO BYTE |
Address of the buffer in which read object values are stored. |
i_astRemoteDevices |
ARRAY [1..Gc_uiRemoteAddressTableLen] OF ST_RemoteDevice |
Contains the list of remote device addresses for Modbus TCP communication. |
The table describes the output variables of the function block in the TwidoEmulationSupport library:
Output |
Data type |
Description |
---|---|---|
q_xDone |
BOOL |
q_xDone is set to TRUE when the function is completed successfully. |
q_xBusy |
BOOL |
q_xBusy is set to TRUE while the function is ongoing. |
q_xAborted |
BOOL |
q_xAborted is set to TRUE when the function is stopped with the i_xAbort input. |
q_xError |
BOOL |
q_xError is set to TRUE when the function stops because of a detected error. |
q_etCommError |
SEN.CommunicationErrorCodes |
q_etCommError contains the value of communication error codes SEN.CommunicationErrorCodes. |
q_etOperError |
SEN.OperationErrorCodes |
q_etOperError contains the value of operation error codes SEN.OperationErrorCodes. |