www.beck-ipc.com
www.beck-ipc.comwww.beck-ipc.com  | ImprintImprint
FAQFAQ  | SearchSearch  |
  |LoginLogin

current time

Questions and discussions about the CoDeSys editor V2.3.

current time

Postby alex87 » 26.01.2012, 21:01

What is the quickest way to have/get current time&date in codesys? I have EK61, using IEC_Full_platform_CM. Any existing project/example should be very helpful.

regards, alex

Re: current time

Postby berb » 27.01.2012, 10:24

Hallo,

you find this function in the SysLibTime.lib.

Regards,
i.A. Günter Berberich

Re: current time

Postby alex87 » 27.01.2012, 12:20

OK, good but I get one tiny error:

Error:Task configuration (5): The task entry 'PLC_PRG(ActualTime:=);' contains invalid parameter

my declaration:
VAR_IN_OUT
ActualTime: SysTime64;
END_VAR

Program:

CurTime(SystemTime:=ActualTime);

Why?

regards

Re: current time

Postby berb » 30.01.2012, 11:13

Hallo,
here is an example program from the Time Lib.
please SySLibTimetest.txt copy in SysLibTimeTest.pro

Regards,
Günter Berberich
Attachments
SySLibTimeTest.txt
(47.02 KiB) Downloaded 1651 times

Re: current time

Postby alex87 » 01.02.2012, 16:24

Thanx mr berb.,

for the example, but i can not open it because of library issues, so i exported the code to other project, but still missing the part about exact task configuration.

I would be glad,If you just explain me how did you set the tasks.

Also I don't know where to put in correct time to calculate it. I get time OK, but from year 2006.

tnx alex

Re: current time

Postby berb » 02.02.2012, 12:10

Hallo,
here is an new example program from the Time Lib.
please SySLibTimetest.txt copy in SysLibTimeTest.pro
Regards,
Günter Berberich
Attachments
SySLibTimeTest.txt
(26.11 KiB) Downloaded 1029 times

Re: current time

Postby alex87 » 02.02.2012, 12:57

Sorry for bothering you but i see no difference between these two project you've sent. I still don't se task configuration, because library issues (I dont have same date/version of libs that you have) delete part of codesys PLC configuration and task configuation.

I still can't figure out where to in-put/set current time in this example.

regards, alex

Re: current time

Postby Paul Elgershuizen » 03.02.2012, 10:24

Hello Alex87,

To read the current time, you have to declare the following instances:
- t64CurrTime : Systime64 := (ulLow:=0, ulHigh:=0); (* The structure containing the time *)
- insTime : CurTime; (* Instance of the function block *)

NOTE : The names are an exmple includive null init.

In your code you should use a call like:
- insTime (SystemTime:= t64CurrTime);
to get the actual time.

To set the time, you have to implement something yourself. This is dependent on the used interfaces and hardware used:
- If you have an Ethernet connection, you can set the systemclock at powerup by reading the time via SNTP.
- If you have a Real-Time-Clock chip in your Hardware integrated, you need to write an external CoDeSys Library to support the chip. Here you can add IEC-Functions to set and get the time etc.
If you have both, it is advised to use SNTP at boot time to set and synchronize the RTC and Systemclock.

For an example to set the Systemclock by using SNTP, is referred to the BECK-IPC Downloadcenter. Search for
"SNTP". Here you find an Application note for I2C RTC and a Software Archive with an example for setting the system time with SNTP from a NTP Server (Archive: tcpip_V3.04.zip)

regards,

Re: current time

Postby Ruben Fuchs » 17.04.2012, 21:32

Perhaps you could take a look at the Codesys PLC example including a Real Time clock example for Codesys for a I2C RTC RICOH RS5C372A

http://www.beck-ipc.com/de/download/loa ... AN_PLC.zip
http://www.beck-ipc.com/de/download/loa ... AN_PLC.pdf
-------------------------------------

Ruben Fuchs
Beamter und Beck-IPC Anhänger

Return to CoDeSys Editor V2.3


Who is online

Users browsing this forum: No registered users and 0 guests


cron