Reading PLC trend data into python.

Honestly, while I use the trend to debug fast/complicated things, I have never really saved them to analyze them. Rockwell uses .dbf extension, because they can never do anything conventional. Python does have a module, naturally:

https://dbfread.readthedocs.io/en/latest/

Libreoffice opens the file fine, which I saved as a CSV, then of course, you could use python's csv module.

Edit: can't speak for Siemens, I only have exposure to Rockwell.

Edit2: it appearst that you can automate converting the files with Libreoffice command line:

internet said:
$ soffice --headless --convert-to csv FILETOCONVERT.DBF
 
Last edited:
It is pretty easy to read data from xml, json or .csv files using python.
Can Rockwell and/or Siemens trends be saved in any of these formats?


Dmroeder probably knows.


The PLC Trace function inside TIA exports as a ttrecx by default, but CSV is an option as well. The ttrecx, at first glance, seems to be a wacky XML file full of binary data, which includes the formatting for the graph and stuff like that.

Or did you mean trends on the Siemens HMI?
 
Oh, this is nice. I wanted to get values from a MicroLogix 1100 data file in RSL Micro into Python:

  • Go offline from Run, saving running state in the process
  • Print running state as PDF report
  • Open PDF with LibreOffice (Writer?)
  • Export as HTML file
  • Scrape data from HTML file with Python
Yuk.
 
Rockwell trends can be saved as a csv.

Keith

Thanks Keith, I see that now. My bad.

If you stop a trend, right click and select Create Snapshot, it creates a .dbf file

I see now to the right of the stop button, there is a Log drop down, where you have an option to save as CSV.
 
OK, next questions.
Since both Rockwell and Siemens can export .csv files,
can the order of the data be determined by the programmer?
This is for a tuning application which is done and works but it seems it is always a pain to for people to export the data.
I would like to see the data in this format
time control% PV

0.0, 50, 159,
0.1 50 160, ....


The next question is the units. For temperature system the time units are usually minutes. The control units are counts or percent. I prefer percent.


Can the units be determined by the programmer?


What I don't want to do is to write a module for each type of controller.


BTW, .dbf is an old data base format that was common long ago.
 
OK, next questions.
Since both Rockwell and Siemens can export .csv files,
can the order of the data be determined by the programmer?
This is for a tuning application which is done and works but it seems it is always a pain to for people to export the data.
I would like to see the data in this format
time control% PV

0.0, 50, 159,
0.1 50 160, ....


The next question is the units. For temperature system the time units are usually minutes. The control units are counts or percent. I prefer percent.


Can the units be determined by the programmer?


What I don't want to do is to write a module for each type of controller.


BTW, .dbf is an old data base format that was common long ago.


Seems unlikely that they'd match, but anything is possible.



The columns for the test trace I just created in TIA were sample number, timestamp, tag a, tag b, tag c. Sample number increments by 1 each sample. Timestamp appears to be milliseconds since Jan 1 1970 (1618510671223.024347, in the first sample in the trace I just took). The three tags are in the order I defined for the trace, not automagically alphabetized or anything.


You could easily include a minutes timestamp that's a tag of your own. The Control/PV tags would be whatever units you use in the system. I know Siemens PID blocks tend to have %, Counts, and Engineering Units as options, dunno how you're doing it.
 
hahahahaha


vewy funny mista wabbit.




Hi Peter, you can use classes and polymorphism to write an input parser for any new format; that way the users are not limited to a single format, while at the same time you do not have to change the tuning class.


Once you write and document the first input parser base class, the rest are easy and quick; the same .py file could handle CSV, TSV, XLS, XLSX, DBF, SQLite, ODBC, whatever.


Put it on Github, I can get it started if you are interested.
 

Similar Topics

Dear all, I don't know why setup of password became challenging and weird. After setting up the password and try to upload the ladder from the plc...
Replies
3
Views
165
Hello! New to the forum and new to PLCs in general. We have an ABB AC500 PLC (circa 2012?) and we are using CoDeSys (version 2.something). We're...
Replies
0
Views
626
I am operating a Siemens IM151-8 F Processor with 4 6ES7-134-4NB01-0AB0 2 channel thermocouple cards. I am getting no reading from any of the...
Replies
31
Views
6,066
I am working on a Micro 820 with a 2080-MOT-HSC high speed counter module. I am trying to read the pulses from a Signet 515 paddle wheel flow...
Replies
0
Views
709
Hi everyone, I have an issue, how is it possible to read data from an XML file with Delta PLC? In fact, I have another device (ElectroCell from...
Replies
1
Views
1,139
Back
Top Bottom