The creation and maintenance of data records for machines is a very important part of keeping machines running efficiently. For example, tracking downtime and uptime is crucial to provide proper maintenance on the machine, while logging stoppages and other events can help provide insight into troubleshooting any system. Maintaining these data logs sometimes requires purchasing additional software and hardware, as well as some programming to integrate everything together.
Siemens has been providing new ways of logging data that come packed with their PLCs and HMIs, which is great because it allows us to implement these features without needing to purchase anything additional.
Logging comes as a feature in both Basic and Comfort Panels, as seen below.
Basic Panel Logging:
Comfort Panel Logging:
The Comfort Panel logging is nicer because you can store the logs in CSV files, which are easily opened in Excel, whereas the Basic Panels require the logs to be stored as TXT files.
Siemens has now also created a group of instructions just for Data Logging so that we can create custom data logs using lower cost processors.
Each of these instructions is very easy to use, and they can be packaged into a single Function Block like the one I created below.
This Function Block allows the user to write values to a data log on “Command Log”, using the data in “Data_block_1”.Logs.
The result of this code will be to add the values of “Int1” and “Real1” to the end of the “Data0” data log with a time stamp. “Int1” lines up with the “Var1” header and “Real1” is under the “Var2” header. If the “Data0” data log doesn’t exist yet, the code will create it.
Once the data log is open I can write the values to it, and after every write I close the data log. I used a simple state machine to move through each step of the data logging process, part of which can be seen below.
After writing to data logs I can then download, rename, and delete them easily through the webserver.
There are many different ways to log data with the S7-1200 and S7-1500 PLCs. For faster or more extensive data logging I recommend keeping the logs open while writing takes place. However, we may only have 10 logs open at a time. Also, there are limits to the lengths of data logs, so you may need to programmatically add new data logs, clear data logs, or delete them.
Contact DMC regarding Siemens S7 PLC Programming Projects.
Learn more about DMC's Siemens S7 PLC Programming services.