Skip to content

fix cryomagnetics4g driver bug. #7114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions docs/changes/newsfragments/7114.improved_driver
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1. Added missing initialization of `self._RETRY_WRITE_ASK` and `self._RETRY_TIME` in the `write_raw` method to handle communication retries on VisaIOError.
2. Updated `set_field` to correctly recognize Standby as a valid final state when setting the magnetic field to 0 T.
3. Modified `wait_while_ramping` to check the actual magnetic field value via `self._get_field()` instead of relying on the status byte, since the instrument may stay in the Ramping state even after reaching the target field.
4. Fixed unit parsing to handle unexpected trailing characters in the instrument's response. (e.g., "\r").
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def __init__(
coil_constant: float,
**kwargs: Unpack[VisaInstrumentKWArgs],
):
self._RETRY_WRITE_ASK = True
self._RETRY_TIME = 1

super().__init__(name, address, **kwargs)

self.coil_constant = coil_constant
Expand Down Expand Up @@ -298,7 +301,7 @@ def set_field(self, field_setpoint: float, block: bool = True) -> None:
self.log.debug("Finished blocking ramp")
# If we are now holding, it was successful

if not exit_state.holding:
if not exit_state.standby and not exit_state.holding:
msg = "_set_field({}) failed with state: {}"
raise Cryomagnetics4GException(msg.format(field_setpoint, exit_state))

Expand All @@ -307,8 +310,8 @@ def wait_while_ramping(
) -> CryomagneticsOperatingState:
"""Waits while the magnet is ramping, checking the status byte instead of field value."""
while True:
status_byte = int(self.ask("*STB?"))
if not bool(status_byte & 1): # Check if ramping bit is clear
current_field = self._get_field()
if abs(value - current_field) < 1e-4:
break
self._sleep(self.ramping_state_check_interval())
self.write("SWEEP PAUSE")
Expand Down Expand Up @@ -355,7 +358,7 @@ def _get_field(self) -> float:
)

# Return value in Tesla, only converting if necessary
if self.units() == "T":
if self.units().strip() == "T":
return numeric_value * self.KG_TO_TESLA
else:
return numeric_value
Expand Down
Loading