Section 6: Instrument programming
2606B System SourceMeter® Instrument Reference Manual
6-12
2606B-901-01 Rev. B / May 2018
Interactive script example
An interactive script prompts the operator to input values using virtual front panel controls. The
following example script uses display messages to prompt the operator to:
•
Enter the voltage level to source
•
Enable or disable measurements
•
Set the number of readings if measurements are enabled
After the operator completes entering values, the output turns on and sources the specified value. If
measurements were enabled, a message indicates that measurements are in progress. Another
message is displayed when the source-measure operation is complete. If measurements were not
enabled, the message indicates that the source operation is complete.
When an input prompt is displayed, the script waits until the operator inputs the parameter or presses
the ENTER key. The example shown here assumes that you are using TSB or TSB Embedded. If you
are using a remote interface, you need to add the
loadscript
and
endscript
commands to the
example code. See
Load a script by sending commands over the remote interface
(on page 6-4).
reset()
-- Clear the display.
display.clear()
-- Prompt the user for a voltage value to source.
srcVoltage = display.prompt("+000.00", " V", "Enter source voltage", 5, -20, 20)
-- Prompt the user to enable measurements.
measEnable = display.menu("Measurements?", "ENABLE DISABLE")
if measEnable == "ENABLE" then
-- Prompt the user for the number of measurements.
numMeas = display.prompt("0000", " Rdgs", "Enter the number of readings", 10,
0, 9999)
smua.measure.count = numMeas
smua.nvbuffer1.clear()
end
-- Convert user input to the source level.
smua.source.levelv = tonumber(srcVoltage)
smua.source.output = smua.OUTPUT_ON
if measEnable == "ENABLE" then
-- Inform the user that measurements are in progress
display.setcursor(1, 1)
display.settext("$BPlease wait.$R$NMeasure operation in progress.")
smua.measure.i(smua.nvbuffer1)
display.clear()
-- Inform the user that the Source Measure operation has finished
display.settext("Operation Finished$NSource-Measure Complete")
else
-- Inform the user that the Source operation has finished
display.settext("Operation Finished$NSource Complete")
end
-- Wait 5 seconds then return to the main screen.
delay(5)
display.screen = display.SMUA