WinCC Flexible 2008: Datalogging via button trigger

STL???

Member
Join Date
Sep 2005
Location
UK
Posts
879
I need to log a collection of data on the press of a button, I'm not finding the help files particularly useful for what i'm trying to achieve.

I need to log each button push the following data types

String (User, alarm text)
Date & Time (error,login,logout)
integer (error number)

I have created a Datalog and added the D&T & int tags no problem, however string is greyed out.

Is it not possible to log strings?

and how can i trigger the capture of tag values into the Data log via button?

Thanks
 
win ce ?

win ce ?

http://www.plctalk.net/qanda/showthread.php?t=45733&highlight=combo+csv

On press, call the script

regards,
Combo


I need to log a collection of data on the press of a button, I'm not finding the help files particularly useful for what i'm trying to achieve.

I need to log each button push the following data types

String (User, alarm text)
Date & Time (error,login,logout)
integer (error number)

I have created a Datalog and added the D&T & int tags no problem, however string is greyed out.

Is it not possible to log strings?

and how can i trigger the capture of tag values into the Data log via button?

Thanks
 
Code

In holland there is script-code like this running in a machine that needs to save and fetch correctionvalues. Running in an MP277 10" touch. It has proven itself allready and does not fail.

Kind regards,
Combo


Code for fetching:
Code:
Dim f, fs, file_path, file_name, file_name_path, DataSet, HiField(6,6), i, j, y
On Error Resume Next
Set fs = CreateObject("filectl.filesystem")
Set f = CreateObject("filectl.file")
file_path= "[URL="file://\\Snelderdata\Machine\1"]\\Snelderdata\Machine\1[/URL]) Opdrukker\correctie\"
file_name= CStr(SmartTags("ACTIVE BATCH.ORDER_DATABASE.ARTIKEL_NUMMER"))& ".csv"
file_name_path= file_path & file_name
If Err.Number <> 0 Then
 ShowSystemAlarm "Error#" & CStr(Err.Number)&""& Err.Description
 Err.Clear
 Exit Sub
End If 
If fs.dir(file_name_path)= "" Then
 SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.VERSCHUIVING") = 0 
 SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.HOEK") = 0
 SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.HOOGTE") = 0
 SmartTags("INSTELLING PONSUNIT.CORRECTIES.RECHTS.BREEDTE") = 0
 SmartTags("INSTELLING PONSUNIT.CORRECTIES.RECHTS.HOEK") = 0
 SmartTags("DB Opvoer Data 100.Positie_Centreerunit") = 0
 SmartTags("Klemsysteem_script") = 1
Else
 f.open file_name_path, 1  
For y = 0 To 6
     i = 0
  HiField(y,i) = f.LineInputString 
Next
 SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.VERSCHUIVING") = HiField(0,0)
 SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.HOEK") = HiField(1,0)
 SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.HOOGTE") = HiField(2,0)
 SmartTags("INSTELLING PONSUNIT.CORRECTIES.RECHTS.BREEDTE") = HiField(3,0)
 SmartTags("INSTELLING PONSUNIT.CORRECTIES.RECHTS.HOEK") = HiField(4,0)
 SmartTags("DB Opvoer Data 100.Positie_Centreerunit") = HiField(5,0) 
 SmartTags("Klemsysteem_script") = HiField(6,0) 
End If
If SmartTags("Klemsysteem_script") = 1 Then
   SmartTags("DB Ponsunit Data 300.Met_Zonder_Klemsysteem")= True
Else  
   SmartTags("DB Ponsunit Data 300.Met_Zonder_Klemsysteem")= False
End If
  
If Err.Number <> 0 Then
 ShowSystemAlarm "Error#" & CStr(Err.Number)&""& Err.Description
 Err.Clear
 Exit Sub
End If 
f.close
Set f = Nothing
Set fs = Nothing
ShowSystemAlarm "Corrections fetching was successful"


Code for Saving:
Code:
Dim f, fs, file_path, file_name, file_name_path
On Error Resume Next
Set fs = CreateObject("filectl.filesystem")
Set f = CreateObject("filectl.file")
file_path= "[URL="file://\\Snelderdata\Machine\1"]\\Snelderdata\Machine\1[/URL]) Opdrukker\correctie\"
file_name= CStr(SmartTags("ACTIVE BATCH.ORDER_DATABASE.ARTIKEL_NUMMER"))& ".csv"
file_name_path= file_path & file_name
If Err.Number <> 0 Then
 ShowSystemAlarm "Error#" & CStr(Err.Number)&""& Err.Description
 Err.Clear
 Exit Sub
End If
If SmartTags("DB Ponsunit Data 300.Met_Zonder_Klemsysteem") Then
  SmartTags("Klemsysteem_script")= 1
Else  
  SmartTags("Klemsysteem_script")= 0
End If
  
f.open (file_name_path), 2  
f.Lineprint SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.VERSCHUIVING")
f.Lineprint SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.HOEK")
f.Lineprint SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.HOOGTE")
f.Lineprint SmartTags("INSTELLING PONSUNIT.CORRECTIES.RECHTS.BREEDTE")
f.Lineprint SmartTags("INSTELLING PONSUNIT.CORRECTIES.RECHTS.HOEK")
f.Lineprint SmartTags("DB Opvoer Data 100.Positie_Centreerunit")
f.Lineprint SmartTags("Klemsysteem_script")
f.Close
  
If Err.Number <> 0 Then
 ShowSystemAlarm "Error#" & CStr(Err.Number)&""& Err.Description
 Err.Clear
 Exit Sub
End If 
Set f = Nothing
Set fs = Nothing
ShowSystemAlarm "Corrections storage was successful"
 
And this

But, what you need is historian, appending line after line..., I think this may be a better example for you then:

Code:
Dim fs, f, DataSet, Dataformat, file_path, file_name, file_name_path
Delay(5) '5 seconds delay
On Error Resume Next
Set fs = CreateObject("filectl.filesystem")
Set f = CreateObject("filectl.file")
file_path = "[URL="file://\\Snelderdata\Machine\1"]\\Snelderdata\Machine\1[/URL]) Opdrukker\historie\" 
file_name = CStr(SmartTags("HISTORIAN BATCH.ORDER_DATABASE.KLANT_NUMMER")) & ".csv"
file_name_path = file_path & file_name
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 1 Then
SmartTags("Script_String_1")= "ø6,2 L20" 
ElseIf SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 2 Then
SmartTags("Script_String_1")= "ø6,2 L40" 
ElseIf SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 3 Then
SmartTags("Script_String_1")= "ø6,2 L60" 
ElseIf SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 4 Then
SmartTags("Script_String_1")= "ø6,2 L80" 
ElseIf SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 5 Then
SmartTags("Script_String_1")= "ø6,2 L100" 
ElseIf SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 7 Then
SmartTags("Script_String_1")= "ø8,2 L20" 
ElseIf SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 8 Then
SmartTags("Script_String_1")= "ø8,2 L40" 
ElseIf SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 9 Then
SmartTags("Script_String_1")= "ø8,2 L60" 
ElseIf SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 10 Then
SmartTags("Script_String_1")= "ø8,2 L80" 
ElseIf SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 11 Then
SmartTags("Script_String_1")= "ø8,2 L100"
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_2") = 0 Then
SmartTags("Script_String_2")= "Geen"
ElseIf SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_2") = 1 Then
SmartTags("Script_String_2")= "ø6,2"
ElseIf SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_2") = 2 Then
SmartTags("Script_String_2")= "ø8,2"
End If 
If SmartTags("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._GATEN") = 0 Then
SmartTags("Script_String_3")= "Enkel Gat"  
ElseIf SmartTags("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._GATEN") = 1 Then
SmartTags("Script_String_3")= "Dubbel Gat 21mm"  
ElseIf SmartTags("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._GATEN") = 2 Then
SmartTags("Script_String_3")= "Dubbel Gat 31mm" 
End If 
  
If SmartTags("HISTORIAN BATCH.ORDER_DATABASE.BUIS._MATERIAAL") = 0 Then
SmartTags("Script_String_4")= "Aluminium"   
ElseIf SmartTags("HISTORIAN BATCH.ORDER_DATABASE.BUIS._MATERIAAL") = 1 Then
SmartTags("Script_String_4")= "Verzinkt Staal"  
End If 
Dataformat = "Datum" & ";" & "Tijd" & ";" & "Ordernummer" & ";" & "Regelnummer" & ";" & "Leverdatum" & ";" & "Artikelnummer" & ";" & "Buistype" & ";" & "Klantnummer" & ";" & "Matrijs Stempel 1" & ";" & "Matrijs Stempel 2" & ";" & "Marijs Gaten" & ";" & "Buismateriaal" & ";" & "Buisdiameter" & ";" & "Buisdikte" & ";" & "Hart Op Hart" & ";" & "Hoek 1" & ";" & "Hoek 2" & ";" & "Grondstoflengte" & ";" &  "Totaal aantal" & ";" & "Aantal per bundel" & ";" & "Aantal geproduceerd" & ";" & "Memo" & ";"       
DataSet = (Date & ";" & Time & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.ORDER_NUMMER") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.REGEL_NUMMER") & ";" & SmartTags("HISTORIAN BATCH.LEVER_DATUM") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.ARTIKEL_NUMMER") & ";" & SmartTags("HISTORIAN BATCH.BUIS_TYPE") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.KLANT_NUMMER") & ";" & SmartTags("Script_String_2") & ";" & SmartTags("Script_String_1") & ";" & SmartTags("Script_String_3") & ";" & SmartTags("Script_String_4") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.BUIS._DIAMETER") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.BUIS._DIKTE") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.WENS._LENGTE") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.WENS._HOEK_1") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.WENS._HOEK_2") & ";" & SmartTags("HISTORIAN BATCH.GRONDSTOF_LENGTE") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.WENS._AANTAL") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.WENS._AANTAL_PER_BUNDEL") & ";" & SmartTags("BATCH STATUS.PRODUCTIE_AANTAL")& ";" & SmartTags("HISTORIAN BATCH.MEMO"))  
 
If Err.Number <> 0 Then
 ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
 Err.Clear
 Exit Sub
End If
 
If fs.dir(file_name_path)="" Then
 f.open file_name_path, 2  'Construct 
 f.LinePrint Dataformat
 f.Lineprint DataSet
 f.close
Else
 f.open file_name_path, 8 'Append
 f.Lineprint DataSet
 f.close
End If

If Err.Number <> 0 Then
 ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
 Err.Clear
 Exit Sub
End If
Set f = Nothing
Set fs = Nothing
ShowSystemAlarm "Historian storage was successful"
 

Similar Topics

Hi, We have upgraded our laptop which includes Windows 11. It appears that WinCC flexible 2008 advanced does not support Windows 11. What...
Replies
11
Views
265
Hello everyone I Have an Issue with the usage of recipes in Wincc Flexible 2008, I create the recipe to change the values in a fast way The...
Replies
0
Views
106
Hello Friends I have installed WinCC Flexible 2008 SP5 Update 2. I have open the software, but the Transfer option does not appear. Is It...
Replies
2
Views
1,471
I have wincc flex 2008 project made with wincc flexible 2088 sp1 project hmi device is simatic pc panel 19" I want to change hmi device to run the...
Replies
17
Views
5,280
Dear experts, I am Muhammad we have an IPC With the windows XP Embedded CE 5.0 on project and running well. i have plan to install wincc flexible...
Replies
8
Views
3,842
Back
Top Bottom