Source code for instruments.Rotator_CR1_Z7
# the rotating stage class
# - wraps around Motor
from Motor_KST_ZST import Motor_KST_ZST as Motor
DEG_PER_CNT = 0.00061035
[docs]class Rotator_CR1_Z7(Motor):
def __init__(self, ser):
'''
Constructor
ser (Serial): the Serial object that corresponds to the port
the motor is connected to
'''
Motor.__init__(self, ser)
self.moving = False #set to false
self.deg_pos = 0 # position of motor, in degrees
self.deg_zeros = 0 # the origin, in degrees
[docs] def delta_angle(self, deg): #, m_callback = None, params = ()):
'''
Relative rotation on the motor
deg (float): the degrees of rotation (negative -> counter-clockwise)
'''
self.moving = True
self.deg_pos += deg
# convert degrees to steps
steps = int(round(deg / DEG_PER_CNT))
Motor.delta_move(self, steps)
self.moving = False
[docs] def abs_angle(self, deg):
'''
Relative rotation on the motor
deg (float): the degrees of rotation (negative -> counter-clockwise)
'''
self.moving = True
# convert degrees to steps
steps = int(round(deg / DEG_PER_CNT))
Motor.abs_move(self, steps)
self.deg_pos = deg
self.moving = False
[docs] def get_angle(self):
'''
return the motors current position, in degrees
'''
return self.deg_pos
[docs] def set_as_zero(self, zer_deg):
'''
change the origin (zero)
'''
n_zero = int(round(zer_deg / DEG_PER_CNT))
Motor.set_as_zero(self, n_zero)
self.deg_zeros = zer_deg
self.deg_pos -= zer_deg
def __str__(self):
'''
<For Debugging Purposes>
gives information relevant to the motor state
'''
return 'position(degrees): ' + str(self.deg_pos) + '\nzeros-position(degrees): ' + str(self.deg_zeros)
'''
Copyright (C) 2017 Robert Polster
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''