I created a trend record in codesys 3.5 (attached picture). However I do not know precisely how much time can the trend record show me backward. Is it days, weeks or months ?
It is highly important to me to know if I can see old recorded values for 1 week or not.
The recorded files of the trend record graph are SQlite files, but they are incomprehensible integers when opened in DB browser. Is there a way to make them readable ?
It depends on how many variables you record since the number of variables affect the storage size and that depends on your device.
The only known limitiation, which may cause some problems, is the 2GB file limit.
Right now there is no way to export it to csv.
Best regards,
Marcel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have 4 variables in the trend with a sampling of 200ms. the storage size in 'Trend storage' is by default 10 MB.
With these configurations can I see with cursor old data values for 1 week backwards ??
Is there any way codesys save/show a long trend ranging from 1 week to 1 month ?
Please it is highly important for me to know if possible to make a long trend and saving in Codesys.
Otherwise I have to change to a SCADA software to do a long trending.
Best Regards,
Jad
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just to confirm, can the trace save a long trend for more then 1 month and show it to me in the backward cursor?
I have no problem with memory, the HMI is the PLC where codesys 3.5 is installed and it has a wide hard disk (500GB). I believe I can put no limit in the 'Trend Storage'.
Marcel, the SQlite files saved by the trend are not readable in DB Browser, just integers. I think they need to be converted to big endian to become float values.
How to read these SQlite files? they are very important for trend analysis.
Best Regards,
Jad
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I use some code in visual designer to do this after I export it from DB Browser as a csv file.
You'll need to change the redacted to the username for the desktop and the file must be named TrendIn.csv.
You'll need to change things up for the amount of fields you have etc.
I'm not sure if it fixes the endian problem you're seeing.
You can definately see back 1 month. I record values every 5 minutes and the longest I've let it run without clearing the trend file was 2 years. Displaying 2 years at once, or a month, however would crash the visualization.
classProgram{staticvoidMain(string[]args){stringrawin=@"C:\Users\**REDACTED**\Desktop\TrendIn.csv";stringpath=@"C:\Users\**REDACTED**\Desktop\ConvertedTrendData.csv";// Create output file "TrendIn.csv"//Input must be TimeStamp, Temp <UInt>using(StreamWritersw=newStreamWriter(path,true)){// Open input file "ConvertedTrendData.csv"//Output will be Timestamp, DateTime, Temp <single>using(StreamReadersr=newStreamReader(rawin)){while(sr.Peek()>=0){strings=sr.ReadLine();string[]flds=s.Split(',');flds[1]=EpochToDateTime(flds[0]).ToString();flds[2]=UIntBinarytoFloat(flds[2]).ToString();s=string.Join(",",flds);sw.WriteLine(s);}}}}// Unix Timestamp to DateTimeprivatestaticDateTimeEpochToDateTime(stringstrValue){long.TryParse(strValue,outlongtimestamp);returnEpochToDateTime(timestamp);}privatestaticDateTimeEpochToDateTime(longtimestamp){varepoch=newDateTime(1970,1,1,0,0,0);stringts=timestamp.ToString();if(ts.Length<=11){returnepoch.AddSeconds(timestamp);}elseif(ts.Length>11&&ts.Length<=14){//Assuming Millisecondsreturnepoch.AddMilliseconds(timestamp);}else{//Assuming Microseconds - reduce by 1000s down to Millisecondswhile(ts.Length>14){ts=ts.Substring(0,ts.Length-3);}timestamp=long.Parse(ts);returnepoch.AddMilliseconds(timestamp);}}//Convert Unsigned Integer Binary Format to Float (single)privatestaticSingleUIntBinarytoFloat(stringstrValue){uint.TryParse(strValue,outuintuintValue);returnUIntBinarytoFloat(uintValue);}privatestaticSingleUIntBinarytoFloat(uintvalue){byte[]bytes=BitConverter.GetBytes(value);returnBitConverter.ToSingle(bytes,0);}}}
If you want something that directly creates a CSV file check out the Datalog_Storage Manager. You'll need to add the library and then the manager to the Modules tab. It does not create a graph though.
Last edit: Morberis 2020-11-16
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
in general yes, if it does work in your case, try it out. (e.g. by increasing the recording interval for a test to simulate the number of records you would have in a month etc etc).
No, I cannot support you reading the sqlite file.
Best regards,
Marcel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all,
It is highly important to me to know if I can see old recorded values for 1 week or not.
I kindly need your support.
hey,
It depends on how many variables you record since the number of variables affect the storage size and that depends on your device.
The only known limitiation, which may cause some problems, is the 2GB file limit.
Right now there is no way to export it to csv.
Best regards,
Marcel
Sir Prestel, there is a problem that user can't understand how many bytes will take one record in database. It will be helpful to show it in CODESYS IDE.
I'm already ask about it:
https://forge.codesys.com/forge/talk/Visualization/thread/9850eec96c/
I also hope that in future versions we get "Export CSV" feature - and not only manually from IDE, but with IEC-code too.
I agree, number of records is better to use.
hello Marcel,
I have 4 variables in the trend with a sampling of 200ms. the storage size in 'Trend storage' is by default 10 MB.
With these configurations can I see with cursor old data values for 1 week backwards ??
Is there any way codesys save/show a long trend ranging from 1 week to 1 month ?
Please it is highly important for me to know if possible to make a long trend and saving in Codesys.
Otherwise I have to change to a SCADA software to do a long trending.
Best Regards,
Jad
Hey,
yeah I think you should be good.
You can also just limit the number of recordings (which is easier to calculate for you).
Yeah the trace does save longer ranges as well, but then the database size may be a problem for your plc.
Again, exporting to CSV is currently not possible.
Best regards,
Marcel
hello,
Just to confirm, can the trace save a long trend for more then 1 month and show it to me in the backward cursor?
I have no problem with memory, the HMI is the PLC where codesys 3.5 is installed and it has a wide hard disk (500GB). I believe I can put no limit in the 'Trend Storage'.
Marcel, the SQlite files saved by the trend are not readable in DB Browser, just integers. I think they need to be converted to big endian to become float values.
How to read these SQlite files? they are very important for trend analysis.
Best Regards,
Jad
I use some code in visual designer to do this after I export it from DB Browser as a csv file.
You'll need to change the redacted to the username for the desktop and the file must be named TrendIn.csv.
You'll need to change things up for the amount of fields you have etc.
I'm not sure if it fixes the endian problem you're seeing.
You can definately see back 1 month. I record values every 5 minutes and the longest I've let it run without clearing the trend file was 2 years. Displaying 2 years at once, or a month, however would crash the visualization.
If you want something that directly creates a CSV file check out the Datalog_Storage Manager. You'll need to add the library and then the manager to the Modules tab. It does not create a graph though.
Last edit: Morberis 2020-11-16
Hello,
in general yes, if it does work in your case, try it out. (e.g. by increasing the recording interval for a test to simulate the number of records you would have in a month etc etc).
No, I cannot support you reading the sqlite file.
Best regards,
Marcel