From df9cdd6f0d63f7c73acfe29647df3a277e197e96 Mon Sep 17 00:00:00 2001 From: Martin Zietz Date: Tue, 15 Dec 2020 16:49:57 +0100 Subject: [PATCH] limited voltage Used diodes can tolerate 17V max, limited script to 16V --- cage_func.py | 3 ++- globals.py | 1 + main.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cage_func.py b/cage_func.py index c5a2dd3..8d15ae1 100644 --- a/cage_func.py +++ b/cage_func.py @@ -89,4 +89,5 @@ def set_axis_current(axis, value): # sets current with correct polarity on one else: raise Exception("This should be impossible.") device.set_current(abs(value), channel) - device.set_voltage(1.1 * g.maxAmps[axisIndex] * g.resistances[axisIndex]) # set max voltage high enough + maxVoltage = min(max(1.1 * g.maxAmps[axisIndex] * g.resistances[axisIndex], 12), g.maxVolts) # limit voltage + device.set_voltage(maxVoltage) diff --git a/globals.py b/globals.py index 8d67e02..b5e47b3 100644 --- a/globals.py +++ b/globals.py @@ -14,6 +14,7 @@ global zAxis global resistances global maxAmps global maxWatts +global maxVolts global arduino diff --git a/main.py b/main.py index ac17039..bd92438 100644 --- a/main.py +++ b/main.py @@ -13,6 +13,7 @@ g.Coil_const = np.array([38.6, 38.45, 37.9])*1e-9 # Coil constants [x,y,z] in T g.ambientField = np.array([80])*1e-6 # ambient magnetic field in measurement area, to be cancelled out g.resistances = np.array([3.9, 1, 1]) # resistance of [x,y,z] circuits g.maxWatts = np.array([8, 0, 0]) # max. allowed power for [x,y,z] circuits +g.maxVolts = 16 # max. allowed voltage, limited to 16V by used diodes! # COM-Ports for power supply units: g.xyPort = "COM1" # placeholders