FB_S7CommCyclicRequest

FB_S7CommCyclicRequest 1:

Cyclic processing (read/write) of data points of an S7 communication connection can be configured with the function block FB_S7CommCyclicRequest. The output bError states whether the request was successfully carried out. Any errors occurring at the time of the request are displayed via the output sErrorTxt and nErrorID.

Syntax

Definition:

VAR_INPUT
    bExecute        : BOOL;
    nCycleTimeMs    : UDINT;
END_VAR
VAR_OUTPUT
    bError          : BOOL;
    sErrorTxt       : STRING;
    nErrorId        : WORD;
    bBusy           : BOOL;
    nReceiveCounter : BYTE;
END_VAR

FB_S7CommCyclicRequest 2: Inputs

Name

Data type

Description

bExecute

BOOL

The function block is executed by a rising edge at this input.

nCycleTimeMs

UDINT

Cycle time to be used in [ms].

FB_S7CommCyclicRequest 3: Outputs

Name

Data type

Description

bError

BOOL

Switches to TRUE if an error occurs during execution.

sErrorTxt

STRING

Contains the error text in the event of an error.

nErrorId

WORD

Outputs an error code in the event of an error.

bBusy

BOOL

TRUE until the function block has executed a command. As long as bBusy = TRUE, the function block will not accept any new commands.

nReceiveCounter

BYTE

Counter for responses received by the S7 Controller. This can be used to check whether a response was received in the cyclic processing.

FB_S7CommCyclicRequest 4: Methods

Name

Definition location

Description

AddReadVar

Local

Adds a read command for a particular S7 data point to the request.

AddReadBit

Local

Adds a read command for a particular BIT-type S7 data point to the request.

AddReadString

Local

Adds a read command on a STRING-type S7 data point to a request.

AddWriteVar

Local

Adds a write command for a particular S7 data point to the request.

AddWriteBit

Local

Adds a write command for a particular BIT-type S7 data point to the request.

AddWriteString

Local

Adds a write command on a STRING-type S7 data point to a request.

RemoveRead

Local

Removes a variable from a read request.

RemoveWrite

Local

Removes a variable from a write request.

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (x86, x64)

Tc3_S7Comm (Communication)