Good practices, Examples, Example 1: excel macro to perform fft of c1 – Teledyne LeCroy WaveExpert series Automation Manual User Manual

Page 31: Overview

Advertising
background image

C

HAPTER

O

NE

Overview

916435 RevA

1-19

GOOD PRACTICES

Using

the

app.SetToDefaultSetup

action, restore the instrument to its default state before setting the

controls required by an application. This eliminates any dependency on the previous configuration of the

instrument. LeCroy strives to ensure that the default state of the instrument is constant from one software

release to the next.

Synchronization is an important concept that needs to be understood before you work with an X-Stream

DSO via Automation. Attempting to read results while acquisitions are in progress could cause

inconsistent results.

Use the X-Stream Browser while developing Automation applications. This tool is guaranteed to show the

up-to-date status of the Automation hierarchy since it retrieves it from a running instrument. It is also a

very quick and easy way to exercise controls in real-time without your having to write a single line of

code.

When using a result object, verify that the status is valid to ensure that the acquisition and/or processing

was valid.

EXAMPLES

Following are fairly complete examples of automating an X-Stream DSO, including configuration, acquisition, and

reading results. Examples are given both as Excel macros, and as Visual Basic Scripts, which can run without

Excel being loaded on the instrument.

Example 1: Excel Macro to Perform FFT of C1

Sub

Button1_Click()

' 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


' Read out the FFT

' Query the number of samples in F1 and store in cell "B1"

numSamples = app.Math.F1.Out.Result.Samples
Cells(1, 2).Value = numSamples

' Access the waveform data array, and fill the first column

Advertising