s7-1200 and WinCC Flexible RT, production data save

rQx

Lifetime Supporting Member
Join Date
Oct 2010
Location
Trelleborg
Posts
1,051
Hello!

I want to save production data in a list form.
I have three variables that I want to save:

Product, weight and time.

I want this to be saved in a list to later be printed by the supervisor.

When I give the system a pulse (or when a tag change or something) I want the current varibles to be saved:

Product1, weight1, time1

when I give the system a new pulse I want it to be saved under the old one:

Product1, weight1, time1
Product2, weitht2, time2

So everytime a new pulse is given, the data is saved under the next so at the end of the day it will be like 20 entries:

Pdoruct1, weight1, time1
Product2, weight2, time2
.................................
Product20, weight20, time20.


What I have now is 20 I/O field of every varible that I fill with a value according to my ladder program. This is working but I just want to know if there is any simpler and better solution. I mean if I want to have 1000 production data stored I can't do it like this. There must be a better solution.

/Tim
 
Hi again!

I've been working with the code and got it to atleast save a log on my computer based on values in the array. However, the .csv format is bothering me.

It saves my data but if I open it in excel it will only occupy one cell and store all information in there. Is there anyway that you could save the production data in diffrent columns in excel?

This is how it is now

Excel A1:

Timestamp, headertext 1, headertext 2, etc etc

I want:

A1.................A2..................A3

Timestamp Headertext 1 Headertext 2


Is it possible?

/Tim
 
I don't know anything about how your CSV file is formatted, but Excel has multiple ways of selecting how to parse a CSV file, and it almost always picks the wrong one by default.

Traditionally (at least here in the US), a CSV file uses commas to separate the columns, and a carriage return/line feed to indicate the next row. However, sometimes a semicolon is used, or a tab, or the fields are all a fixed width. I'm guessing your import settings in excel aren't quite right.
 
Wow, that did the trick!

So heres my new concerns about this script:

The name of the file chould be set with this statement in the script:

SmartTags("LOG_WriteFileName") = "C:\LOGS\LOGGING_" & CStr(DatePart("yyyy",Date)) & "_" & CStr(DatePart("m",Date)) & "_" & CStr(DatePart("d",Date)) & ".csv"

What I want to do is the descide the Name of the file with the use of a string I can set from my PLC. So instead of "LOGGING" I want to use a string I set in PLC to name it for example "OutboundFrance". Since I have no experience in scripting I don't know where to start. I can edit the script and understand how to but to add new component is to hard (for now).

I made an atempt
Is this the way to do it:

SmartTags("LOG_WriteFileName") = "C:\LOGS\" & SmartTags("LOGNAME") & CStr(DatePart("yyyy",Date)) & "_" & CStr(DatePart("m",Date)) & "_" & CStr(DatePart("d",Date)) & ".csv"

The LOGNAME beeing a String of 10, from my PLC to my RT.
 
Last edited:
That sounds promising, and would be the first thing I try.

I'm not sure how Strings are handled between the HMI and the PLC, though. In the PLC, the first two bytes of the string are the max & current length. I'm not sure if the HMI actually strips those out or not. I would assume they are smart enough to take care of that for you, but I've never tried to use a PLC string in a script before.
 
Perfect, thanks alot!
And again, thanks for the script. Easy to edit!
I'll post if I have any new questions.

/Tim
 
Everything works perfect!
I now have a script that I can name from my PC, it gets properly formated in excel.
This is just what I need.

I have another question: Is it possible to format the header text to be bold and underlined? Maybe use diffrent sizes and so on?

/Tim
 

Similar Topics

Dear all, I nead to access parts of structures from s7-1200 plc in wincc flexible running on PC. My problem is that plc programm is done by...
Replies
4
Views
2,952
Hi! I shall connect my s7 1200 CPU with a computer. I have wincc flexible advanced and I have made my program. I found on the siemens site how to...
Replies
2
Views
5,185
Hello all, I am trying to connect an existing Siemens WinCC SCADA to a new machines S7-1200 PLC. I have connected anpther 1200 and a 1500...
Replies
2
Views
2,882
Hello everyone, I have 8xS71200 cpu fitted profinet with Wincc RT on pc station .I use tia portla v13 sp1 and i want to check and show current...
Replies
9
Views
9,571
Hey folks... I've been thrown into the deep end of a dodgy pool. A life line would be appreciated. Our one and only resident PCS7 knowledgable...
Replies
8
Views
4,058
Back
Top Bottom