Figure 1. The Advanced Customization option lets you seamlessly and continuously update the input of one parameter with the output of another. |
To demonstrate, we’ll use the example of taking the x@max value measured on each acquisition and using it to dynamically populate the X position used by the measurement parameter lvl@x. However, these principles could be applied to any two parameters that share a logical/mathematical relationship, or to a parameter and a math function (for example, to use the output of a parameter as the multiplier for a Rescale function).
How It Works
Advanced Customization enables you to insert custom math and measurement processors into the MAUI oscilloscope application. These processors compute in “real time” with results that appear on the oscilloscope application display, the same as all other MAUI processors.
All custom processors operate on the oscilloscope’s COM Automation interface objects, which are exposed by the MAUI Browser. Several languages can be used to write processors, but the simplest is VBScript, which is the native scripting language of the MAUI application. VBScripts can be easily created and assigned directly in the MAUI user interface, as we’ll demonstrate here.
For dynamic measurements, a “host” parameter (Pn) is set up with a custom VBScript that reads the output value of one parameter and pushes it into one of the input fields of another parameter. As the parameters are recalculated with each acquisition, the variable value is dynamically updated.
CAUTION: Because of the dependencies created by the MAUI application order of processing, we do not recommend setting up more than one dynamic field in any parameter or using this method to “chain” more than two parameters. You can, however, run more than one dynamic measurement simultaneously provided they do not use the same input/output parameters.
VBScript Syntax for Dynamic Measurements
The basic syntax for creating a dynamic measurement is:
' Create COM object handle:
Set app = CreateObject("LeCroy.XStreamDSO")
' Define the output variable:
var = app.Measure.P1.Out.Result.Value
' Define the input variable
app.Measure.P2.Operator.field = var
Where:
var is whatever handle you wish to give the variable value. Our examples use ‘x_at_max’.
field is the parameter input field where the value will be inserted. Our examples use ‘HorValue’.
We’ve used P1 and P2 to distinguish the first parameter from the second parameter, but in practice these could be any two parameters in your system, provided they are distinct from each other and from the VBScript host parameter. You are not syntactically restricted to using P1 and P2.
Some optional settings can be added to the host parameter (Pn) display as a consistency check to confirm the script is pulling the correct value from P1. They are:
' Display the P1 output in the Pn table cell to confirm that the value was read properly
OutResult.Value = var
' Use same vertical unit in Pn as P1
OutResult.VerticalUnits = app.Measure.P1.Out.Result.VerticalUnits
' Set display resolution of Pn table cell to value
OutResult.VerticalResolution = value
Finding the Automation Objects in MAUI Browser
To write your script, you will need to find the Automation Result Interface (output) that exposes the output value, and the Control Variable (input) that will receive that output value. This can be done prior to or at the time of scripting.
The MAUI Browser installed on the oscilloscope desktop (and on PCs with MAUI Studio) shows the entire COM Automation hierarchy of the oscilloscope application. By expanding the folders, you can navigate to any COM object and copy its full string for use in scripts.
If you’re working on the oscilloscope, choose File > Minimize or File > Windowed to show the desktop and launch MAUI Browser.
Note: The icon may be labeled MAUI Studio Browser or MAUI Automation Browser, and you’ll see it called XStream Browser elsewhere in the application. They are the same thing.
In our example, the X position field of the P2 lvl@x measurement will be updated dynamically using the last P1 x@max value, so we need to find the COM object strings for:
The P1 output value. Expand the Measure > P1 folder, and look in the gray, “Result” folder for output objects. The last output value is exposed by: app.Measure.P1.Out.Result.Value.
The P2 horizontal input field. Expand the Measure > P2 folder, and look in the yellow, “Operator“ folder for input CVARs. The horizontal input field is: app.Measure.P2.Operator.HorValue.
Note that on the MAUI GUI, this field is labeled X Position. One way to tell which CVAR corresponds to which field is to set a known value in the application field, which will appear in the browser when you refresh the object hierarchy.
Once you find and select the object that will be used by your script, the full COM Automation string appears in the MAUI Browser message bar. Right-click on the browser window and choose Copy Path to put it on your clipboard, ready to paste into your script.
Configuring Dynamic Measurements Step-by-Step
1. Stop acquisition.
2. On the MAUI Measure Setup dialogs, create P1 and P2 as usual. We've set x@max in P1:
lvl@x is set in P2. We can just leave the default setting for the X Position field of lvl@x, since that value will be updated dynamically by the script.
3. Create the host parameter using the Param script custom measurement. Ours is in P3.
Since this parameter is not directly measuring a waveform, it does not matter what the Source is, but to be consistent with P1 and P2, we’ve used C1.
4. On the Script Math subdialog, click Edit Code to open the Script Editor window. You can begin scripting right in the window, paste from another editor, or upload a saved script file.
5. When finished scripting, click Apply. This loads the script into the P3 processor, where it will begin operating with the next acquisition.
6. Restart acquisition.
The script above results in the following Measure display:
Note how the P3 table cell is showing the same value as P1, due to the display settings we added, and the P2 X Position field is also the same as the P1 value.
If you were to do this example on your oscilloscope, you would see the P2 X Position field update dynamically with each trigger to the same value as shown under P1 in the Measure table.
Watch Mike Hertz demonstrate this in our video: Configuring Dynamic Oscilloscope Measurements Using Advanced Customization
You can also download our application note: Configuring Dynamic Measurements Using Advanced Customization (XDEV)
No comments:
Post a Comment