Blog

Data Logging with Siemens S7-1200 PLCs

Data Logging with Siemens S7-1200 PLCs

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:

Basic Panel Logging Interface

Comfort Panel Logging:

Comfort Panel Logging Interface

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[0].

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.

Comments

Karthik
# Karthik
Can someone advise me on how i can achieve the below:
I am having a CPU 1214C & HMI KTP 700 Basic. I would like to do data logging only when a certain PLC input goes to high (example I0.0 is TRUE). Currently, using the basic setting available i am able to log but the logging is done for every status change of the PLC tag (I0.0 TRUE = 1 log & I0.0 FALSE = another log).. Please help me on how to get the log limited (only log when the tag status change from FALSE to TRUE & no logging when the tag status change from TRUE to FALSE.

Thank you in advance.
reza
# reza
hi dear
i have problems
1- "historical data" in my project tree is missing
2- when i create a data block (like above), this problem i face:
the data type "datalogtype" is missing
can you please help me?
thanks
Quoc
# Quoc
Can you give me an example of the program?

__________________________________
Như bài này liên kết này:https://www.dmcinfo.com/latest-thinking/blog/id/8567/siemens-s7-1200-web-server-tutorial--from-getting-started-to-html5-user-defined-pages

Post a comment

Name (required)

Email (required)

CAPTCHA image
Enter the code shown above:

Related Blog Posts