VM 10Ton logging script
How the new data has to be added in the VM 10Ton logging script
Sub Logging() (Subroutine – Declares the name, arguments
& code that from a body of a Sub procedure)
Dim Declares variables & allocates storage space
obj,foldername……. Which variable u want to use.
folderway="D:\10T Logging" Create a pathway to log the data in D:\10T
Set objectway=CreateObject("Scripting.FileSystemObject") Logging location
If Not objectway.FolderExists(folderway) Then Creates a obj (variable) to store the data.
objectway.CreateFolder folderway If there is already a folder exists then log data
End If into that only.
If not, create a folder & then log data into
that &
End the condition.
Yearval=Year(Date) Yearval – year value
Monthval=Month(Date) Logs the year corresponding to date.
Dateval=CStr(Date)
timeval=CStr(Time) CStr-Converts an expression to a variant-type
GetUserName Username value with the datatype string
SmartTags("User_Name")= Username
Get the username tag from the PLC.
Eg: operator 1
foldername="D:\10T Logging" & CStr(Yearval) Create a foldername to log the data in D:\10T
Set obj=CreateObject("Scripting.FileSystemObject") Logging with folder named as 10T Logging &
If Not obj.FolderExists(foldername) Then its corresponding year.
obj.CreateFolder foldername
End If Creates a obj (variable) i.e 2024 in that path.
If there is already a folder exists then log data
in the folder.
If not, create a folder & then log data into
that & end the condition.
foldername1="D:\10T Logging" & CStr(Yearval) &"\"& Create a foldername to log the data in D:\10T
CStr(Yearval)&"-" & CStr(Monthval) Logging location & Logs the year.
Set obj1=CreateObject("Scripting.FileSystemObject")
If Not obj1.FolderExists(foldername1) Then
obj1.CreateFolder foldername1
End If
filename= CStr(Date)&"_"& SmartTags("User_Name") &" .csv " Save the file in the format of csv (excel)
Set file=CreateObject("Scripting.FileSystemObject")
fileexist=file.FileExists(foldername1 & "\" & filename) Create a filename to log the data in D:\10T
If Not fileexist Then Logging with CSV file named as
file.CreateTextFile(foldername1 & "\" & filename) corresponding date & its username.
If there is already a file exists then log data in
the folder.
If not, create a file & then log data into that &
end the condition.
Set appendix=file.OpenTextFile(foldername1 & "\" & filename Appendix - to write & save the parameters
, 8)
appendix.WriteLine("Time, Agitator Cricuit Pressure, HE Oil 8-write the data
Outlet Temp") 2-read the data
“ \ ”- used inside subfolder
appendix.Close
End If
Set row=file.OpenTextFile(foldername1 &"\" & filename,8) 8-write the data
row.WriteLine(""& CStr(timeval) &","&SmartTags("Profibus PA
Transmitter_Agitator Circuit Gage Pressure Transmitter M") row.WriteLine – from the PLC -> PLC tags ->
IO -> Profibus PA Transmitters
or use CTRL+J to add the tags
Add the smartags corresponding to the
appendix value
row.Close Close the row
End Sub (End the subroutine).
How this script is executed?
Logging - Cross-reference (it is used by clock pulse – Acquistion cycle – 1s (whether the
equipment is ON/OFF, data should be logged.))
Tags.ScriptExcBit (PLC tag) -> Cross-reference -> Main N/W 66 – Clock 0.5Hz (2s)
How to add an new tags data into the logging folder
1) Set appendix=file.OpenTextFile(foldername1 & "\" & filename , 8)
appendix.WriteLine("Time, add the corresponding tag (this will set the header")
appendix.Close
2) Set row=file.OpenTextFile(foldername1 &"\" & filename,8)
row.WriteLine(""& CStr(timeval) &","& add the tag for which the data need to be logged
(Shortcut - Ctrl + J) &"")
row.Close
Procedure for Data Logging
1) Create a new VB script for logging.
2) Select the PLC (Eg: CPU 315-2DP) properties General Clock memory/System
& Clock Memory Check the Clock memory Select the Memory byte address as
0