Difference between revisions of "AGILENT 33220A PYTHON"
From emboxit
m (1 revision) |
|
(No difference)
|
Revision as of 07:41, 26 August 2017
Contents
BitBucket
PyVisa
- Install python 2.7.9 that includes pip Python 2.7.9
- Install pyvisa from command prompt:
python -m pip install -U pyvisa
Worked:
import visa rm = visa.ResourceManager() rm.list_resources() my_instrument = rm.open_resource('USB0::0x0957::0x0407::MY44047602::INSTR') print(my_instrument.query('*IDN?')) my_instrument.write('OUTPut ON')
This works faster:
import visa rm = visa.ResourceManager() #rm.list_resources() AGILENT_33220A = rm.open_resource('USB0::0x0957::0x0407::MY44047602::INSTR') #print(AGILENT_33220A.query('*IDN?')) AGILENT_33220A.write('OUTPut ON')
- AUTO RECOGNITION OF SERIAL NUMBER
rm = visa.ResourceManager() resource_list = rm.list_resources() resource = "" for index in range(len(resource_list)): if "0x0957::0x0407::" in resource_list[index]: resource = resource_list[index] break if resource != "": AGILENT_33220A = rm.open_resource(resource) print(AGILENT_33220A.query('*IDN?')) else: print "Error: Agilent 33220A not connected." sys.exit() AGILENT_33220A.write('*RST') AGILENT_33220A.write('FUNCtion SINusoid') AGILENT_33220A.write('OUTPut:LOAD 50') AGILENT_33220A.write('VOLTage 1') AGILENT_33220A.write('FREQuency 25000') AGILENT_33220A.write('OUTPut ON') AGILENT_33220A.write('FREQuency 26000') AGILENT_33220A.write('SWEep:STATe ON')
Scanning
- For available remote commands: Agilent 33220A 20 MHz Waveform Generator User's Guide
import sys import visa #rm = visa.ResourceManager() #rm.list_resources() #AGILENT_33220A = rm.open_resource('USB0::0x0957::0x0407::MY44047602::INSTR') #print(AGILENT_33220A.query('*IDN?')) rm = visa.ResourceManager() resource_list = rm.list_resources() resource = "" for index in range(len(resource_list)): if "0x0957::0x0407::" in resource_list[index]: resource = resource_list[index] break if resource != "": AGILENT_33220A = rm.open_resource(resource) print(AGILENT_33220A.query('*IDN?')) else: print "Error: Agilent 33220A not connected." sys.exit() AGILENT_33220A.write('*RST') AGILENT_33220A.write('FUNCtion SINusoid') AGILENT_33220A.write('OUTPut:LOAD 50') AGILENT_33220A.write('VOLTage 4') AGILENT_33220A.write('FREQuency 25000') AGILENT_33220A.write('OUTPut ON') AGILENT_33220A.write('FREQuency 26000') AGILENT_33220A.write('SWEep:STATe ON') AGILENT_33220A.write('FREQuency:STARt 1000') AGILENT_33220A.write('FREQuency:STOP 10000') AGILENT_33220A.write('SWEep:TIME 0.3') AGILENT_33220A.write('MARKer:FREQuency 2000') AGILENT_33220A.write('MARKer On')
Peak detection
- Install matplotlib:
python -m pip install matplotlib
- copy to C:\Python27\Scripts
- numpy-1.12.0b1+mkl-cp27-cp27m-win_amd64.whl
- scipy-0.18.1-cp27-cp27m-win_amd64.whl
pip install "numpy-1.12.0b1+mkl-cp27-cp27m-win_amd64.whl" pip install "scipy-0.18.1-cp27-cp27m-win_amd64.whl"
<python> import numpy import peakutils from peakutils.plot import plot as pplot from matplotlib import pyplot
centers = (30.5, 72.3)
x = numpy.linspace(0, 120, 121)
y = (peakutils.gaussian(x, 5, centers[0], 3) +
peakutils.gaussian(x, 7, centers[1], 10) + numpy.random.rand(x.size))
pyplot.figure(figsize=(10,6)) pyplot.plot(x, y) pyplot.title("Data with noise")
indexes = peakutils.indexes(y, thres=0.5, min_dist=30) print(indexes) print(x[indexes], y[indexes]) pyplot.figure(figsize=(10,6)) pplot(x, y, indexes) pyplot.title('First estimate')