I’m looking to get data through time and the time logging seems pretty hard in X90
There is a TIME data type, but I can find no function to fill it.
So I try to get time via DATE_AND_TIME with the function DTGetTime, but this function doesn’t seem to work.
So I switch DTStructure and this time it works.
There is a function that returns TIME data types ?
There is a way to fill a TIME data type without creating my own DT_TO_TIME function?
Do I need to pass by the DTstructure to get the DT ?
Thanks,
Hi,
I’m not sure if I got your usescase completely right, so sorry in advance if I write too much general stuff
According to IEC 61131, a DATE_AND_TIME variable is for an absolute timestamp (seconds since 1-1-1970), and a TIME variable is for a timespan (milliseconds since “device powered on”).
So if you need a timespan, you can use for example the clock_ms() function which delivers that count of milliseconds since controller was switched on into a TIME datatype.
The DTGetTime() function block delivers the timestamp from the RTC (real time clock) of the controller into a DATE_AND_TIME variable (at the function blocks output .DT1)
The function block(s) including the …DTStructure phrase are using a structure of single elements for input / output instead of the IEC variable types (to have an alternative that you can chosse what type of data presentation fits better to your usecase), and the same is available for the …TIMEstructure datatype and functions.
If you need to calculate differences between 2 TIME or 2 DATE_AND_TIME variables, the’re the functions DiffDT() and DiffT() available.
All this functions / function blocks are part of the AsTime library.
Best regards!
Thanks you clock_ms() is exactly what i was lonking for.
All the code was already made, i was missing the time generator.
I try the TP function and use the PT but it wasn’t elegant solution.