FB_WriteRealOnDelta

FB_WriteRealOnDelta 1:

Event-driven writing of a variable of type REAL.

The FB_WriteRealOnDelta() function block checks cyclically whether the value at the fSignal input has changed. The cycle time within which the check is carried out is specified by the parameter tCycleTime. If 0 seconds is given for tCycleTime, the input signal is examined during every PLC cycle. If the comparison establishes that the current value is greater than fUpperLimit or lower than the value fLowerLimit, then the value is sent to the ADS device that is to be specified. The receiver is addressed by means of the AMS-NetId and the port number (see also ADS Device Identification). The position within the receiver is specified by the index group/index offset or by the symbol name. Usually this is the input image or the flags area.

The internal representation of floating-point numbers differs according to the hardware being used. Whereas Intel use the "little-endian" format, Motorola-based hardware employs the "big-endian" format. The input variable bSwapLowHighWord can be used to make the necessary adjustment to be able to exchange floating point numbers. This is necessary, for instance, if floating point numbers need to be exchanged between the TwinCAT PLC running on a PC and a BC9000.

If the bEnable input is set to FALSE, no further signal transmission is carried out.

VAR_INPUT

bEnable          : BOOL := FALSE;
sNetId           : T_AmsNetId;
nPort            : T_AmsPort := AMSPORT_R0_PLC_RTS1;
nIdxGrp          : UDINT;
nIdxOffs         : UDINT;
sVarName         : STRING;
fSignal          : REAL;
fLowerLimit      : REAL;
fUpperLimit      : REAL;
tCycleTime       : TIME := t#0s;
bSendNow         : BOOL;
bSwapLowHighWord : BOOL := FALSE;

bEnable: Enable block.

sNetId: AMS-NetId of the ADS device to which the value is to be transmitted.

nPort: AMS- port number of the ADS device to which the value is to be transmitted.

nIdxGrp: Index group within the ADS device into which the value is to be transmitted.

nIdxOffs: Index offset within the ADS device into which the value is to be transmitted.

sVarName: Symbol name within the ADS device into which the value is to be transmitted.

fSignal: Variable whose value is to be transmitted.

fLowerLimit: Lower limit value.

fUpperLimit: Upper limit value.

tCycleTime: Cycle period in which the input signal is examined to see that it has changed.

bSendNow: The value is transmitted immediately in response to a rising edge.

bSwapLowHighWord: The least significant WORD and the most significant WORD are swapped.

VAR_OUTPUT

bBusy          : BOOL;
fLastSignal    : BYTE;
bError         : BOOL;
nErrorId       : UDINT;
nErrorCnt      : UDINT;

bBusy: Transmission is active.

fLastSignal: Most recently transmitted value.

bError: An error occurred during the transmission.

nErrorId: Error number if an error has occurred.

nErrorCnt: Number of transmission attempts that have returned faults.

Requirements

Development environment

Target system

Required libraries

TwinCAT 2.11 R3/x64

PC/CX, BX or BC

TcDataExchange-Bibliothek from V1.0.0