Minor bug in RTC_2 FB

Begonnen von Strucc, 19. Mai 2011, 07:51:07

Vorheriges Thema - Nächstes Thema

0 Mitglieder und 1 Gast betrachten dieses Thema.

Strucc

Hi,

While implementing SNTB based time synchronization I found a minor bug with the DST offset calculation:

Line 9-10:
(* calculate time offset and set ldt output *)
LDT := DWORD_TO_DT(DT_TO_DWORD(UDT) + INT_TO_DWORD(ofs + BOOL_TO_INT(DSO)) * 60);


Should be:
(* calculate time offset and set ldt output *)
LDT := DWORD_TO_DT(DT_TO_DWORD(UDT) + INT_TO_DWORD(ofs + (BOOL_TO_INT(DSO) *60)) * 60);


This was within library for CoDeSys 2.

By the way thanks for all the ideas and work within these libraries: really great and useful stuff. I'm looking forward to contribute.

P.Peter

Strucc

#1
By the way, it  could be more correct to reuse the UTC_TO_LTIME function:

(* calculate time offset and set ldt output *)
LDT := UTC_TO_LTIME(UDT, DSO, OFS);