Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lantz/drivers/agilent/__init__.py
Original file line number Diff line number Diff line change
@@ -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']
94 changes: 94 additions & 0 deletions lantz/drivers/agilent/a33220a.py
Original file line number Diff line number Diff line change
@@ -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)