getting started with visual basic scripting in MultiVu
getting started with visual basic scripting in MultiVu
The Visual Basic interpreter included in MultiVu, WinWrap Basic, is very similar to VBA
provided by Microsoft. The executable programs (.BAS files) are called macros in MultiVu. We
also refer to WinWrap Basic as a scripting environment.
General guides to programming in Visual Basic are available on the web. For example, here is a
link to a Microsoft VBA programming guide:
http://msdn.microsoft.com/en-us/library/aa716285(VS.60).aspx
WinWrap’s language reference page is a more advanced resource:
http://www.winwrap.com/web/basic/language/?p=doc_group_overview.htm
WinWrap also provides full function reference embedded into the editor in MultiVu, accessed by
pressing F1 or right-clicking in the editor window. This reference material applies only to
general WinWrap functions and not the MultiVu platform-specific functions (like setting or
reading the temperature or magnetic field). For a dictionary of essential MultiVu function calls,
see the section at the end of this application note. This dictionary is also included as a PDF file as
part of a .ZIP archive attached to this application note. That .ZIP file contains example programs
for interfacing external instruments, controlling the QD instrument, and creating and
manipulating data files.
There is also a dictionary of the available function calls which can be pulled up by pressing the
Browse Object button (circled in red in the editor screen shot below).
Selecting Edit Macro will then open up the WinWrap Basic editor:
You can also translate an existing sequence (.SEQ file) into a Basic program using the
Sequence > Advanced > Compile Macro command when a sequence is open in MultiVu. This
can be helpful in getting started with basic instrument calls for setting field, temperature, etc. if
In the attached ZIPped folder are some example macros (.BAS files), object files (.OBJ), and
class files (.CLS). Please consult a programming guide for more information on the creation and
use of objects and classes. Unpack this zip file into the folder C:\qdppms\macros (or
C:\QDVersaLab\macros or C:\QDSquidVSM\macros, etc.). This is the default location for macro
files. We suggest right-clicking on the zip file and using “Open with Compressed (zipped)
folders” in order to preserve the structure of the subfolders (note that the zipped folder should
unpack with subfolders as the programs will reference objects or class files using relative
directory links). After unpacking the library, open macros from the editor using the Open file
icon. You will see general examples like MultiVu Scan Field Loop.bas which is
written so that any platform can use it and others which are platform specific like PPMS scan
V output.bas that uses analog voltage outputs on the Model 6000 of the PPMS. There are
macros for interfacing with 3rd party instruments like LCR meters, a resistance bridge, and a
lock-in amplifier. Perhaps the best example to start with is getGPIBdata and
writetofile.BAS (screen shot is shown on the next page) which shows the following
important operations:
1) Interfacing with the Quantum Design instrument (set/read field and temperature) which
are written in the cross-platform MultiVu.xxx format
2) Setting up and interfacing with an external resistance bridge using GPIB
3) Opening and writing data to a .DAT file which can be graphed in MultiVu; NOTE: some
existing users may have an older version of the class file (MVUData.cls) for this, while
a newer and more sophisticated version (MultiVuDataFile.cls) is included in the
attached zip file
In addition to code written by Quantum Design users, some manufacturers of 3rd party
instruments (e.g., Agilent) provide Visual Basic example code to interface their devices.
A useful feature of this editor is that it includes code completion as well as highlighting of
recognized functions. As an example, type Wait( and you will see a tooltip dialog showing the
format of the argument of the Wait function.
Please note: you use the green arrow button in the editor to run a macro, NOT using the MultiVu
Run Sequence command.
To easily see the objects or class files that a particular macro uses (seen in the '#uses
declarations at the beginning of the program), right-click in the editor window and select Sheet >
Open Uses and the modules will appear on new tabs on the left of the window.
When debugging code, it is helpful to keep the editor window always split in order to keep the
debug information visible after execution has stopped. Do this by right-clicking in the editor and
selecting View > Always Split.
If you are interested in sharing any code you have written, such as .OBJ files and a simple
implementation example, Quantum Design welcomes your contributions at [email protected] .
Conventions
Methods signatures are shown twice, first in WinWrap (Visual Basic) syntax, second in C-like
syntax. Variable types are as follows (note that some types, e.g. long, have different meanings
in different languages, so be careful):
Some method arguments are passed by value, and others are passed by reference. By value
arguments look like this in WinWrap: ByVal temperature As Double, and like this in
C: double temperature. By reference arguments look like this in WinWrap: ByRef
temperature as Double, and like this in C: double* temperature. Note that you
must create appropriate variables to pass as by reference arguments before making a call to a
method that takes by reference arguments. Do not attempt to pass a constant number as a by
reference argument.
All methods return an error code with type long. A value of zero indicates no error. Other
values indicate an error.
Methods
SetTemperature
MultiVu.SetTemperature(ByVal temperature As Double, ByVal rate
As Double, ByVal approach As Long) As Long
long SetTemperature(double temperature, double rate, long
approach)
temperature: Temperature set point in kelvin
rate: Temperature rate set point in kelvin/second
approach: Approach mode as one of the following codes
0: Fast settle
1: No overshoot
GetTemperature
MultiVu.GetTemperature(ByRef temperature As Double, ByRef state
As Long) As Long
long GetTemperature(double* temperature, long* state)
temperature: Temperature reported by MultiVu in kelvin.
state: Temperature status reported by MultiVu as one of the following codes
SetField
MultiVu.SetField(ByVal field As Double, ByVal rate as Double,
ByVal approach As Long, ByVal mode as Long) As Long
long SetField(double field, double rate, long approach, long
mode)
field: Field set point in oersted
rate: Field ramp rate set point in oersted/second
approach: Approach mode as one of the following codes
0: Linear
1: No overshoot
2: Oscillate
mode: Mode at end of field ramp as one of the following codes. Note that Persistent mode is not
supported by VersaLab and DynaCool
0: Persistent
1: Driven
GetField
MultiVu.GetField(ByRef field As Double, ByRef state As Double)
As Long
long GetField(double* field, long* state)
field: Field reported by MultiVu in oersted
state: Field state reported by MultiVu as one of the following codes
0: Unknown
1: Persistent (PPMS), Standby (VersaLab and DynaCool)
2: Switch warming
3: Switch cooling
4: Holding in driven mode
5: Iterating
6: Charging
8: Current error
15: General failure in field control
GetChamber
MultiVu.GetChamber(ByRef code As Long) As Long
long GetChamber(long* state)
code: Chamber state reported by MultiVu as one of the following codes:
0: Unknown
1: Purged/Sealed
2: Vented/Sealed
3: Sealed (condition unknown)
4: Purging
5: Venting
6: Pre-high vacuum
7: High vacuum
8: Pumping continuously
9: Flooding continuously
WaitFor
MultiVu.WaitFor(ByVal mask As Long, ByVal delay As Double,
ByVal timeout As Double)
mask: Code that determine which subsystems need to be stable in order to satisfy the WaitFor.
To wait for multiple subsystems, you set mask to the sum of the codes for the desired
subsystems. Subsystem codes are:
0: No subsystems (useful to create a delay without waiting for stability)
1: Temperature
2: Field
4: Position (rotator)
8: Chamber (purge, high vacuum, etc.)
delay: Time in seconds to wait after stability is reached.
timeout: If stability is not reached within timeout (in seconds), the wait is abandoned. Set
timeout to 0 in order to turn off this feature (i.e., to wait forever for stability).
Note: The WaitFor method is for use within WinWrap scripting only. In order to wait for
stability in other programming environments, use one or more of the “Get” methods to poll
status.