thiagoralves Show full post »
Bordini
Hello, I'm new to OpenPLC. I liked the post on the testRTC lib; I'm implementing a program and would like to use it, but I can not open the lib.
Quote 0 0
thiagoralves
It was made for a previous version of the editor. You can still open it if you target OpenPLC Editor shortcut to PLCOpenEditor.py instead of Beremiz.py
Quote 1 0
Krzysztof
Good morning,
I am new here and I'm under the impression of a great job!
I need to read the current system time and system tick. I have some problems. I run the program on Raspberry PI and read the register% ML1024 and% ML1025, but both values are 0. What am I doing wrong?
Quote 0 0
thiagoralves
How are you reading these registers? Your program is not using the Current_Time or Sys_Tick variables you created.
Quote 0 0
Krzysztof
Hello,
I implemented the fixes and launched the program in the simulator on the PC. Unfortunately, the problem still occurs.
Quote 0 0
thiagoralves
Two things: your DT variable format is wrong. It should be

DT#2018-11-1 15:06:00

with no dash (-) between the date and the time. That’s why you see a red line after it.

The second thing is that special functions are not supported on the simulator. They only work on the physical device, as this is a particular implementation of the runtime.
Quote 0 0
Krzysztof
When I removed dash, compiler returned error.
Quote 0 0
Krzysztof
So, I found discription of RTC
Quote:

(****************************************************************

RTC - Real-time clock

Q is a copy of IN.

When IN = FALSE, CDT is the current date and time as set by the
PLC driver.

When IN changes from FALSE to TRUE, PDT is stored. As long as IN is
TRUE, CDT is equal to PDT + the amount of time since PDT was loaded.

****************************************************************)

FUNCTION_BLOCK RTC
VAR_INPUT
IN : BOOL; (* 0 - current time, 1 - load time from


When set the RTC block without any parameters, the function block returns the current system data and time (in the documentation).
On simulation it work properly but on hardware not. Probably don't load system time on Runtime environment. Same situation like use %ML1024 register.
Quote 0 0
thiagoralves
This is a limitation of the runtime that I plan to fix later. That’s why I added the %ML1024 register so that you can still get current system time on the runtime. The %ML1024 register is a hack and is not available on the editor (that’s why on the simulation it is always showing zero), only in the actual hardware running the runtime. This register on the runtime holds the current EPOCH time in milliseconds. Then you just convert it to a Date Time variable and you have the same output as the RTC block you have in the simulation. Just keep in mind that the %ML1024 register already takes in consideration time zone and daylight saving time, so you don’t need to add or subtract hours depending on your time zone.
Quote 0 0