#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
# Copyright 2012-2017 Frédéric Magniette, Miguel Rubio-Roy
# This file is part of Pyrame.
#
# Pyrame is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrame is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrame. If not, see <http://www.gnu.org/licenses/>
import scpi
# CLASS ##########################################################
class ag_n6700b_class(scpi.scpi):
# Available channels
channels=["1","2","3","4"]
def __init__(self):
super(ag_n6700b_class,self).__init__("ag_n6700b")
def set_voltage(self,ag_n6700b_id,voltage,slew_rate="undef"):
if slew_rate!="undef":
slew_rate="MAX"
else:
slew_rate="%.4f" % (slew_rate)
command=r"SOUR:VOLT:SLEW {slew_rate}, (@{channel})\n"
command+=r"SOUR:CURR {current:.4f}, (@{channel})\n"
command+=r"SOUR:VOLT {voltage:.4f}, (@{channel})"
return super(ag_n6700b_class,self).set_voltage(ag_n6700b_id,voltage,command)
def set_current(self,ag_n6700b_id,current):
command= r"SOUR:VOLT {voltage:.4f}, (@{channel})\n"
command+=r"SOUR:CURR {current:.4f}, (@{channel})"
return super(ag_n6700b_class,self).set_current(ag_n6700b_id,current,command)
def set_voltage_limit(self,ag_n6700b_id,voltage_limit):
command= r"SOUR:VOLT:PROT:LEV {voltage_limit:.4f}, (@{channel})\n"
command+=r"SOUR:VOLT {voltage_limit:.4f}, (@{channel})"
return super(ag_n6700b_class,self).set_voltage_limit(ag_n6700b_id,voltage_limit,command)
def set_current_limit(self,ag_n6700b_id,current_limit):
command=r"SOUR:CURR {current_limit:.4f}, (@{channel})"
return super(ag_n6700b_class,self).set_current_limit(ag_n6700b_id,current_limit,command)
def set_rise_delay_ag_n6700b(self,ag_n6700b_id,rise_delay):
command=r"OUTP:DEL:RISE %.4f, (@{channel})" % (rise_delay)
return self.simple_command(ag_n6700b_id,command)
def get_voltage(self,ag_n6700b_id):
query=r"MEAS:VOLT? (@{channel})"
return self.simple_query(ag_n6700b_id,query)
def get_current(self,ag_n6700b_id):
query=r"MEAS:CURR? (@{channel})"
return self.simple_query(ag_n6700b_id,query)
def power_on(self,ag_n6700b_id):
command=r"OUTP ON, (@{channel})"
return self.simple_command(ag_n6700b_id,command)
def power_off(self,ag_n6700b_id):
command=r"OUTP OFF, (@{channel})"
return self.simple_command(ag_n6700b_id,command)
# CREATE POOL ####################################################
me=ag_n6700b_class()
# COMMANDS #######################################################
[docs]def init_ag_n6700b(ag_n6700b_id,conf_string):
"""Initialize ag_n6700b power supply identified by *ag_n6700b_id*
*conf_string* must include the parameter:
- bus: conf_string of the underlying link module (GPIB, TCP, ...)
- channel: channel on which the id will act"""
return me.init(ag_n6700b_id,conf_string)
[docs]def deinit_ag_n6700b(ag_n6700b_id):
"Deinitialize an ag_n6700b"
return me.deinit(ag_n6700b_id)
[docs]def config_ag_n6700b(ag_n6700b_id):
"Configure an ag_n6700b"
return me.config(ag_n6700b_id)
[docs]def inval_ag_n6700b(ag_n6700b_id):
"Invalidate an ag_n6700b"
return me.inval(ag_n6700b_id)
[docs]def reset_ag_n6700b(ag_n6700b_id):
"Send RST signal to PS"
return me.reset(ag_n6700b_id)
[docs]def set_voltage_ag_n6700b(ag_n6700b_id,voltage):
"Set voltage in Volts. channel can be 1, 2, 3 or 4."
return me.set_voltage(ag_n6700b_id,voltage)
[docs]def set_current_ag_n6700b(ag_n6700b_id,current):
"Set current in Ampers. channel can be 1, 2, 3 or 4."
return me.set_current(ag_n6700b_id,current)
[docs]def set_voltage_limit_ag_n6700b(ag_n6700b_id,voltage_limit):
"Set voltage limit in Volts. channel can be 1, 2, 3 or 4. Over Voltage Protection is also set."
return me.set_voltage_limit(ag_n6700b_id,voltage_limit)
[docs]def set_current_limit_ag_n6700b(ag_n6700b_id,current_limit):
"Set current limit in Ampers. channel can be 1, 2, 3 or 4."
return me.set_current_limit(ag_n6700b_id,current_limit)
[docs]def get_voltage_ag_n6700b(ag_n6700b_id):
"Get voltage in Volts. channel can be 1, 2, 3 or 4."
return me.get_voltage(ag_n6700b_id)
[docs]def get_current_ag_n6700b(ag_n6700b_id):
"Get current in Ampers. channel can be 1, 2, 3 or 4."
return me.get_current(ag_n6700b_id)
[docs]def power_on_ag_n6700b(ag_n6700b_id):
"Turn on channel. channel can be 1, 2, 3 or 4."
return me.power_on(ag_n6700b_id)
[docs]def power_off_ag_n6700b(ag_n6700b_id):
"Turn off channel. channel can be 1, 2, 3 or 4."
return me.power_off(ag_n6700b_id)
[docs]def set_rise_delay_ag_n6700b(ag_n6700_id,rise_delay):
"Set power-on (rise) delay in seconds. channel can be 1, 2, 3 or 4."
return me.set_rise_delay(ag_n6700b_id,rise_delay)
[docs]def free_command_ag_n6700b(ag_n6700b_id,command):
"Send a raw command to the PS"
return me.free_command(ag_n6700b_id,command)
[docs]def get_error_queue_ag_n6700b(ag_n6700b_id):
"Read error queue until the end (code 0)"
return me.get_error_queue(ag_n6700b_id)