beautypg.com

From visual basic, From matlab – Teledyne LeCroy WaveExpert series Automation Manual User Manual

Page 22

background image

A

BOUT

A

UTOMATION

1-10

916435 RevA

From Visual Basic

From Visual Basic the CreateObject method is used to create the connection to an instrument by Automation.
The following code example creates this connection and sets up some of the instrument’s controls:

' Connect to the X-Stream DSO
Dim app as Object
Set app = CreateObject(“LeCroy.XStreamDSO”)

' Setup Vertical and Horizontal settings
app.Acquisition.C1.VerScale = 0.5
app.Acquisition.C1.VerOffset = 0.25

app.Acquisition.Horizontal.HorScale = 0.000001

' Disconnect from the DSO
Set app = Nothing

From MATLAB

The syntax for controlling the scope MATLAB uses the actxserver keyword to connect to the instrument.
The following code example creates this connection, enables variable vertical scale, reads the vertical scale value

for C1, and increases it by a factor of 1.5, arms the scope, waits for the acquisition to be complete, and then

reads out the value and mean of parameter P1.

% Connect to oscilloscope via DCOM at IP address 172.28.9.31

DSO = actxserver('LeCroy.XStreamDSO', '127.0.0.1')

% Readback instrument ID

get(DSO.Item('InstrumentID'),'Value')

% Create references to the Acquisition, C1, Measure and P1 objects for convenience

acq = DSO.Object.Item('Acquisition')

c1 = acq.Object.Item('C1')

meas = DSO.Object.Item('Measure')

p1 = meas.Object.Item('P1')

% Enable variable vertical scale for channel 1

set(c1,'VerScaleVariable',-1)

% Read the vertical scale for C1 and increase it by a factor of 1.5, re-read and display new scale

verscale = get(c1.Item('VerScale'), 'Value')

set(c1, 'VerScale', 1.5 * verscale)

verscale = get(c1.Item('VerScale'), 'Value')

% Invoke the Acquire method, and force a trigger if the acquisition isn’t complete within 3 seconds.

invoke(acq, 'Acquire', 3, 1)

% Readout the value and mean of measurement P1 (requires P1 to be setup and displayed)

p1_val= get(p1.Out.Result,'Value')

p1_mean = get(p1.Object.Item('Mean').Result,'Value')

Creating references to objects at each level in the oscilloscope application’s object hierarchy is
highly recommended in order to keep the code cleaner and easier to debug.

N

N

O

O

T

T

E

E

:

: Don’t confuse the control of the instrument from MATLAB

(MATLAB “drives”) with the use of MATLAB from within a
custom processing function (the instrument “drives”).