7 example program – BECKHOFF CX210000x4 User Manual
Page 23
Product overview
2.7
Example Program
The following PLC program shows by way of an example how the three function blocks are used for the
power supply unit.
PROGRAM MAIN
VAR
nCounter AT %Q*: USINT;
(* navi switch *)
bUp AT %I* : BOOL;
bDown AT %I* : BOOL;
bLeft AT %I* : BOOL;
bRight AT %I* : BOOL;
bEnter AT %I* : BOOL;
bToggle AT %I* : BOOL;
nIn : USINT;
eNaviSwitchCx2 : E_CX2100_NaviSwitch;
(* get display *)
fbGetDisplayText : FB_CXGetTextDisplayUSB;
bExecuteRead : BOOL;
eModeRead : E_CX2100_DisplayModesRd;
nCursorMode : USINT;
nBacklight : USINT;
bReadCursorInfoReq : BOOL := TRUE;
bReadBacklightReq : BOOL := TRUE;
bReadLine1Req : BOOL;
bReadLine2Req : BOOL;
bReadLinesReq : BOOL := TRUE;
(* set display *)
fbSetDisplayText : FB_CXSetTextDisplayUSB;
bExecuteWrite : BOOL;
eModeWrite : E_CX2100_DisplayModesWr;
bCursorOnReq : BOOL;
bCursorOffReq : BOOL;
bBlinkCursorOnReq : BOOL;
bBlinkCursorOffReq : BOOL;
bBacklightOnReq : BOOL;
bBacklightOffReq : BOOL;
bClearDisplayReq : BOOL;
bWriteLine1Req : BOOL;
bWriteLine2Req : BOOL;
bWriteLinesReq : BOOL;
bSetCursorPosXReq : BOOL;
bSetCursorPosYReq : BOOL;
bSetCursorPosXYReq : BOOL;
(* common *)
nCursorPosX : USINT;
nCursorPosY : USINT;
sLine1 : STRING;
sLine2 : STRING;
bBusy : BOOL;
bError : BOOL;
nErrorID : UDINT;
END_VAR
nCounter := nCounter + 1;
nIn.2 := bUp;
nIn.3 := bDown;
nIn.4 := bLeft;
nIn.5 := bRight;
nIn.6 := bEnter;
(* get navi switch *)
eNaviSwitchCx2 := F_CXNaviSwitchUSB(nIn);
(* prepare get display mode *)
IF (eModeRead = eCX2100_DisplayNoActionRd) AND (eModeWrite = eCX2100_DisplayNoActionWr) THEN
IF bReadCursorInfoReq THEN
eModeRead := eCX2100_ReadCursorInfo;
bExecuteRead := TRUE;
ELSIF bReadBacklightReq THEN
eModeRead := eCX2100_ReadBackLight;
bExecuteRead := TRUE;
CX210000x4
23
Version 1.0