A single trial on a sample-size of one merely gives you an indication of truth but is not conclusive. Because of this, the ability to automate your primary test and debug equipment can be immensely powerful. Let your equipment do the work while you deliberate over the latest TPS reports. This post will focus on the MSO-X 2024A.
Installing the Software
You will need to start by installing your Python environment of choice, then the Keysight IO Libraries suite.
Download the Keysight IO Libraries Suite here.
Connecting the Hardware
Since this is a new-ish scope, we can use the USB connection and it will enumerate as a VISA com port. This can be found on the rear of the instrument as seen below. Simply connect a USB cable from the instrument to your computer.
To give ourselves something to measure, attach a probe to channel one (yellow) and wavegen output as highlighted below.
HelloWorld
The basic connection to the device is simple. You initialize a VISA resource, connect to the device using its VISA address, and then send commands. To know the address of your instrument, install and launch Keysight Connection Expert.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import visa import time # initialize visa resource rm = visa.ResourceManager() # open the resource using the VISA address from Keysight Connection Expert MSO_X_2024A = rm.open_resource('USB0::0x0957::0x1796::MY52140586::0::INSTR') # request the instrument to identify itself modelSerialnumber = MSO_X_2024A.query('*IDN?') print str(modelSerialnumber) # close MSO_X_2024A.close() rm.close() |
Moving Forward
The next step forward would be changing some parameters on the instrument and collecting some data. To demonstrate this, I’m going to be using the waveform generator to step through a series of frequencies, measuring the resulting frequency using channel 1, and then displaying the result in the prompt.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import visa import time CURRENT_FREQ = 200000 FREQ_INCREMENT = 10000 ENDING_FREQ = 500000 measFreqCh1=0 rm = visa.ResourceManager() MSO_X_2024A = rm.open_resource('USB0::0x0957::0x1796::MY52140586::0::INSTR') # setup MSO_X_2024A.write(':WGEN:FUNCtion %s' % ('SINusoid')) # set wavegen to a sine wave MSO_X_2024A.write(':WGEN:VOLTage %G' % (3.3)) # # with amplitude of 3.3V MSO_X_2024A.write(':WGEN:VOLTage:OFFSet %G' % (1.8)) # # at an offset of 1.8V MSO_X_2024A.write(':WGEN:FREQuency %G' % (200000.0)) # # starting at 200kHz # enable wavegen output MSO_X_2024A.write(':WGEN:OUTPut %d' % (1)) # ramp through a range of target frequencies and print the results to the prompt while (CURRENT_FREQ <= ENDING_FREQ): time.sleep(0.100) temp_values = MSO_X_2024A.query_ascii_values(':MEASure:FREQuency? %s' % ('CHANNEL1')) measFreqCh1 = temp_values[0] print 'Target: {0} Meas: {1}'.format(str(CURRENT_FREQ), str(measFreqCh1)) CURRENT_FREQ = CURRENT_FREQ + FREQ_INCREMENT MSO_X_2024A.write(':WGEN:FREQuency %G' % (float(CURRENT_FREQ))) MSO_X_2024A.close() rm.close() |
References and Links
- Examples on Github
- Keysight IO Libraries Suite
- Keysight Command Expert
- Keysight Benchvue
- Keysight Course: Introduction to Python Automation