Qudi
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
magnet.Magnet Class Reference

Magnet positioning software for superconducting magnet. More...

Inheritance diagram for magnet.Magnet:
Inheritance graph
[legend]
Collaboration diagram for magnet.Magnet:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self, kwargs)
 Here the connections to the power supplies and to the counter are established.
 
def on_activate (self)
 
def on_deactivate (self)
 
def utf8_to_byte (self, myutf8)
 Convenience function for code refactoring. More...
 
def byte_to_utf8 (self, mybytes)
 Convenience function for code refactoring. More...
 
def get_constraints (self)
 Retrieve the hardware constraints from the magnet driving device. More...
 
def tell (self, param_dict)
 Send a command string to the magnet. More...
 
def ask (self, param_dict)
 Asks the magnet a 'question' and returns an answer from it. More...
 
def get_status (self, param_list=None)
 Get the status of the position. More...
 
def heat_switch (self, axis)
 This function enables heating of the PJSwitch, which is a necessary step to conduct current to the coils. More...
 
def heat_all_switches (self)
 Just a convenience function to heat all switches at once, as it is unusual to only apply a magnetic field in one direction.
 
def cool_switch (self, axis)
 Turns off the heating of the PJSwitch, axis depending on user input. More...
 
def cool_all_switches (self)
 Just a convenience function to cool all switches at once This will take 600s. More...
 
def initialize (self)
 
def idle_magnet (self)
 Cool all coils of the superconducting magnet to achieve maximum accuracy after aligning. More...
 
def wake_up_magnet (self)
 Heat all coils of the superconducting magnet to get back to the working state. More...
 
def switch_mode (self, bool_var)
 
def target_field_setpoint (self, param_dict)
 Function to set the target field (in T), which will be reached through the function ramp(self, param_list). More...
 
def ramp (self, param_list=None)
 function to ramp the magnetic field in the direction(s) to the target field values More...
 
def ramp_to_zero (self, axis)
 Function to ramp down a specific coil to zero current. More...
 
def calibrate (self, param_list=None)
 Calibrates the stage. More...
 
def set_coordinates (self, param_dict)
 
def move_abs (self, param_dict)
 Moves stage to absolute position (absolute movement) More...
 
def move_rel (self, param_dict)
 Moves stage in given direction (in spheric coordinates with theta and phi in radian) More...
 
def transform_coordinates (self, param_dict)
 Function for generic coordinate transformation. More...
 
def get_current_field (self)
 Function that asks the magnet for the current field strength in each direction. More...
 
def get_pos (self, param_list=None)
 Gets current position of the stage. More...
 
def stop_hard (self, param_list=None)
 function that pauses the heating of a specific coil depending on the elements in param_list. More...
 
def abort (self)
 Stops movement of the stage. More...
 
def ask_status (self, param_list=None)
 Function that returns the status of the coils ('x','y' and 'z') given in the param_dict. More...
 
def translated_get_status (self, param_list=None)
 Just a translation of the numbers according to the manual supplied by American Magnets, Inc. More...
 
def set_velocity (self, param_dict)
 Function to change the ramp rate in T/s (ampere per second) More...
 
def get_velocity (self, param_list=None)
 Gets the current velocity for all connected axes. More...
 
def check_constraints (self, param_dict)
 
def rho_pos_max (self, param_dict)
 
def update_coordinates (self, param_dict)
 
def set_magnet_idle_state (self, magnet_idle=True)
 Set the magnet to couple/decouple to/from the control. More...
 
def get_magnet_idle_state (self)
 Retrieve the current state of the magnet, whether it is idle or not. More...
 
- Public Member Functions inherited from core.module.BaseMixin
def __init__ (self, manager, name, config=None, callbacks=None, kwargs)
 Initialise Base class object and set up its state machine. More...
 
def log (self)
 Returns a logger object.
 
def is_module_threaded (self)
 Returns whether the module shall be started in a thread.
 
def on_activate (self)
 Method called when module is activated. More...
 
def on_deactivate (self)
 Method called when module is deactivated. More...
 
def getStatusVariables (self)
 Return a dict of variable names and their content representing the module state for saving. More...
 
def setStatusVariables (self, variableDict)
 Give a module a dict of variable names and their content representing the module state. More...
 
def getConfiguration (self)
 Return the configration dictionary for this module. More...
 
def get_connector (self, connector_name)
 Return module connected to the given named connector. More...
 
- Public Member Functions inherited from core.module.ModuleMeta
def __new__ (cls, name, bases, attrs)
 Collect declared Connectors, ConfigOptions and StatusVars into dictionaries. More...
 

Public Attributes

 soc_x
 
 soc_y
 
 soc_z
 
 mode
 
- Public Attributes inherited from core.module.BaseMixin
 module_state
 
 connectors
 

Static Public Attributes

 port = ConfigOption('magnet_port', missing='error')
 
 ip_addr_x = ConfigOption('magnet_IP_address_x', missing='error')
 
 ip_addr_y = ConfigOption('magnet_IP_address_y', missing='error')
 
 ip_addr_z = ConfigOption('magnet_IP_address_z', missing='error')
 
 waitingtime = ConfigOption('magnet_waitingtime', 0.01)
 
 x_constr = ConfigOption('magnet_x_constr', 1.0)
 
 y_constr = ConfigOption('magnet_y_constr', 1.0)
 
 z_constr = ConfigOption('magnet_z_constr', 3.0)
 
 rho_constr = ConfigOption('magnet_rho_constr', 1.2)
 

Detailed Description

Magnet positioning software for superconducting magnet.

Enables precise positioning of the magnetic field in spherical coordinates with the angle theta, phi and the radius rho. The superconducting magnet has three coils, one in x, y and z direction respectively. The current through these coils is used to compute theta, phi and rho. The alignment can be done manually as well as automatically via fluorescence alignment.

Example config for copy-paste:

sc_magnet: module 'sc_magnet.magnet.Magnet' magnet_port 3000 magnet_IP_address_x 192.168.0.12 magnet_IP_address_y 192.168.0.13 magnet_IP_address_z 192.168.0.14 magnet_waitingtime 0.01 # in seconds magnet_x_constr 1.0 magnet_y_constr 2.0 magnet_z_constr 3.0 magnet_rho_constr 1.2

Member Function Documentation

◆ abort()

def magnet.Magnet.abort (   self)

Stops movement of the stage.

Returns
int: error code (0:OK, -1:error)

◆ ask()

def magnet.Magnet.ask (   self,
  param_dict 
)

Asks the magnet a 'question' and returns an answer from it.

Parameters
dictionaryparam_dict: has to have one of the following keys: 'x', 'y' or 'z' the items have to be valid questions for the magnet.
Returns
answer_dict: contains the same labels as the param_dict if it was set correct and the corresponding items are the answers of the magnet (format is string), else an empty dictionary is returned

◆ ask_status()

def magnet.Magnet.ask_status (   self,
  param_list = None 
)

Function that returns the status of the coils ('x','y' and 'z') given in the param_dict.

Parameters
listparam_list: string (elements allowed 'x', 'y' and 'z') for which the status should be returned. Can be None, then the answer is the same as for the list ['x','y','z'].
Returns
state: returns a string, which contains the number '1' to '10' representing the state, the magnet is in.

For further information on the meaning of the numbers see translated_get_status()

◆ byte_to_utf8()

def magnet.Magnet.byte_to_utf8 (   self,
  mybytes 
)

Convenience function for code refactoring.

Parameters
bytesmybytes the byte message to be decoded
Returns
the decoded string in uni code

◆ calibrate()

def magnet.Magnet.calibrate (   self,
  param_list = None 
)

Calibrates the stage.

In the case of the super conducting magnet this just means moving all or a user specified coil to zero magnetic field.

Parameters
dictparam_list: param_list: optional, if a specific calibration of an axis is desired, then the labels of the needed axis should be passed in the param_list. If nothing is passed, then all connected axis will be calibrated.
Returns
int: error code (0:OK, -1:error)

After calibration the stage moves to home position which will be the zero point for the passed axis. The calibration procedure will be different for each stage.

◆ cool_all_switches()

def magnet.Magnet.cool_all_switches (   self)

Just a convenience function to cool all switches at once This will take 600s.

◆ cool_switch()

def magnet.Magnet.cool_switch (   self,
  axis 
)

Turns off the heating of the PJSwitch, axis depending on user input.

Parameters
stringaxis: desired axis (x, y, z)

◆ get_constraints()

def magnet.Magnet.get_constraints (   self)

Retrieve the hardware constraints from the magnet driving device.

Returns
dict: dict with constraints for the magnet hardware. These constraints will be passed via the logic to the GUI so that proper display elements with boundary conditions could be made.

Provides all the constraints for each axis of a motorized stage (like total travel distance, velocity, ...) Each axis has its own dictionary, where the label is used as the identifier throughout the whole module. The dictionaries for each axis are again grouped together in a constraints dictionary in the form

{'<label_axis0>': axis0 }

where axis0 is again a dict with the possible values defined below. The possible keys in the constraint are defined in the interface file. If the hardware does not support the values for the constraints, then insert just None. If you are not sure about the meaning, look in other hardware files to get an impression.

◆ get_current_field()

def magnet.Magnet.get_current_field (   self)

Function that asks the magnet for the current field strength in each direction.

Parameters

◆ get_magnet_idle_state()

def magnet.Magnet.get_magnet_idle_state (   self)

Retrieve the current state of the magnet, whether it is idle or not.

Returns
bool: the actual state which was set in the magnet hardware. True = idle, decoupled from control False = Not Idle, coupled to control

◆ get_pos()

def magnet.Magnet.get_pos (   self,
  param_list = None 
)

Gets current position of the stage.

Parameters
listparam_list: optional, if a specific position of an axis is desired, then the labels of the needed axis should be passed in the param_list. If nothing is passed, then from each axis the position is asked.
Returns
dict mypos: with keys being the axis labels and item the current position. Given in spheric coordinates with Units T, rad , rad.

◆ get_status()

def magnet.Magnet.get_status (   self,
  param_list = None 
)

Get the status of the position.

Parameters
listparam_list: optional, if a specific status of an axis is desired, then the labels of the needed axis should be passed in the param_list. If nothing is passed, then from each axis the status is asked.
Returns
dict: with the axis label as key and the status number as item. Possible states are { -1 : Error, 1: SCM doing something, 0: SCM doing nothing }

◆ get_velocity()

def magnet.Magnet.get_velocity (   self,
  param_list = None 
)

Gets the current velocity for all connected axes.

Parameters
dictparam_list: optional, if a specific velocity of an axis is desired, then the labels of the needed axis should be passed as the param_list. If nothing is passed, then from each axis the velocity is asked.
Returns
dict: with the axis label as key and the velocity as item.

◆ heat_switch()

def magnet.Magnet.heat_switch (   self,
  axis 
)

This function enables heating of the PJSwitch, which is a necessary step to conduct current to the coils.

Parameters
stringaxis: desired axis (x, y, z)

◆ idle_magnet()

def magnet.Magnet.idle_magnet (   self)

Cool all coils of the superconducting magnet to achieve maximum accuracy after aligning.

Returns
int: (0: Ok, -1:error)

◆ move_abs()

def magnet.Magnet.move_abs (   self,
  param_dict 
)

Moves stage to absolute position (absolute movement)

Parameters
dictparam_dict: dictionary, which passes all the relevant parameters, that should be changed. Usage: {'axis_label': <the-abs-pos-value>}. 'axis_label' must correspond to a label given to one of the axis. In this case the axes are labeled 'rho', 'theta' and 'phi'.
Returns
int: error code (0:OK, -1:error)

◆ move_rel()

def magnet.Magnet.move_rel (   self,
  param_dict 
)

Moves stage in given direction (in spheric coordinates with theta and phi in radian)

Parameters
dictparam_dict: dictionary, which passes all the relevant parameters, which should be changed. Usage: {'axis_label': <the-abs-pos-value>}. 'axis_label' must correspond to a label given to one of the axis.
Returns
int: error code (0:OK, -1:error)

◆ ramp()

def magnet.Magnet.ramp (   self,
  param_list = None 
)

function to ramp the magnetic field in the direction(s) to the target field values

Parameters
listparam_list: This param is optional. If supplied it has to contain the labels for the axes, which should be ramped (only cartesian makes sense here), else all axes will be ramped.
Returns
int: error code (0:OK, -1:error)

◆ ramp_to_zero()

def magnet.Magnet.ramp_to_zero (   self,
  axis 
)

Function to ramp down a specific coil to zero current.

Parameters
axisstring axis: (allowed inputs 'x', 'y' and 'z')

◆ set_magnet_idle_state()

def magnet.Magnet.set_magnet_idle_state (   self,
  magnet_idle = True 
)

Set the magnet to couple/decouple to/from the control.

Parameters
boolmagnet_idle: if True then magnet will be set to idle and each movement command will be ignored from the hardware file. If False the magnet will react on movement changes of any kind.
Returns
bool: the actual state which was set in the magnet hardware. True = idle, decoupled from control False = Not Idle, coupled to control

◆ set_velocity()

def magnet.Magnet.set_velocity (   self,
  param_dict 
)

Function to change the ramp rate in T/s (ampere per second)

Parameters
dictcontains as keys the different cartesian axes ('x', 'y', 'z') and the dict contains list of parameters, that have to be supplied. In this case this is segment, ramp_rate and maxval. How does this work? The maxval for the current marks the endpoint and in between you have several segments with differen ramp_rates.
Returns
int: error code (0:OK, -1:error)

◆ stop_hard()

def magnet.Magnet.stop_hard (   self,
  param_list = None 
)

function that pauses the heating of a specific coil depending on the elements in param_list.

Parameters
listparam_list: Can contain elements 'x', 'y' or 'z'. In the case no list is supplied the heating of all coils is stopped
Returns
integer: 0 everything is ok and -1 an error occured.

◆ target_field_setpoint()

def magnet.Magnet.target_field_setpoint (   self,
  param_dict 
)

Function to set the target field (in T), which will be reached through the function ramp(self, param_list).

Parameters
dictparam_dict: Contains as keys the axes to be set e.g. 'x' or 'y' and the items are the float values for the new field generated by the coil of that axis.
Returns
int: error code (0:OK, -1:error)

◆ tell()

def magnet.Magnet.tell (   self,
  param_dict 
)

Send a command string to the magnet.

Parameters
dictparam_dict: has to have one of the following keys: 'x', 'y' or 'z' with an appropriate command for the magnet

◆ transform_coordinates()

def magnet.Magnet.transform_coordinates (   self,
  param_dict 
)

Function for generic coordinate transformation.

This is a refactoring to the old functions (4) to be replaced by just one function

Parameters
dictparam_dict: contains a param_dict, which contains a list of values to be transformed. The transformation depends on the keys of the first and the second dictionary. Possible keys are: "deg", "rad", "cart" for example if the first key is deg and the second is cartesian then the values in the list will be transformed from deg to cartesian.

Ordering of the values should be [x,y,z] (cartesian) or [rho, theta, phi] for deg or rad

Returns
list containing the transformed values

◆ translated_get_status()

def magnet.Magnet.translated_get_status (   self,
  param_list = None 
)

Just a translation of the numbers according to the manual supplied by American Magnets, Inc.

Parameters
listparam_list: string (elements allowed 'x', 'y' and 'z') for which the translated status should be returned. Can be None, then the answer is the same as for the list ['x','y','z']
Returns
dictionary status_dict: keys are the elements of param_list and the items contain the message for the user.

◆ utf8_to_byte()

def magnet.Magnet.utf8_to_byte (   self,
  myutf8 
)

Convenience function for code refactoring.

Parameters
stringmyutf8 the message to be encoded
Returns
the encoded message in bytes

◆ wake_up_magnet()

def magnet.Magnet.wake_up_magnet (   self)

Heat all coils of the superconducting magnet to get back to the working state.

Returns
int: (0: Ok, -1:error)

The documentation for this class was generated from the following file: