FB_NLinkWrite

FB_NLinkWrite 1:

This function block sends data from the local TwinCAT system to the third-party system (WRITE 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 to which the data is written (DB, DX only) *)
    nOffset     : WORD := 0; (* Start byte/word address to which the data is send *)
    cbBuffer    : UDINT(0..MAX_NLink_DATALENGTH) := 0;(* Contains the number of source bytes to be send *)
    pBuffer     : DWORD := 0; (* Contains the address of the source buffer containing the data to be send *)
    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.) to which data are to be written.

nDB: Data block number in the third-party system. Block in which data are to be written (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 written to 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 byte length of the data to be transferred from the source data buffer in the local TwinCAT system to the third-party system. The byte length is specified even for access to word addresses.

pBuffer: Pointer/address for the source data buffer. Data from this buffer are transferred to the third-party system. The address can be determined with the ADR operator. The source data buffer must not be smaller than the specified length of the data to be sent.

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;
    cbWrite : UDINT := 0;(* Number of successfull written 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.

cbWrite: In case of success: Number of successfully written 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