Skip to content

Commit

Permalink
E3632A -> auto formatting, convert self.value to float, handle averag…
Browse files Browse the repository at this point in the history
…ing input
  • Loading branch information
franz-sweepMe committed Nov 8, 2024
1 parent 4432ea6 commit fddbf59
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions src/SMU-Keysight_E3632A/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# find those in the corresponding folders or contact the maintainer.
#
# MIT License
#
#
# Copyright (c) 2024 SweepMe! GmbH (sweep-me.net)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -36,8 +36,7 @@


class Device(EmptyDevice):
"""
description =
"""description =
<p><strong>Notes:</strong></p>
<ul>
<li>COM Port untested as of 20240619</li>
Expand All @@ -47,7 +46,6 @@ class Device(EmptyDevice):
"""

def __init__(self):

EmptyDevice.__init__(self)

self.shortname = "E3632A"
Expand All @@ -60,18 +58,16 @@ def __init__(self):
self.port_manager = True
self.port_types = ["COM", "GPIB"]

self.port_properties = {"timeout": 1,
}
self.port_properties = {
"timeout": 1,
}

def set_GUIparameter(self):

gui_parameter = {
"SweepMode": ["Voltage in V"],

# NOT NEEDED with E3632A as it is a single channel instrument
# but will be used for other E36xxA instruments later.
# "Channel": [1],

"RouteOut": ["Front"],
"Compliance": 1,
"RangeVoltage": ["15 V / 7 A", "30 V / 4 A"],
Expand All @@ -92,11 +88,11 @@ def get_GUIparameter(self, parameter={}):

self.voltage_range = parameter["RangeVoltage"]
self.average = int(parameter["Average"])
if self.average == 0:
msg = ("Average of 0 not possible. Disable average by setting it to 1.")

if self.average < 1:
msg = "Average smaller 1 not possible. Disable average by setting it to 1."
raise Exception(msg)

def initialize(self):
self.port.write("*IDN?")
identifier = self.port.read()
Expand All @@ -107,7 +103,6 @@ def initialize(self):
self.display_off()

def configure(self):

# self.port.write("VOLT:PROT:STAT OFF") # output voltage protection disabled
# self.port.write("CURR:PROT:STAT OFF") # output current protection disabled

Expand Down Expand Up @@ -154,39 +149,40 @@ def poweroff(self):
self.port.write("OUTP:STAT OFF")

def apply(self):
if float(self.value) > 15.45 and float(self.currentlimit) > 4.12:
msg = ("The next requested step would exceed 15.45 V with current limit higher than 4.12 A.\n\n"
"Please either stop at 15.45 V max or lower current compliance limit to 4.12 A max.")
self.value = float(self.value)
if self.value > 15.45 and float(self.currentlimit) > 4.12:
msg = (
"The next requested step would exceed 15.45 V with current limit higher than 4.12 A.\n\n"
"Please either stop at 15.45 V max or lower current compliance limit to 4.12 A max."
)
raise Exception(msg)
else:
self.port.write("VOLT:LEV:IMM %1.4f" % float(self.value))
self.port.write("VOLT:LEV:IMM %1.4f" % self.value)
# the adjustment of the output takes some time; without the delay, the timing is borderline and
# can lead to an Error-113 as the instrument is not ready just yet to receive a new command
time.sleep(0.1)

def measure(self):
self.v = 0
self.i = 0
for n in range(self.average):
for n in range(self.average):
self.port.write("MEAS:VOLT?")
self.v = self.v + float(self.port.read())
self.port.write("MEAS:CURR?")
self.i = self.i + float(self.port.read())

self.v = self.v / self.average
self.i = self.i / self.average

def call(self):
return [self.v, self.i]

def display_off(self):

self.port.write("DISP:STAT OFF")
# wait for display shutdown procedure to complete
# time.sleep(0.5)

def display_on(self):

self.port.write("DISP:STAT ON")
# wait for display switch-on procedure to complete
# time.sleep(0.5)

0 comments on commit fddbf59

Please sign in to comment.