s7-1500 time and date display in Citect via OPCua

Hello Everyone,

I would like to display the recorded date and time in my plc on a Citect popup. 

My PLC variable is LDT datatype, how do i communicate this correctly to Citect via OPCua. I know I will have to make some conversions, but which datatype do i need in the PLC and which datatype do i need in Citect ? Could you please help me with this. I can't find any good documentation about this.

Thank you very much in advance. 

  • If you wish to send the information as a single variable then the best way is to convert the value in the PLC to the date/time format Citect natively uses: I believe it is a 32-bit (long) unsigned integer that counts seconds since 1-1-1970 (UTC). If this conversion is too complex, you could also consider transfering the individual elements as separate variables (i.e. year, month, day, hour, minute, second) and use those items in Citect or combine them with a Cicode function you create.
  • As i define a UDINT in the PLC and a ULONG in Citect, and my date is for example LDT#1970-01-01-00:00:01. So 1 second from 1970...
    My UDINT value in the PLC is 1_000_000_000 then my ULONG value in Citect is 1000000000. So it's the same. However when I use the TimeToStr() function in Citect, is shows 2001-09-09 03:46:40. Why is this, is this because of a byte swap?
  • Hi Roy,
    I don't know exactly how the LDT type is coded into bytes/words, but Citect expects a simple seconds count starting from 1-1-1970. So one second after new year's eve in 1970 should read 1, not 1000000000. From my experience with Siemens Step5 way in the past, there could be a byte swap involved as well as a word swap, but in your example it seems more likely that there has to be done some rearranging within the decimal notation, not byte-wise. Maybe you could test some more values and compare them with the numbers you get in Citect when using StrToDate() and/or StrToTime().

    Regards,
    Patrick
  • You probably should first divide your LDT value by 1000000000 because it counts in nanoseconds while Citect counts in seconds
  • Hi Patrick,
    Thanks for all your help. I was just figuring this out, i finally found the same problem with the nano seconds.