FB_NLinkFetch

FB_NLinkFetch 1:

This function block reads data from the third-party system and writes them to the local TwinCAT system (FETCH service).

VAR_IN_OUT

VAR_IN_OUT
    hLink : T_HNLINK;
END_VAR

hLink : Network connection handle. This is where the instance of the variable used for establishing the connection by the FB_NLinkOpen function block is transferred.

VAR_INPUT

VAR_INPUT
    devAddr     : BYTE := 2;(* Device address, MPI address of the remote component or its PROFIBUS address *)
    eArea       : E_NLinkArea := eNLinkArea_DB;(* PLC data area *)
    nDB         : WORD := 0; (* Data block number from which the data is read (DB, DX only). *)
    nOffset     : WORD := 0; (* Start byte/word address from which the data are taken to *)
    cbBuffer    : UDINT(0..MAX_NLink_DATALENGTH) := 0; (* Contains the max. number of destination bytes to be received *)
    pBuffer     : DWORD := 0; (* Contains the address of the destination buffer for the received data *)
    nOpt        : DWORD := 0; (* Additional options (reserved) *)
    bExecute    : BOOL; (* Rising edge at this input starts command execution *)
    tTimeout    : TIME := DEFAULT_ADS_TIMEOUT;(* Maximum time allowed for the execution of the command *)
END_VAR

devAddr: Device address, MPI address of the component on the third-party system.

eArea: PLC data area in the third-party system (inputs, outputs, data block etc.) from which data are to be read.

nDB: Data block number in the third-party system. Data are to be read from this data block (only relevant for access to data blocks and extended data blocks).

nOffset: The start byte address or word address from which data are to be read in the third-party system. Whether a byte or word address is to be specified depends on the type of external controller/protocol used and the data area to be accessed. Further information can be found here: Description of the PLC data area parameter values.

cbBuffer: Maximum number of data bytes to be read. The byte length is specified even for access to word addresses.

pBuffer: Pointer/address of the target data buffer in the TwinCAT system. The read data are written into this buffer. The address can be determined with the ADR operator. The target data buffer must not be smaller than the specified length of the data to be read.

nOpt: Reserved for future applications.

bExecute: The block is activated by a rising edge at this input.

tTimeout: Specifies the timeout that must not be exceeded on receipt of the command.

VAR_OUTPUT

VAR_OUTPUT
    bBusy   : BOOL;
    bError  : BOOL;
    nErrID  : UDINT;
    cbRead  : UDINT := 0; (* Number of recend realy returned data bytes *)
END_VAR

bBusy: When the function block is activated this output is set. It remains set until a feedback is received. While Busy = TRUE, no new command will be accepted at the inputs. Please note that it is not the command execution but the receipt of the command that is monitored.

bError: In the event of an error during the command transfer, this output is set once the bBusy output has been reset.

nErrID: Supplies the error number when the bError output is set.

cbRead: Number of successfully read data bytes.

Example:

See examples.

Requirements

Development environment

Target platform

PLC libraries to be linked

TwinCAT v2.11.0 Build > 1536

PC or CX (x86, ARM)

TcS5S7Comm.Lib