forked from zietzm/Helmholtz_Test_Bench
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
import numpy as np
|
|
import settings as g
|
|
import cage_func as func
|
|
# from pyps2000b import PS2000B
|
|
from Arduino import Arduino
|
|
|
|
# User Inputs/Configuration----------------------------------
|
|
# Desired output:
|
|
mag_vec1 = np.array([10, 10, 5])*1e-6
|
|
|
|
# Constants:
|
|
g.COIL_CONST = np.array([38.6, 38.45, 37.9]) * 1e-9 # Coil constants [x,y,z] in T/A
|
|
g.AMBIENT_FIELD = 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.MAX_WATTS = np.array([8, 0, 0]) # max. allowed power for [x,y,z] circuits
|
|
g.MAX_VOLTS = 16 # max. allowed voltage, limited to 16V by used diodes!
|
|
|
|
# COM-Ports for power supply units:
|
|
g.XY_PORT = "COM1" # placeholders
|
|
g.Z_PORT = "COM2"
|
|
|
|
# Code starts here------------------------------------------
|
|
g.MAX_AMPS = np.sqrt(g.MAX_WATTS / g.RESISTANCES) # calculate maximum currents in each axis
|
|
|
|
print("Connecting to PSUs...")
|
|
func.setup_axes() # initiate communication, set handles
|
|
print("Connecting to Arduino...")
|
|
g.ARDUINO = Arduino() # search for connected arduino and set handle
|
|
print("Arduino found, configuring pins.")
|
|
func.setup_arduino()
|
|
print("Activating PSU outputs...")
|
|
func.activate_all() # activate remote control and outputs on PSUs
|
|
|
|
func.set_field_simple(mag_vec1)
|
|
|
|
func.deactivate_all()
|