For a project I need to find out if time is before or after 11 AM.
I tried to read the time with DTStructureGetTime and compare the hour element of the DTStructure with 11.
The variables:
VAR
dpgIst11Uhr : BOOL; (*Einspeisen darf ab 11 Uhr beginnen*)
dpgDTStructureGetTime_1 : DTStructureGetTime; (*Reads the local time from the target system in DTStructure format.*)
dpgCurrentDateTime : DTStructure; (*Aktuelle Uhrzeit der SPS als DTStructure*)
status : UDINT;
END_VAR
The code in an cyclic module:
dpgDTStructureGetTime_1.enable := TRUE;
status := dpgDTStructureGetTime_1.pDTStructure := ADR(dpgCurrentDateTime); // aktuelles Data & Time ist in CurrentDateTime Data type DTStructure
IF dpgCurrentDateTime.hour >= 11 THEN
dpgIst11Uhr := TRUE;
END_IF;
Unfortunately, the structure dpgCurrentDateTime is empty, all elements are 0.
Additional, status must be as UDINT declared not as UINT as described in AS Help.
PLC: X20CP0482
AS 4.11
Any ideas what I am doing wrong?
Walter