Skip to content

Instantly share code, notes, and snippets.

@jwt625
Last active January 6, 2018 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwt625/3b27287bdfc737660f8c36b9450a0f07 to your computer and use it in GitHub Desktop.
Save jwt625/3b27287bdfc737660f8c36b9450a0f07 to your computer and use it in GitHub Desktop.
#!/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
\[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;]
#!/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