plc.myforum.ro Forum Index plc.myforum.ro
PLCs users www.plc.myforum.ro!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TIA Portal 14 VBScript for MHI MP277 10"

 
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> SIMATIC Automation Systems -Reg.U
View previous topic :: View next topic  
Author Message
SohrabB
Junior 2
Junior 2


Joined: 04 May 2012
Posts: 29

PostPosted: 01/01/2018 20:57    Post subject: TIA Portal 14 VBScript for MHI MP277 10" Reply with quote

Hi everyone

I have written a VBScript on the TIA Portal, and it works well with simulation on Windows, but it does not work on the HMI MP277 (Windows CE 5.0). Can anyone correct it for me?
My file is attached. Many thanks

[url=http://www.girlshare.ro/3490003606.1]US_Data_Log_2.vbs[/url]
-------------------------------------------------------------------------------
Sub US_Data_Log_SB()


Dim fso, f, ts

'Declaration of local tags - Deklaration der lokalen Variablen
Dim path
Dim mode
Dim delimiter
Dim gap

Dim NewJob
NewJob=False

Dim NextStep

SmartTags("LOG_US_Start")=1

Path = SmartTags("LOG_US_WriteFileName") = "\Storage Card USB\LOG_US_" & CStr(DatePart("yyyy",Date)) & "-" & CStr(DatePart("m",Date)) & "-" & CStr(DatePart("d",Date)) & "_" & CStr(SmartTags("Job_Number")) & ".csv"
SmartTags("LOG_US_WriteFileName") = Path

'Starting error routine - Starten der Fehlerroutine
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
'Check if any errors happend - Auf Fehler prüfen
If Err.Number<> 0 Then
ShowSystemAlarm "Error # " & CStr(Err.Number)& " "& Err.Description
Err.Clear
Exit Sub
End If


If Not fso.FileExists(path) Then
fso.CreateTextFile path
NewJob = True
End If
'Check if any errors happend - Auf Fehler prüfen
If Err.Number<> 0 Then
ShowSystemAlarm "Error # " & CStr(Err.Number)& " "& Err.Description
Err.Clear
Exit Sub
End If

'Initialization of Tags - Initialisierung von Variablen
mode=8 '8 = Append
Set f = fso.GetFile(path)
Set ts = f.OpenAsTextStream(8, -2)

'Check if any errors happend - Auf Fehler prüfen
If Err.Number<0>=NextStep Then
'Write data into file - Daten werden in die Datein geschrieben

ts.WriteLine (CStr(Date) & "," & CStr(Time) & "," & SmartTags("US_Density") & "," & SmartTags("US_Pump1_Pressure") & "," & SmartTags("US_Pump2_Pressure") & "," & SmartTags("US_Pump1_Flow") & "," & SmartTags("US_Pump2_Flow") & "," & SmartTags("US_Pump1_Volume") & "," & SmartTags("US_Pump2_Volume") & "," & SmartTags("US_Pumps_Total_Flow") & "," & SmartTags("US_Pumps_Total_Volume") & ",")
'Check if any errors happend - Auf Fehler prüfen
If Err.Number<> 0 Then
ShowSystemAlarm "Error # " & CStr(Err.Number)& " "& Err.Description
Err.Clear
Exit Sub
End If
' NextStep=Timer+1
NextStep=Timer + SmartTags("LOG_Interval_Time")
End If
Loop Until SmartTags("LOG_US_Stop")=1

ts.Close
ShowSystemAlarm "Storage of data finished"

End Sub


Last edited by SohrabB on 02/01/2018 09:21; edited 2 times in total
Back to top
View user's profile Send private message
commit
Junior
Junior


Joined: 28 Dec 2017
Posts: 3

PostPosted: 01/01/2018 21:23    Post subject: Reply with quote

No file..reupload..
Back to top
View user's profile Send private message
SohrabB
Junior 2
Junior 2


Joined: 04 May 2012
Posts: 29

PostPosted: 02/01/2018 11:24    Post subject: Reply with quote

commit wrote:
No file..reupload..


Hi Thanks

The post has been modified.
Back to top
View user's profile Send private message
maersk
Member 3
Member 3
maersk

Joined: 17 Aug 2014
Posts: 891

PostPosted: 02/01/2018 14:55    Post subject: Reply with quote

Read on how do you store data with a script in a file with WinCC TIA Portal on
http://plc.myforum.ro/viewtopic.php?p=27086#27086

Adapt your script eventually.
Back to top
View user's profile Send private message
SohrabB
Junior 2
Junior 2


Joined: 04 May 2012
Posts: 29

PostPosted: 04/01/2018 19:28    Post subject: Reply with quote

maersk wrote:
Read on how do you store data with a script in a file with WinCC TIA Portal on
http://plc.myforum.ro/viewtopic.php?p=27086#27086

Adapt your script eventually.


Thanks ...........................................................
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> SIMATIC Automation Systems -Reg.U All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro