Files
Helmholtz_Test_Bench/globals.py
T
Martin Zietz c0fb71f73f started on config file
renamed settings.py to globals.py
2021-01-28 12:50:13 +01:00

50 lines
1.4 KiB
Python

import numpy as np
from configparser import ConfigParser
# global variables set in other files
XY_DEVICE = None
Z_DEVICE = None
ARDUINO = None
X_AXIS = None # object structure: (device, channel, arduino pin, axis index)
Y_AXIS = None
Z_AXIS = None
AXES = None # list containing [X_AXIS, Y_AXIS, Z_AXIS]
app = None
def read_config(file): # attempt to read config file
config_object = ConfigParser()
config_object.read(file)
print(config_object["X-Axis"]["coil_consthhh"])
def create_config(file):
config = ConfigParser()
config["X-Axis"] = {
"coil_const": str(38.6 * 1e-6)
}
with open(file, 'w') as conf:
config.write(conf)
# Constants:
COIL_CONST = np.array([38.6, 38.45, 37.9]) * 1e-6 # Coil constants [x,y,z] in T/A
AMBIENT_FIELD = np.array([30, 30, 30]) * 1e-6 # ambient magnetic field in measurement area, to be cancelled out
RESISTANCES = np.array([1.7, 1.7, 1.7]) # resistance of [x,y,z] circuits
MAX_WATTS = np.array([15, 15, 15]) # max. allowed power for [x,y,z] circuits
MAX_VOLTS = [16, 16, 16] # max. allowed voltage, limited to 16V by used diodes!
# COM-Ports for power supply units:
XY_PORT = "COM10" # placeholders
Z_PORT = "COM11"
AXIS_NAMES = ["X-Axis", "Y-Axis", "Z-Axis"]
ports = [XY_PORT, XY_PORT, Z_PORT]
RELAY_PINS = [15, 16, 17] # pin on the Arduino for switching relay of each axis [x,y,z]