Commit 06702a41 authored by Christian Schneider's avatar Christian Schneider
Browse files

ADded Minicircuits Step Attenuator

parent 89f63b67
......@@ -41,7 +41,8 @@ IPList = {'SCOPE': '192.168.0.99',
'SMU5': '192.168.0.148',
'XXF1': '138.232.183.115', # Running on Windows machine
'NI6020': '138.232.183.115', # Running on Windows machine
'DA1': '192.168.0.131'
'DA1': '192.168.0.131',
'DA2': '192.168.0.119::23'
}
#NOTE: please after updating the list, update the date written above.
......@@ -76,8 +76,8 @@ class DA(object):
from .Drivers.RohdeSchwarz.RSC import RSC
self.driver = RSC
elif id_string[:3] == 'DA2':
# TODO
pass
from .Drivers.MiniCircuits.RCDAT import RCDAT
self.driver = RCDAT
else:
if driver is None:
raise Exception('DriverError. Specify Driver')
......
# -*- coding: utf-8 -*- #######################################################
"""
@author: Christian Schneider
Driver for Minicircuits RCDAT Digital Step Attenuator
"""
import visa
VERSION = '1.0.0'
class RCDAT(object):
"""Instrument Driver for Minicircuits Step Attenuator"""
def __init__(self, ip, *pars):
"""
*pars are not used, however required
to be compatible to other devices.
Parameters
-----------
ip : str
IP of spectrum analyzer
"""
# Minicircuits RCDAT30 characteristics
self.max_attenuation = 30 # in dB
self.max_frequency = 30 # in GHz
self.step_attenuation = 0.5 # in dB
self.ch = 0
self.ip = ip
self.__version__ = VERSION
# Initialize connection
rm = visa.ResourceManager()
self._inst = rm.open_resource('TCPIP0::{}::SOCKET'.format(ip))
# Correct for bug in minicircuits communication implementation
self._inst.read_termination = '\n\r'
def com(self, command, arg="?"):
"""Function to communicate with the device. Gives the current status
if no arg is given"""
if arg == "?":
resp = self._inst.query("{}?".format(command))
try:
return float(resp)
except:
return resp.strip('\n')
else:
self._inst.write("{} {}".format(command, arg))
return 0
def identify(self):
"""Query identify string of the device"""
model = self.com(':MN')
snumber = self.com(':SN')
firmware = self.com(':FIRMWARE')
return "MiniCircuits,{},{},{}".format(model, snumber, firmware)
def close(self):
"""Close socket."""
self._inst.close()
def clear(self):
pass
def reset(self):
pass
def abort(self):
pass
def deviation(self):
"""Returns deviation from set attenuation value.
Not implemented for minicircuits."""
return 'see Datasheet'
def list_attenuators(self):
"""List installed attenuators"""
# Just internal for minicricuits
return 'Internal'
def attenuation(self, att='?'):
"""Set/query attenuation.
Parameters
-----------
att : '?', int
Attenuation in dB. Use '?' to query current value.
Note
-----
The 0 level is actually around -3 db
"""
# Set value
if not isinstance(att, str):
# Give warning if out of range
if att > self.max_attenuation:
print('Warning: max attenuation is {}'
.format(self.max_attenuation))
return self.com(':SETATT={}'.format(self.max_attenuation), '')
else:
self.com(':SETATT={}'.format(att), '')
# Query current value
else:
return self.com('ATT')
def set_offset(self, offset='?'):
pass
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment