From 4d1f5a7437455e95f9f975ba8112424bf9cef39a Mon Sep 17 00:00:00 2001 From: IRS Cleanroom Laptop Date: Thu, 19 Aug 2021 15:08:53 +0200 Subject: [PATCH] Fixed issue with QL355TP driver. Calibration methods validated. --- src/calibration.py | 15 +++++++-------- src/psu_device.py | 10 +++++----- tools/fgm3d_adapter.py | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/calibration.py b/src/calibration.py index c18a67c..e5e411d 100644 --- a/src/calibration.py +++ b/src/calibration.py @@ -15,12 +15,12 @@ class AmbientFieldCalibration(Thread): The magnetometer does not need to be centered. The axes of the magnetometer must match the coil configuration!""" # Timeout/settling time for the calibration procedure. An acceptable duration for the PI is required - SETTLE_TIME = 15 + SETTLE_TIME = 45 # PID controller time delta - TIME_DELTA = 0.25 - P_CONTROL = -1e4 # 0.4 A/s slew-rate at 40uT - I_CONTROL = -2.5e4 # 0.025 A/s slew-rate for 1uTs - I_LIMIT = 1e-6 # uTs, Limit I to 0.025 A/s slew-rate to prevent wind-up + TIME_DELTA = 0.5 + P_CONTROL = -7e3 # 0.2 A/s slew-rate at 40uT + I_CONTROL = 0 # -1e4 # 0.01A/s slew-rate for 1uTs + I_LIMIT = 1e-7 # uTs, Limit I to 0.025 A/s slew-rate to prevent wind-up # D_CONTROL = Not implemented for now def __init__(self, view_queue): @@ -105,8 +105,8 @@ class AmbientFieldCalibration(Thread): class CoilConstantCalibration(Thread): MEASUREMENT_RANGE = 3 # A. Will extend into negative and positive sign - MEASUREMENT_POINTS = 6 # Excludes zero. eg 0.5, 1, 1.5, 2 - SETTLE_TIME = 0.5 # Time until new measurement is ready after setting current + MEASUREMENT_POINTS = 4 # Excludes zero. eg 0.5, 1, 1.5, 2 + SETTLE_TIME = 3 # Time until new measurement is ready after setting current def __init__(self, view_queue): Thread.__init__(self) @@ -179,7 +179,6 @@ class CoilConstantCalibration(Thread): k_deviations[i], _ = self.calculate_standard_deviation(k_samples) # Put device into an off and ready state - time.sleep(3) self.cage_dev.idle() angles = {'xy': self.angle_between(axis_field_directions[0], axis_field_directions[1]) * 180 / pi, diff --git a/src/psu_device.py b/src/psu_device.py index fe8fffb..42c5305 100644 --- a/src/psu_device.py +++ b/src/psu_device.py @@ -198,8 +198,8 @@ class PSUDeviceQL355TP(PSUDevice): # Request current setpoint self._serial_object.write("I{}?\n".format(channel_nr).encode()) resp = self._serial_object.read_until() - # Trim whitespace and units - current_setp = float(resp.decode().rstrip()[:-1]) + # Trim whitespace, prefix and units + current_setp = float(resp.decode().rstrip()[3:-1]) # Request current voltage self._serial_object.write("V{}O?\n".format(channel_nr).encode()) @@ -211,14 +211,14 @@ class PSUDeviceQL355TP(PSUDevice): self._serial_object.write("V{}?\n".format(channel_nr).encode()) resp = self._serial_object.read_until() # Trim whitespace and units - voltage_setp = float(resp.decode().rstrip()[:-1]) + voltage_setp = float(resp.decode().rstrip()[3:-1]) # Format should match the provided template in abstract PSUDevice class. # The remote_active property is assumed to always be True since it cant be read # (it should be since we are talking to it) return {'active': output_active, 'remote_active': True, - 'actual_voltage': voltage, 'limit_voltage': voltage_setp, - 'actual_current': current, 'limit_current': current_setp} + 'voltage': voltage, 'voltage_setpoint': voltage_setp, + 'current': current, 'current_setpoint': current_setp} def set_output_range(self, channel_nr, value_range): """The QL355TP supports various output ranges. We require the 15V/5A mode to achieve the greatest range.""" diff --git a/tools/fgm3d_adapter.py b/tools/fgm3d_adapter.py index 7a151b4..598d392 100644 --- a/tools/fgm3d_adapter.py +++ b/tools/fgm3d_adapter.py @@ -28,7 +28,7 @@ while True: if ready: # Data is not valid otherwise # Only use the x y and z values - tokens = [float(v) for v in new_line.split(";")[1:-1]] + tokens = [float(v.replace(',', '.')) for v in new_line.split(";")[1:-1]] axis_fields = [tokens[m[0]]*m[1] for m in axis_mapping] axis_fields = ["{:.6e}".format(v) for v in axis_fields] s.sendall(("magnetometer_field {} {} {}\n".format(*axis_fields)).encode())