Example: FB_SMIVenetianBlind

Example: FB_SMIVenetianBlind 1:

Venetian blind control.

Download PLC export file

VAR_INPUT

bUp             : BOOL;
bDown           : BOOL;
bStop           : BOOL;
bSwitchOverUp   : BOOL;
bSwitchOverDown : BOOL;
tSwitchOverTime : TIME := t#400ms;
bStep           : BOOL;
iAngle          : INT := 0;
bSetPosition    : BOOL;
bySetPosition   : BYTE := 0;
bSafetyPosition : BOOL;
tPositionRead   : TIME := t#1s;
dwAddr          : DWORD := 0;
eAddrType       : E_SMIAddrType := eSMIAddrTypeAddress;
dwAddrOption    : DWORD := 0;
dwMasterDevAddr : DWORD := 0;
dwOptions       : DWORD := 0;

bUp: driving upwards. Starts with creep velocity and raises to rapid velocity.

bDown: driving downwards. Starts with creep velocity and raises to rapid velocity.

bStop: stops the blind.

bSwitchOverUp: stepping the blind up. If the signal remains present for longer than tSwitchOverTime, the blind remains latched.

bSwitchOverDown: stepping the blind down. If the signal remains present for longer than tSwitchOverTime, the blind remains latched.

tSwitchOverTime: gives the time for which the bSwitchOverUp and bSwitchOverDown inputs must remain asserted before the blind gets latched. If the value is 0, the blind is latched immediately.

bStep: moves the blind to the specified position.

iAngle: angle (-510° ... +510°) to which the blind is to be moved, after a rising edge has been applied to input bStep. Negative value corresponds to move up, positive value to move down.

bSetPosition: moves the blind to the position specified under input bySetPosition.

bySetPosition: position in percentage to which the blind is to be moved, after a rising edge has been applied to input bSetPosition. 0 % corresponds to fully up, 100 % to fully down.

bSafetyPosition: the safety position is approached. It is not possible to operate the blind while this input is set.

tPositionRead: interval in which the current position is read from the SMI motor if no positioning commands are processed.

dwAddr: manufacturer code (0-15), address of a device (0-15), bit field (16 bits) for the group addressing or slave ID (32-bit key ID).

eAddrType: defines whether the dwAddr input is to be evaluated as a manufacturer code, the address of a device, for group addressing or as a slave ID.

dwAddrOption: if the SMI device is addressed by slave ID (eAddrType = eSMIAddrTypeSlaveId), then the manufacturer code must be specified via this input.

dwMasterDevAddr: address (0-15) of the SMI motor of which the current position is to be read when eAddrType != eSMIAddrTypeAddress.

dwOptions: reserved for future expansions.

VAR_OUTPUT

bBusy           : BOOL;
bError          : BOOL;
udiErrorId      : UDINT;
byActualPosition: BYTE;

bBusy: this output is set as soon as the function block processes a command and remains active until the command has been processed.

bError: this output is switched to TRUE as soon as an error occurs during the execution of a command.

udiErrorId: contains the command-specific error code of the most recently executed command.

byActualPosition: the position read out in percentage. 0 % corresponds to the upper final position and 100 % to the lower final position.

VAR_IN_OUT

stCommandBuffer     : ST_SMICommandBuffer;

stCommandBuffer: reference to the structure for communication (buffer) with the FB_KL6831KL6841Communication() block.

Requirements

Development environment

Target system

Required libraries

TwinCAT 2.11 R3/x64 from build 2238

PC/CX, BX or BC

TcSMI library from V1.0.0