So I made sure to scour the internet before asking this, and I even found useful information on this site. However, I am new to VBScripting. I have learned how to take control of the Waverunner I am using it, and use it to set various triggers and such on the oscilloscope, but now I am using it to interface with a piece of Arduino software. My arduino software works, but for the research I need to do, I need to move away from "Copy and Paste" from the Serial Port. I need to sync time stamps with a clock on another board and monitor humidity and temperature in my cold box through weekend and nightly runs (and don't feel like living in my lab EVERY night.. some are ok.) Anyway, here is the VBScript code I have been using... but from what I understand from other forum posts, I would need to save to this EEPROM memory first? I'm not sure I follow.
What I have been trying to do is upload my Arduino code, then without opening the Serial Monitor, I double click this VBScript... however, nothing gets written....
Sorry if its stretched out, I program in XCode and Notepade, so anyone who helps me may want to copy and paste the code into another text editor to view comments correctly. Thanks for those who read and reply quickly!
'
' PreconSensorCode.vbs
'
' Author: xxxxxxxxxxxx
' Institution: xxxxxxxxxxxx
' Contact: xxxxxxxxxxxx
'
' PreconSensorCode is a VB Script that is meant to be used with the LeCroy WaveRunner Oscilloscope
'
' The Precon HS-2000V sensor system (off of Arduino Microntrollers) is interfaced
' in this script. It is assumed that whoever attempts to use or modify this code will be able
' to understand enough of the language with accompanying documentation/comments to figure out
' what they want and don't want.
'
'**************************************************************
'Call the CreateObject to instate ActiveX Control
'To understand the "com" handle more, go to My Computer->Hardware->Device Manager->Ports->USB Serial Port (COM6)
' You should see the following port settings: BPS=9600, Data Bits=9, Parity=None, Flow Control=None
' This Translates to COM6:9600,N,8,1
' Note, you might be using a different COM port, since there are 3 options on the Waverunner, but the details are most likely the same
set app = CreateObject("Lecroy.XStreamDSO") 'Establish control over the LeCroy Waverunner
set fso = CreateObject("Scripting.FileSystemObject") 'Establish file system control to manage folders and files
Set com = fso.OpenTextFile("COM6:9600,N,8,1", 1) 'Establish control over the COM port that your arduino is attached too, the option 1 is ForReading
set FSO = CreateObject("Scripting.FileSystemObject") 'Since fso is being used to read the COM port, need to define another to Write
'While setting up the scope, stop any Acquisition Process
app.Acquisition.TriggerMode="Stopped"
'Prepare a text file. TRUE=Overwrittable. False=ASCII script. Then set the TTree Branch Definitions
dim filetowrite 'Specify the filename to write time stamp too
dim timeStart
filetowrite = InputBox("Enter the DATE and RUN Number for this formatted as RUN10,RUN11,... (start at RUN10 not RUN01) : ","Setting File Name","RUN10",150,150)
timeStart = "1/1/1970 12:00:00 AM"
if FSO.FolderExists("C:\Documents and Settings\LeCroyUSer\Desktop\PreconSensor") = true then
set DataFile = FSO.CreateTextFile("C:\Documents and Settings\LeCroyUSer\Desktop\PreconSensor\" & filetowrite & ".txt",True,False)
DataFile.WriteLine("PreconTrigger/F:Date:Time:Meridiem")
else
FSO.CreateFolder("C:\Documents and Settings\LeCroyUSer\Desktop\PreconSensor")
set DataFile = FSO.CreateTextFile("C:\Documents and Settings\LeCroyUSer\Desktop\PreconSensor\" & filetowrite & ".txt",True,False)
DataFile.WriteLine("PreconTrigger/F:Date:Time:Meridiem")
end if
'Now Prepare a text file to read in the Arduino values. The option 2 sets it to writeable. The value True will create the file if it doesn't exist.
Set ArduinoFile = FSO.OpenTextFile("C:\Documents and Settings\LeCroyUSer\Desktop\PreconSensor\" & filetowrite & "_Precon.txt", 2, True)
MsgBox("Start to read data from COM")
Do While com.AtEndOfStream <> True
s = com.ReadLine
ArduinoFile.WriteLine(s)
'Response.Write(datediff("s", timeStart, now())
Loop
'Sanity Check to tell the User What happened
MsgBox("Just finished taking Precon triggers and writing to file.")
'Break away from applications and files
DataFile.Close
ArduinoFile.Close
com.Close()
Set app = Nothing
set fso = Nothing
set FSO = Nothing