Tutorial¶
Note: system setup should be completed first
This example expects a function generator connected to channel 1 of an oscilloscope.
Open an instrument¶
In [1]: from instrument_opening import open_by_name
In [2]: fg = open_by_name(name='old_fg') # name within the configuration file (config.yaml)
Opened Instrument: Agilent Technologies,33220A,MY44060286,2.07-2.06-22-2
Simple set and get combination¶
In [3]: fg.set('offset', 0.5);
In [4]: print('Readback of Function Generator offset = {} [V]'.format(fg.get('offset')))
Readback of Function Generator offset = 0.5 [V]
In [5]: fg.set('v', 1);
In [6]: fg.set('freq', 3.12e3);
In [7]: fg.set('load', 'INF');
In [8]: fg.set('output', 'ON'); # this is an example of a lookup table conversion 'ON' -> 1
Open an oscilloscope in order to demonstrate more complex setters and getters:
In [9]: osc = open_by_name(name='msox_scope') # name within the configuration file (config.yaml)
Opened Instrument: KEYSIGHT TECHNOLOGIES,MSO-X 3034T,MY58030693,07.20.2017102614
In [10]: osc.set('time_range', 1e-3);
In [11]: osc.set('chan_scale', 0.2, configs={'chan': 1});
In [12]: osc.set('chan_offset', 0.5, configs={'chan': 1});
Oscilloscope triggering
In [13]: osc.set('trigger_sweep', 'NORM');
In [14]: osc.set('trigger_mode', 'EDGE');
In [15]: osc.set('trigger_slope', 'POS');
In [16]: osc.set('trigger_level', 0.5, configs={'chan': 1});
In [17]: osc.set('trigger_source', 1);
Oscilloscope measurements
In [18]: v_average = osc.get('meas', configs={'meas_type': 'VAV', 'chan': 1});
In [19]: v_pkpk = osc.get('meas', configs={'meas_type': 'VPP', 'chan': 1});
In [20]: v_freq = osc.get('meas', configs={'meas_type': 'FREQ', 'chan': 1});
Print oscilloscope measurements
In [21]: print('Oscilloscope measurements: Average voltage: {} \nPeak-to-peak voltage: {}\n'.format(v_average, v_pkpk))
Oscilloscope measurements: Average voltage: 0.49938
Peak-to-peak voltage: 1.01
In [22]: print('Frequency: {} [kHz]'.format(v_freq/1000))