Chapter 3 Configuring for Measurements 73
Subprogram execution can also be resumed by sending the GPIB Group
Execute Trigger (this does not in itself trigger a reading: it merely resumes
subprogram operation).
Nested Subprograms You can use a subprogram to call another subprogram (nested subprograms).
For example, when the following subprogram is called (CALL 1 command),
it takes 10 DC voltage readings and then calls the previously stored
subprogram DCCUR1.
10 OUTPUT 722; "SUB 1"
20 OUTPUT 722;"TRIG HOLD"
30 OUTPUT 722;"NRDGS 10,AUTO"
40 OUTPUT 722;"DCV 10"
50 OUTPUT 722;"TRIG SGL"
60 OUTPUT 722; "CALL DCCUR1"
70 OUTPUT 722; "SUBEND"
80 END
A subprogram containing a PAUSE command cannot be called from another
subprogram. The multimeter allows you to nest up to 10 subprograms; that
is having subprogram 1 call subprogram 2 which calls 3, which calls 4 ...
which calls subprogram 10.
Autostart
Subprogram
When you entitle a subprogram 0, that subprogram will be executed
whenever the multimeter completes its power-on sequence or it is reset using
the front panel Reset key. This is particularly useful to automatically return
the multimeter to its previous state following a power failure. Whenever a
power failure is detected, the multimeter stores its present state as state 0
(states are discussed later in this chapter). The following program stores an
autostart program that returns the multimeter to its power-down state and
also sets the A/D converter's reference frequency to the exact power line
frequency (see "Changing the Reference Frequency" earlier in this chapter
for details).
10 OUTPUT 722; "SUB 0"
20 OUTPUT 722;"RSTATE 0"
30 OUTPUT 722;"LFREQ LINE"
40 OUTPUT 722; "SUBEND"
50 END
You can also call the autostart subprogram (CALL 0 command) if you need
to execute the subprogram without having to cycle the multimeter's power.
Compressing
Subprograms
When you store a subprogram, the multimeter stores the ASCII text in
continuous memory and a compiled version of the subprogram in volatile
memory. When you call a subprogram, the multimeter executes the compiled
version (this is why a subprogram executes faster than the equivalent
commands sent over the bus). When power is removed, only the ASCII text
is saved. When power is reapplied, the multimeter uses the ASCII text to
generate a compiled subprogram. You can compress subprograms using the
COMPRESS command. Compressing a subprogram removes the ASCII text
from continuous memory leaving only the compiled version in volatile
memory. This makes more continuous memory space available but removes
the subprogram from continuous memory (all record of the subprogram will
be destroyed when power is removed or the front panel Reset key is pressed).