I am trying to read out the current time and date and display it in
the visualization.
And here's my code:
The counter is increased every 500ms,
so every 3s I want to read out the actual time and display
it at the visualization. The code runs in cyclic task with 500ms cycle time.
For some reasons, I only get in the first cycle a date and time.
The output dtu_getdt.xDone will not reset even
if dtu_getdt.Execute is set back from TRUE to FALSE.
According to the library description the outputs should be reseted upon a
falling edge. I'm not sure whether this is the reason for executing it only once or not.
Using Codesys 3.5 SP11 Patch4+
RaspberryPi Runtime
VAR
dtu_getdt : DTU.GetDateAndTime;
dtDate : DATE_AND_TIME;
END_VAR
Codepart:
IF i_count1 > 5 THEN
dtu_getdt.xExecute := TRUE;
dtu_getdt();
IF dtu_getdt.xError THEN
; // Fehlerbehandlung
END_IF
IF dtu_getdt.xDone THEN
// ohne Fehler abgeschlossen
dtDate := dtu_getdt.dtDateAndTime;
dtu_getdt.xExecute := FALSE;
END_IF
i_count1 :=0;
END_IF
i_count1 := i_count1+1;
Thanks for any comments. I'm not a very experienced user.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
dtu_getdt();
IF i_count1 > 5 THEN
dtu_getdt.xExecute := TRUE;
IF dtu_getdt.xDone THEN
// ohne Fehler abgeschlossen
dtDate := dtu_getdt.dtDateAndTime;
dtu_getdt.xExecute := FALSE;
i_count1 :=0;
END_IF
Hi
I am trying to read out the current time and date and display it in
the visualization.
And here's my code:
The counter is increased every 500ms,
so every 3s I want to read out the actual time and display
it at the visualization. The code runs in cyclic task with 500ms cycle time.
For some reasons, I only get in the first cycle a date and time.
The output dtu_getdt.xDone will not reset even
if dtu_getdt.Execute is set back from TRUE to FALSE.
According to the library description the outputs should be reseted upon a
falling edge. I'm not sure whether this is the reason for executing it only once or not.
Using Codesys 3.5 SP11 Patch4+
RaspberryPi Runtime
VAR
dtu_getdt : DTU.GetDateAndTime;
dtDate : DATE_AND_TIME;
END_VAR
Codepart:
IF i_count1 > 5 THEN
dtu_getdt.xExecute := TRUE;
dtu_getdt();
IF dtu_getdt.xError THEN
; // Fehlerbehandlung
END_IF
IF dtu_getdt.xDone THEN
// ohne Fehler abgeschlossen
dtDate := dtu_getdt.dtDateAndTime;
dtu_getdt.xExecute := FALSE;
END_IF
i_count1 :=0;
END_IF
i_count1 := i_count1+1;
Thanks for any comments. I'm not a very experienced user.
dtu_getdt();
IF i_count1 > 5 THEN
dtu_getdt.xExecute := TRUE;
IF dtu_getdt.xDone THEN
// ohne Fehler abgeschlossen
dtDate := dtu_getdt.dtDateAndTime;
dtu_getdt.xExecute := FALSE;
i_count1 :=0;
END_IF
END_IF
i_count1 := i_count1+1;
Thanks a lot !!