This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu Jan 4 20:02:31 2018 | |
@author: linqs-wentao | |
""" | |
class fiberpull: | |
def __init__(self, ctrlraddr, d0_fiber=2, d_fiber=1, t_heat=10): | |
self.ctrlraddr = ctrlraddr | |
self.d0_fiber = d0_fiber | |
self.d_fiber = d_fiber | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\[Alpha] = -1./180*Pi; | |
oldpoints = points; | |
For[ii = 1, ii <= n, | |
c = points[[ii]]; | |
For[jj = ii + 1, jj <= n, | |
rotated = c + RotationMatrix[\[Alpha]].(points[[jj]] - c); | |
points[[jj]] = rotated; | |
jj = jj + 1;] ; | |
ii = ii + 1;] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu Jan 4 16:16:44 2018 | |
@author: linqs-wentao | |
""" | |
#import PyDAQmx as daq | |
#import numpy | |
#import visa | |
#import time | |
#import datetime | |
class npstage: | |
def __init__(self, axis, controller): | |
""" | |
axis: stage axis, numeric | |
controller: GPIB visa connection to the stage controller. e.g.: | |
rm = visa.ResourceManager() | |
stage = rm.open_resource('GPIB0::1::INSTR') | |
""" | |
self.axis = axis | |
self.controller = controller | |
self.v = 0 | |
self.a = 0 | |
self.pos = 0 | |
self.enable() | |
self.setA(1.0) | |
self.setV(1.0) | |
self.write('OR5') # search for home | |
def write_direct(self, cmd): | |
self.controller.write(cmd) | |
def query_direct(self, cmd): | |
val = self.controller.query(cmd) | |
return float(val) | |
def write(self,cmd): | |
""" | |
add axis as a prefix to cmd | |
""" | |
self.write_direct(str(self.axis)+cmd) | |
def query(self, cmd): | |
""" | |
add axis as a prefix to cmd | |
""" | |
val = self.query_direct(str(self.axis)+cmd) | |
return val | |
def enable(self): | |
self.write('MO') | |
def disable(self): | |
self.write('MF') | |
def mov2max(self): | |
# move to positive limit | |
self.write('MT+') | |
print('Moving to max position') | |
def mov2min(self): | |
# move to negative limit | |
self.write('MT-') | |
print('Moving to min position') | |
def setV(self,v): | |
# set velocity | |
self.write('VA%.2f'%(v)) | |
self.v = v | |
print('Set axis %d velocity to %.2fmm/s.'%(self.axis, v)) | |
def getV(self): | |
# get velocity | |
v = self.query('VA?') | |
self.v = v | |
return v | |
def setA(self,a): | |
# set acceleration | |
self.write('AC%.2f'%(a)) | |
self.a = a | |
def movAbs(self,pos): | |
# move to absolute position | |
self.write('PA%.2f'%(pos)) | |
self.pos = pos | |
print('Move axis %d to abs position %.2f.'%(self.axis,pos)) | |
def mov(self,d): | |
# move by distance | |
self.write('PR%.2f'%(d)) | |
pos = self.pos + d | |
self.pos = pos | |
print('Move axis %d by distance %.2f.'%(self.axis,d)) | |
def stop(self): | |
# stop operation | |
self.write('ST') | |
def print(self): | |
s = 'Stage %d: v = %.2fmm/s, a = %.2f, pos = %.2fmm\n'%(self.axis, self.v, | |
self.a, self.pos) | |
print(s) | |
return s | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment