Teledyne LeCroy WaveExpert series Automation Manual User Manual
Page 32
A
BOUT
A
UTOMATION
1-20
916435 RevA
' of the spreadsheet with it
wave = app.Math.F1.Out.Result.DataArray
For
i = 0
To
numSamples - 1
Cells(i + 1, 1).Value = wave(i)
Next
End
Sub
Example 2: VBScript Program to Perform FFT of C1 and Store Results in Text File
This example requires no additional software to be installed on the instrument, since it relies upon the built-in
Visual Basic Script interpreter. The example is very similar to the previous Excel example, the most notable
difference being the use of a standard system ActiveX control, “Scripting.FileSystemObject”, to enable the
creation of files containing waveform data in ASCII format.
' VBScript example
' Configure the DSO to perform an FFT on Channel 1 and store
' the resulting data in a text file in ASCII format
' Connect to the DSO
Set
app = CreateObject("LeCroy.XStreamDSO")
' Restore the instrument to its default state
app.SetToDefaultSetup
' Stop acquisitions during setup
app.Acquisition.TriggerMode = "Stopped"
' Turn C2 off (default state leaves C1 and C2 On)
app.Acquisition.C2.View =
False
' Configure F1=FFT(C1), using a Blackman-Harris filter
app.Math.F1.View =
True
app.Math.F1.Source1 = "C1"
app.Math.F1.Operator1 = "FFT"
app.Math.F1.Operator1Setup.Window = "BlackmanHarris"
' Take a single acquisition, force after 2 seconds if it doesn't trigger
app.Acquisition.Acquire 2,
True
' Readout the FFT
numSamples = app.Math.F1.Out.Result.Samples
Set
fso = CreateObject("Scripting.FileSystemObject")
Set
MyFile= fso.CreateTextFile("c:\XStreamFFT.txt",
True
)
' Write the FFT power spectrum into the file, sample by sample
wave = app.Math.F1.Out.Result.DataArray
For
i = 0
To
numSamples - 1
MyFile.WriteLine(wave(i))
Next
' Clean up
MyFile.Close
Set fso = Nothing
Set app = Nothing