diff --git a/lantz/drivers/agilent/__init__.py b/lantz/drivers/agilent/__init__.py new file mode 100644 index 0000000..6434ba5 --- /dev/null +++ b/lantz/drivers/agilent/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +""" + lantz.drivers.agilent + ~~~~~~~~~~~~~~~~~~~~~ + + :company: Agilent. + :description: Chemical analysis, life sciences and diagnostics. + :website: http://www.agilent.com/ + + --- + + :copyright: 2015 by Lantz Authors, see AUTHORS for more details. + :license: BSD, + +""" + +from .a33220a import A33220A + +__all__ = ['A33220A'] diff --git a/lantz/drivers/agilent/a33220a.py b/lantz/drivers/agilent/a33220a.py new file mode 100644 index 0000000..2eac1dd --- /dev/null +++ b/lantz/drivers/agilent/a33220a.py @@ -0,0 +1,94 @@ +from __future__ import division + +from lantz.messagebased import MessageBasedDriver +from lantz import Action +from lantz import Feat, DictFeat +# from lantz import Q_ + +import numpy as np + + +class A33220A(MessageBasedDriver): + """The agilent 33220a function generator""" + + MANUFACTURER_ID = '0x0957' + MODEL_CODE = '0x0407' + + DEFAULTS = {'USB': {'write_termination': '\n', + 'read_termination': '\n', + 'timeout': 2000, + 'encoding': 'ascii' + }} + @Feat() + def idn(self): + return self.query('*IDN?') + + @Feat() + def func(self): + """ Return the function type. + The options are: + -SINusoid + -SQUare + -RAMP + -PULSe + -NOISe + -DC + -USER + """ + return self.query('FUNC?') + + @func.setter + def func(self,functype): + """ Sets the function type. + """ + self.write('FUNC {}'.format(functype)) + + @Feat(units='Hz') + def freq(self): + """ Return the frequency in hertz. + """ + return self.query('FREQ?') + + @freq.setter + def freq(self,value): + """ Set the frequency. + """ + self.write('FREQ {} Hz'.format(value)) + + @Feat(units='V') + def volt(self): + """ Return the amplitude. + """ + return self.query('VOLT?') + + @volt.setter + def volt(self,value): + """ Sets the output voltage. + """ + self.write('VOLT {} VPP'.format(value)) + + @Feat(units='V') + def offset(self): + """ Return the offset. + """ + return self.query('VOLT:OFFS?') + + @offset.setter + def offset(self,value): + """ Sets the offset + """ + self.write('VOLT:OFFS {}'.format(value)) + + @Action(values={True:'ON', False:'OFF'}) + def output(self,value): + """ Turns the output on or off. + """ + self.write('OUTP {}'.format(value)) + +if __name__ == '__main__': + with A33220A.via_usb() as fgen: + fgen.func = 'SQU' + fgen.freq = 2 * kilohertz + fgen.volt = 1.2 * volt + fgen.offset = 1 * volt + fgen.output(True)