Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Experimental Physics
Quantum Circuits
python-repo
Commits
5445010c
Commit
5445010c
authored
Apr 22, 2021
by
Romain Baptiste Dominique Albert
Browse files
Bug correction for preliminary support
parent
508c34a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
71 deletions
+101
-71
Instruments/CS.py
Instruments/CS.py
+49
-27
Instruments/Drivers/iTest/BE2142C.py
Instruments/Drivers/iTest/BE2142C.py
+52
-44
No files found.
Instruments/CS.py
View file @
5445010c
...
...
@@ -86,6 +86,9 @@ class CS(object):
elif
id_string
[:
4
]
==
'YOKO'
:
from
.Drivers.Yokogawa.GS200
import
GS200
self
.
driver
=
GS200
elif
id_string
[:
5
]
==
'ITEST'
:
from
.Drivers.iTest.BE2142C
import
BE2142
self
.
driver
=
BE2142
else
:
if
driver
is
None
:
raise
Exception
(
'DriverError. Specify Driver'
)
...
...
@@ -95,19 +98,28 @@ class CS(object):
# Connect to device ####################################################
self
.
instr
=
None
self
.
init_driver
()
self
.
instr
=
self
.
driver
(
self
.
ip
,
self
.
ch
,
cur_lim
=
self
.
cur_lim
,
vol_lim
=
self
.
vol_lim
)
print
(
"{cs} - Channel {channel}"
.
format
(
cs
=
id_string
,
channel
=
channel
))
print
(
"Identify: "
+
self
.
instr
.
identify
())
# Identify at beginning
print
(
"IP: "
+
self
.
ip
)
# Sweep to zero
if
reset
:
self
.
ramp
(
0
,
safe_mode
=
False
)
if
self
.
output
():
print
(
'Ramping to zero, this might take some time'
)
if
id_string
[:
5
]
!=
'ITEST'
:
self
.
ramp
(
0
,
safe_mode
=
False
)
else
:
self
.
ramp
(
0
,
I_step
=
1e-3
,
safe_mode
=
False
)
else
:
self
.
output_level
(
0.
)
self
.
output
(
0
)
# Set limits
self
.
set_limits
(
I_max
=
self
.
cur_lim
,
V_max
=
self
.
vol_lim
)
if
id_string
[:
5
]
!=
'ITEST'
:
# Set Output to current
self
.
output_mode
(
"CURR"
)
self
.
output_mode
(
"CURR"
)
update_db
(
self
)
def
identify
(
self
):
...
...
@@ -170,25 +182,30 @@ class CS(object):
if
str
(
arg
)
!=
"?"
:
update_db
(
self
)
elif
self
.
instr
.
check_compliance
(
self
.
ch
):
print
(
'Warning: Device in compliance'
)
return
resp
def
show_limits
(
self
,
prints
=
True
):
"""Returns current limits.
min_cur, max_cur, min_vol, max_vol
"""
lims
=
(
-
self
.
instr
.
cur_lim
,
self
.
instr
.
cur_lim
,
-
self
.
instr
.
vol_lim
,
self
.
instr
.
vol_lim
)
if
prints
:
print
(
"Minimal Current: {:.2e} A | Maximal Current: {:.2e} A"
.
format
(
lims
[
0
],
lims
[
1
]))
print
(
"Minimal Voltage: {:.2e} V | Maximal Voltage: {:.2e} V"
.
format
(
lims
[
2
],
lims
[
3
]))
return
lims
def
set_limits
(
self
,
I_max
,
V_max
,
output_protection
=
False
,
if
self
.
id
[:
5
]
!=
'ITEST'
:
lims
=
(
-
self
.
instr
.
cur_lim
,
self
.
instr
.
cur_lim
,
-
self
.
instr
.
vol_lim
,
self
.
instr
.
vol_lim
)
if
prints
:
print
(
"Minimal Current: {:.2e} A | Maximal Current: {:.2e} A"
.
format
(
lims
[
0
],
lims
[
1
]))
print
(
"Minimal Voltage: {:.2e} V | Maximal Voltage: {:.2e} V"
.
format
(
lims
[
2
],
lims
[
3
]))
return
lims
else
:
limits
=
(
-
self
.
instr
.
current_limit
,
self
.
instr
.
current_limit
)
if
prints
:
print
(
"Minimal Current: {:.2e} A | Maximal Current: {:.2e} A"
.
format
(
limits
[
0
],
limits
[
1
]))
return
limits
def
set_limits
(
self
,
I_max
,
V_max
=
None
,
output_protection
=
False
,
print_status
=
True
):
"""This function sets the limits of the output
The corresponding values for the compliance are taken from the
...
...
@@ -259,12 +276,14 @@ class CS(object):
else
'OFF'
),
'Mode'
:
self
.
output_mode
(),
'Output Level'
:
self
.
output_level
(),
'Limit Voltage'
:
'{} mV | {} mV'
.
format
(
lims
[
2
]
*
1e3
,
lims
[
3
]
*
1e3
),
'Floating'
:
str
(
self
.
floating
()),
'Limit Current'
:
'{} mA | {} mA'
.
format
(
lims
[
0
]
*
1e3
,
lims
[
1
]
*
1e3
)
,
'Floating'
:
str
(
self
.
floating
())
lims
[
1
]
*
1e3
)
}
if
self
.
id
[:
5
]
!=
'ITEST'
:
dct
[
'Limit Voltage'
]
=
'{} mV | {} mV'
.
format
(
lims
[
2
]
*
1e3
,
lims
[
3
]
*
1e3
)
msments
=
self
.
meas
()
if
msments
:
dct
.
update
(
msments
)
...
...
@@ -277,11 +296,11 @@ class CS(object):
else
'OFF'
),
'Mode'
:
self
.
output_mode
(),
'Output Level'
:
self
.
output_level
(),
'Limit Voltage'
:
lims
[
-
1
],
'Limit Current'
:
lims
[
1
],
'Floating'
:
str
(
self
.
floating
())
'Floating'
:
str
(
self
.
floating
()),
'Limit Current'
:
lims
[
1
]
}
if
self
.
id
[:
5
]
!=
'ITEST'
:
dct
[
'Limit Voltage'
]
=
lims
[
-
1
]
return
dct
else
:
...
...
@@ -290,5 +309,8 @@ class CS(object):
self
.
instr
.
output_level
(
dictionary
[
'Output Level'
])
if
self
.
id
[:
3
]
==
'SMU'
:
self
.
instr
.
floating
(
dictionary
[
'Floating'
])
self
.
set_limits
(
dictionary
[
'Limit Current'
],
dictionary
[
'Limit Voltage'
],
print_status
=
False
)
if
self
.
id
[:
5
]
!=
'ITEST'
:
self
.
set_limits
(
dictionary
[
'Limit Current'
],
dictionary
[
'Limit Voltage'
],
print_status
=
False
)
else
:
self
.
set_limits
(
dictionary
[
'Limit Current'
],
print_status
=
False
)
Instruments/Drivers/iTest/BE2142C.py
View file @
5445010c
...
...
@@ -23,11 +23,7 @@ class BE2142(object):
Reset the device to default settings at initialization
"""
def
__init__
(
self
,
ip_and_board
,
channel
,
current_limit
=
1e-3
,
reset
=
False
,
range
=
2
):
"""
Range= 2 -> 12V
"""
def
__init__
(
self
,
ip_and_board
,
channel
,
cur_lim
=
1e-3
,
vol_lim
=
None
,
reset
=
False
,
range
=
1
):
self
.
version
=
'1.'
ip
,
board
=
ip_and_board
.
split
(
'@'
)
...
...
@@ -35,17 +31,17 @@ class BE2142(object):
self
.
board
=
int
(
board
)
self
.
channel
=
channel
self
.
output_activated
=
False
self
.
_output_activated
=
False
# Initialize device
self
.
rm
=
visa
.
ResourceManager
()
self
.
set_range
(
range
)
# Safety compliance values
self
.
current_limit
=
cur
rent
_lim
it
if
cur
rent
_lim
it
is
not
None
:
self
.
set_limits
(
cur
rent
_lim
it
,
print_status
=
True
)
self
.
current_limit
=
cur_lim
if
cur_lim
is
not
None
:
self
.
set_limits
(
cur_lim
,
print_status
=
True
)
# Initialize device
self
.
rm
=
visa
.
ResourceManager
()
# Reset
if
reset
:
self
.
reset
()
...
...
@@ -63,7 +59,7 @@ class BE2142(object):
connection is fast with this instrument so it is not a problem.
"""
with
rm
.
open_resource
(
'TCPIP::{}::5025::SOCKET'
.
format
(
self
.
ip
))
as
inst
:
with
self
.
rm
.
open_resource
(
'TCPIP::{}::5025::SOCKET'
.
format
(
self
.
ip
))
as
inst
:
inst
.
read_termination
=
'
\n
'
inst
.
write
(
'INST {:d}'
.
format
(
self
.
board
))
if
bool_channel
:
...
...
@@ -81,9 +77,10 @@ class BE2142(object):
return
0
def
close
(
self
):
'''The connection with the instrument is cloed automatically
after each communication. Keep for compatibilty'''
return
None
'''Put the channel to zero and disconnect the output. Notice that the connection with
the instrument is closed automatically after each communication.'''
self
.
output_level
(
0.
)
self
.
output
(
'OFF'
)
def
identify
(
self
):
"""Identification of the device"""
...
...
@@ -95,7 +92,9 @@ class BE2142(object):
def
reset
(
self
):
""" Resets machine to this default settings."""
## To be completed -> Sure, other parameter to fix...
self
.
output
(
'OFF'
)
self
.
output_level
(
0.
)
self
.
range
(
1
)
self
.
com
(
'LIMIT:STATE OFF'
)
def
output
(
self
,
arg
=
'?'
):
...
...
@@ -113,19 +112,24 @@ class BE2142(object):
"""
if
arg
not
in
[
'?'
,
'ON'
,
1
,
'1'
,
'OFF'
,
0
,
'0'
]:
raise
ValueError
(
'Output state invalid.'
)
raise
ValueError
(
'Output state is invalid.'
)
if
arg
==
1
or
arg
==
'1'
:
arg
=
'ON'
elif
arg
==
0
or
arg
==
'0'
:
arg
=
'OFF'
tmp
=
self
.
com
(
'OUTPUT'
,
arg
)
if
tmp
is
not
None
:
if
arg
==
'?'
:
return
int
(
tmp
)
if
arg
==
'ON'
or
arg
==
1
or
arg
==
'1'
:
self
.
output_activated
=
True
if
arg
==
'ON'
:
self
.
_
output_activated
=
True
else
:
self
.
output_activated
=
False
self
.
_
output_activated
=
False
# Utilities functions #####################################################
def
set_limits
(
self
,
current_limit
=
1e-3
,
print_status
=
True
):
def
set_limits
(
self
,
i_max
=
1e-3
,
v_max
=
None
,
delay
=
1e-0
,
print_status
=
True
):
"""Set the limits of the output for the channel.
Parameters
...
...
@@ -134,13 +138,13 @@ class BE2142(object):
Sets the maximum value, default 1mA
"""
self
.
current_limit
=
fabs
(
float
(
current_limit
))
self
.
current_limit
=
fabs
(
float
(
i_max
))
if
self
.
current_limit
>
15e-3
:
raise
ValueError
(
'You cannot fix a current limit ({:f} A) higher than what the '
\
'voltage source can deliver (0.015 A)'
.
format
(
self
.
current_limit
))
self
.
com
(
'LIMIT:STATE'
,
'ON'
)
self
.
com
(
'LIMIT:DELAY'
,
'0'
)
self
.
com
(
'LIMIT:DELAY'
,
delay
*
1e3
)
self
.
com
(
'HALT:STATE'
,
'0'
)
self
.
com
(
'LIMIT:CURRENT:UPPER'
,
self
.
current_limit
)
...
...
@@ -149,11 +153,15 @@ class BE2142(object):
if
print_status
:
print
(
"Compliance set to {} A"
.
format
(
self
.
current_limit
))
def
check_
limit
(
self
):
def
check_
compliance
(
self
,
channel
=
None
):
"""Check if the current limit was exceeded and raise an exception if true
"""
fail
=
self
.
com
(
'LIMit:FAIL'
,
'?'
)
if
fail
==
1
:
Parameters
-----------
channel : for compatibility
"""
fail
=
int
(
self
.
com
(
'LIMit:FAIL'
,
'?'
))
if
fail
==
3
or
fail
==
4
:
raise
Exception
(
'The current limit for the iTest was reached. The output was '
'automatically disactivated. Solve the issue and call clear_limit '
'function before putting the output at on again'
)
...
...
@@ -192,8 +200,8 @@ class BE2142(object):
Parameters
-----------
arg : 1, 2, '?'
1 means -1
.
2V +1
.
2V range
2 means -12V +12V range
1 means -12V +12V range
2 means -1
.
2V +1
.
2V range
"""
...
...
@@ -204,13 +212,13 @@ class BE2142(object):
if
range
!=
'?'
:
self
.
range
=
range
if
output_activated
and
range
!=
'?'
:
if
self
.
_
output_activated
and
range
!=
'?'
:
raise
ValueError
(
'You must stop the output before changing the range of iTest source. '
'Notice that there are no real autoranging using these sources.'
)
'Notice that there are no real auto
-
ranging using these sources.'
)
self
.
com
(
'VOLTage:RANGe ,'
,
arg
)
self
.
com
(
'VOLTage:RANGe ,'
,
range
)
def
output_mode
(
self
,
mode
=
'?'
):
def
output_mode
(
self
,
arg
=
'?'
):
"""Set/query current Output mode
Implemented for compatibility reasons, only VOLT mode is available. Current can be generated
...
...
@@ -220,13 +228,13 @@ class BE2142(object):
-----------
arg : 'VOLT', '?'
"""
if
mode
!=
'VOLT'
or
mode
!=
'?'
:
if
arg
not
in
[
'VOLT'
,
'?'
]
:
raise
ValueError
(
'The iTest source can only output voltage. Use a resistor to create '
'a current source'
)
else
:
return
'VOLT'
def
output_off_mode
(
self
,
mode
=
'?'
):
def
output_off_mode
(
self
,
arg
=
'?'
):
"""
Not available for iTest source
"""
...
...
@@ -248,20 +256,20 @@ class BE2142(object):
if
arg
==
'?'
:
if
safe_mode
:
self
.
check_
limit
()
self
.
check_
compliance
()
return
self
.
com
(
'VOLTage'
,
arg
)
arg
=
float
(
arg
)
if
self
.
range
==
1
and
fabs
(
arg
)
>
1.2
:
raise
ValueError
(
'Voltage
{}
is too high for the range 1.2V currently used.'
%
arg
)
if
self
.
range
==
2
and
fabs
(
arg
)
>
12
:
raise
ValueError
(
'Voltage
{}
is too high for the range 12V currently used.'
%
arg
)
if
self
.
range
==
2
and
fabs
(
arg
)
>
1.2
:
raise
ValueError
(
'Voltage
%f
is too high for the range 1.2V currently used.'
%
arg
)
if
self
.
range
==
1
and
fabs
(
arg
)
>
12
:
raise
ValueError
(
'Voltage
%f
is too high for the range 12V currently used.'
%
arg
)
self
.
com
(
'VOLTage'
,
arg
)
if
safe_mode
:
self
.
check_
limit
()
self
.
check_
compliance
()
def
floating
(
self
,
mode
=
'?'
):
"""The iTest/Bilt BE2142 voltage source is always floating. However,
...
...
@@ -279,7 +287,7 @@ class BE2142(object):
def
meas_curr
(
self
):
"""Return spot measurement of current"""
return
float
(
self
.
com
(
'MEASure:
VOLTage
'
))
return
float
(
self
.
com
(
'MEASure:
CURRent
'
))
def
stairsweep
(
self
,
minval
,
maxval
,
points
,
int_time
=
0.01
):
"""Not yet implemented
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment