With CoDeSys there are libraries SysLibRtc.lib or SysLibTime.lib to get the real time clock.
I think with your controller you must have the same libraries.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
for nice clocks have a look at w www.oscat.de w
lots of functions
example:
(*
version 1.2 8. mar. 2009
programmer hugo
tested by oscat
DT_SIMU simulates a real time clock and can be adjusted to different speeds
it can also be used in simulation to simulate a real time clock.
the peed of the clock can be increased or decreased to debug timers.
with the input start a start date-time can be specified.
I tried using SysLibTime, but had issues (the time stayed at Jan 1, 1970, 12:00 AM).
So, I decided to use the time string format. Just make a rectangle in your visualization, and set the text string to something like mine:
Time:
%t%I:%M:%S %p
Date:
%t%m/%d/%Y
Unfortunately, %I in the time string gives a leading zero for the hour, but I couldn't figure out how to remove it. For more info about the time string, you can click the ? button next to the Text field.
Edit: Found out that SysLibTime doesn't work in Simulation. It did work on my Wago, but only when the program was running. %t strings, however, will always work, even when the program isn't running.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Is it possible to display the real time clock of my 750-849?
thanks
With CoDeSys there are libraries SysLibRtc.lib or SysLibTime.lib to get the real time clock.
I think with your controller you must have the same libraries.
for nice clocks have a look at w www.oscat.de w
lots of functions
example:
(*
version 1.2 8. mar. 2009
programmer hugo
tested by oscat
DT_SIMU simulates a real time clock and can be adjusted to different speeds
it can also be used in simulation to simulate a real time clock.
the peed of the clock can be increased or decreased to debug timers.
with the input start a start date-time can be specified.
)
( @END_DECLARATION := '0' )
( read system timer *)
tx := T_PLC_MS();
tc := REAL_TO_DWORD(DWORD_TO_REAL(tx - last) * speed);
IF NOT init THEN
init := TRUE;
DTS := Start;
tc := 0;
last := tx;
ELSIF SPEED = 0.0 THEN
DTS := DWORD_TO_DT(DT_TO_DWORD(DTS) + 1);
ELSIF tc >= 1000 THEN
td := (tc / 1000) * 1000;
DTS := DTS + DWORD_TO_TIME(td);
last := last + REAL_TO_DWORD(DWORD_TO_REAL(td) / speed);
END_IF;
(* revision history
hm 11. sep. 2008 rev 1.0
original version
hm 16. nov 2008 rev 1.1
added type conversions for compatibility reasons
hm 8. mar. 2009 rev 1.2
added increment by cycle mode
*)
END_FUNCTION_BLOCK
just one for you to get the idea the rest is at oscat
you can have it displayed with lines or with numbers.
if needed more help just ask.
I tried using SysLibTime, but had issues (the time stayed at Jan 1, 1970, 12:00 AM).
So, I decided to use the time string format. Just make a rectangle in your visualization, and set the text string to something like mine:
Time:
%t%I:%M:%S %p
Date:
%t%m/%d/%Y
Unfortunately, %I in the time string gives a leading zero for the hour, but I couldn't figure out how to remove it. For more info about the time string, you can click the ? button next to the Text field.
Edit: Found out that SysLibTime doesn't work in Simulation. It did work on my Wago, but only when the program was running. %t strings, however, will always work, even when the program isn't running.