Kuhnke Electronics Instruction Manual

Kuhnke Electronics Instruction Manual Kuhnke Electronics Instruction Manual

17.02.2013 Views

Remanent Data PROGRAM operating time � Operating hour counter: This program compiles a count of the operating time using elements from SystemData. xrdata.SysVars.secs := xrdata.SysVars.secs +1 ; IF xrdata.SysVars.secs >= 60 THEN END_IF xrdata.SysVars.secs := 0; xrdata.SysVars.mins := xrdata.SysVars.mins +1 ; IF xrdata.SysVars.mins >= 60 THEN END_IF xrdata.SysVars.mins := 0; xrdata.SysVars.hors := xrdata.SysVars.hors + 1 ; IF xrdata.SysVars.hors >= 24 THEN END_IF PROGRAM PLC_PRG VAR END_VAR VAR RETAIN END_VAR xrdata.SysVars.hors := 0; xrdata.SysVars.days := xrdata.SysVars.days + 1 ; PLC_PRG Checks if the extraremanent data are OK. Run "Clear" to remove the data if they are not OK. noof_SystemStarts counts the number of system starts. Rema1 is a Retain variable. Use it to check the difference to the extraremanent data. flag: BOOL := TRUE ; running: UDINT; Start_OK: BOOL; Clear: BOOL; Rema1: UDINT; 122 E 700 GB

Start_OK := CheckXREMDATA(Clear); IF flag AND Start_OK THEN END_IF xrdata.SysVars.noof_SystemStarts := Rema1:=Rema1+1; flag := FALSE; IF Start_OK THEN (* The actual main program goes here. *) END_IF running:=running +1; FUNCTION CheckXREMDATA : BOOL VAR_INPUT END_VAR VAR END_VAR flag1:BOOL; Remanent Data xrdata.SysVars.noof_SystemStarts+1; CheckXREMDATA: Use the "magic words" to check if the remanent data are OK. If the contents of the "magic words" changed they are overwritten with the defined bit pattern. Depending on the value of the "clear" input variable, the extraremanent structures can be removed. pSysVars: POINTER TO DWORD; pExtrarema02: POINTER TO DWORD; Size_SysVars: UINT; Size_Extrarema02: UINT; i: INT; pByte: POINTER TO ARRAY[0..4095] OF BYTE; 123

Start_OK := CheckXREMDATA(Clear);<br />

IF flag AND Start_OK THEN<br />

END_IF<br />

xrdata.SysVars.noof_SystemStarts :=<br />

Rema1:=Rema1+1;<br />

flag := FALSE;<br />

IF Start_OK THEN<br />

(* The actual main program goes here. *)<br />

END_IF<br />

running:=running +1;<br />

FUNCTION CheckXREMDATA : BOOL<br />

VAR_INPUT<br />

END_VAR<br />

VAR<br />

END_VAR<br />

flag1:BOOL;<br />

Remanent Data<br />

xrdata.SysVars.noof_SystemStarts+1;<br />

CheckXREMDATA:<br />

Use the "magic words" to check if the remanent data are<br />

OK. If the contents of the "magic words" changed they are<br />

overwritten with the defined bit pattern. Depending on the<br />

value of the "clear" input variable, the extraremanent<br />

structures can be removed.<br />

pSysVars: POINTER TO DWORD;<br />

pExtrarema02: POINTER TO DWORD;<br />

Size_SysVars: UINT;<br />

Size_Extrarema02: UINT;<br />

i: INT;<br />

pByte: POINTER TO ARRAY[0..4095] OF BYTE;<br />

123

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!