Help With First Timer.

Author Message
Nutkin

  • Total Posts : 3
  • Scores: 0
  • Reward points : 0
  • Joined: 11/3/2008
  • Status: offline
Help With First Timer. Tuesday, November 04, 2008 12:11 AM (permalink)
0
Ok first off im using the script editor for a job at work as a little proof of concept for a customer. He doesnt want to install any software etc so im attempting in script for him via excel.

I went to vbforums but their nospam thing is ridiculous and doesnt work.


So im hopeing you guys can help.

Right Senario.

Products on a test line, comes to the end an Agilent scope performs a test and logs its results and saves as a text file!

For every text file i would like the name to change. so say its testing a transistor, is it possible to name the text files each time the test is run transistor1.txt then transistor2.txt

In order to get this i assume the script must loop,  so can i get my script to loop and pause, Like jsut have one big button that runs the test.

Also i have no idea how you get the Text box to input names, like at the start the user needs to enter what line hes on and what test hes performing.


Any help with this is rgeatly appriciated guys :)

I include my script bellow for evaluation.

Option Explicit
Public myMgr As VisaComLib.ResourceManager
Public myScope As VisaComLib.FormattedIO488
Public varQueryResult As Variant
Public strQueryResult As String
Sub Main()


' Create the VISA COM I/O resource.
Set myMgr = New VisaComLib.ResourceManager
Set myScope = New VisaComLib.FormattedIO488
'Configure LAN conection
Set myScope.IO = myMgr.Open("TCPIP0::tim5.britain.agilent.com::inst0::INSTR")
Initialize
Capture
End Sub
Private Sub Initialize()
'Clear the interface
myScope.IO.Clear
'Default the Scope
myScope.WriteString "*RST"
'Set AutoScale
myScope.WriteString ":AUTOSCALE"
'Set the Vertical range
myScope.WriteString ":CHANNEL1:RANGE 8"
' Set the time range
myScope.WriteString ":TIM:RANG 2e-3"
' Set reference to center.
myScope.WriteString ":TIMEBASE:REFERENCE CENTER"
End Sub
Private Sub Capture()
' Declerations
Dim Frequency As String
Dim Time As String
Dim SetDate As String
Dim strPath As String
Dim AssemTyp As String
Dim AssemSerial As String
Dim TestType As String
Dim ProStep As String
Dim Amplitude As String
Dim AvVolt As String

myScope.WriteString ":SYSTem:TIME?"
varQueryResult = myScope.ReadString
strPath = "c:\scope\config\Data.txt" //Would like to increment with every run!
Close #1   ' If #1 is open, close it.
' Open file for output.
Open strPath For Output Access Write Lock Write As #1

myScope.WriteString "*IDN?"
varQueryResult = myScope.ReadString
Write #1, , "Instrument ID: " + varQueryResult + vbCrLf

ProStep = "step 1"  //[ These i would like user text input for.]
Write #1, , "Process Step: " + ProStep + vbCrLf

TestType = "Frequencey Test"   //[ These i would like user text input for.]
Write #1, , "Test Type: " + TestType + vbCrLf
 
AssemTyp = "Malaysia 1"  //[ These i would like user text input for.]
Write #1, , "Assembly Name: " + AssemTyp + vbCrLf

AssemSerial = "Mlys01452203"   //[ These i would like user text input for.]
Write #1, , "Assembly Serial No: " + AssemSerial + vbCrLf

myScope.WriteString ":SYSTem:TIME?"
Time = myScope.ReadString
Write #1, , "Time: " + Time + vbCrLf

myScope.WriteString ":SYSTem:DATE?"
SetDate = myScope.ReadString
Write #1, , "DATE: " + SetDate + vbCrLf
  
'Test for frequency above 1KHz
myScope.WriteString ":MEASURE:FREQUENCY?"
Frequency = myScope.ReadNumber
Write #1, , "Frequency: " + FormatNumber(Frequency / 1000, 4) + " kHz"

If Frequency > 1000 Then Write #1, , "Result: Pass" Else: Write #1, , "Result: Fail" + vbCrLf


'Test for amplitude above 1V
myScope.WriteString ":MEASURE:VAMP?"
Amplitude = myScope.ReadNumber
Write #1, , "Amplitude: " + Amplitude

If Amplitude > 1 Then Write #1, , "Result: Pass" Else: Write #1, , "Result: Fail" + vbCrLf

'Test for Average Voltage above 0.5V
myScope.WriteString ":MEASURE:VAV?"
AvVolt = myScope.ReadNumber
Write #1, , "Average Voltage: " + AvVolt

If AvVolt > 0.5 Then Write #1, , "Result: Pass" Else: Write #1, , "Result: Fail"

Close #1

End Sub
<message edited by Nutkin on Tuesday, November 04, 2008 12:14 AM>
 
#1
    ebgreen

    • Total Posts : 8227
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    RE: Help With First Timer. Tuesday, November 04, 2008 1:15 AM (permalink)
    0
    Okay, for big suggestions. To get user input use InputBox. To increment the text file number, you could keep an internal number that you increment and add to the file name. To make sure that you didn't overwrite anything, just have it look through all the files in the folder and find the largest number every time that the program runs.
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      Nutkin

      • Total Posts : 3
      • Scores: 0
      • Reward points : 0
      • Joined: 11/3/2008
      • Status: offline
      RE: Help With First Timer. Tuesday, November 04, 2008 1:23 AM (permalink)
      0
      Thank you for the text box hints :) very usedful.
       
      how would you modify this line to add the variable
       
       strPath = "c:\scope\config\Data.txt"
       
      ive tried
       
       strPath = "c:\scope\config\Data"VARIABLE".txt"
       
      but it doesnt seem to work. but im used to C based coding so im not suprised.
       
      #3
        ebgreen

        • Total Posts : 8227
        • Scores: 98
        • Reward points : 0
        • Joined: 7/12/2005
        • Status: offline
        RE: Help With First Timer. Tuesday, November 04, 2008 2:04 AM (permalink)
        0
        Lets say that you kept a counter named nFileNumber. Then you would make the name like this:

        strPath = "C:\scope\config\Data" & nFileNumber & ".txt"
        "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
        Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
        http://www.visualbasicscript.com/m_47117/tm.htm
         
        #4
          Rischip

          • Total Posts : 519
          • Scores: 2
          • Reward points : 0
          • Joined: 3/26/2007
          • Status: offline
          RE: Help With First Timer. Tuesday, November 04, 2008 3:37 AM (permalink)
          0
          I would recommend padding the variable so you do not get variable length file names.

          Somefilename00005.txt
          Somefilename00006.txt
          Somefilename00010.txt

          instead of

          Somefilename5.txt
          Somefilename6.txt
          Somefilename10.txt
          Somefilename100.txt

          Also I would store the variable for the filename in a seperate file. This way if the script is restarted or any of the files move then the correct starting point is known.
           
          #5

            Online Bookmarks Sharing: Share/Bookmark

            Jump to:

            Current active users

            There are 0 members and 1 guests.

            Icon Legend and Permission

            • New Messages
            • No New Messages
            • Hot Topic w/ New Messages
            • Hot Topic w/o New Messages
            • Locked w/ New Messages
            • Locked w/o New Messages
            • Read Message
            • Post New Thread
            • Reply to message
            • Post New Poll
            • Submit Vote
            • Post reward post
            • Delete my own posts
            • Delete my own threads
            • Rate post

            2000-2012 ASPPlayground.NET Forum Version 3.9