adding Q1 for triggering status
This commit is contained in:
@@ -289,6 +289,75 @@ class MXTuning(Tuning):
|
||||
EXPORT_SYMBOL(obsvr_servo_ctrl_{motid});'''.format(motid=motid)
|
||||
return (hdr,prog)
|
||||
|
||||
def check_fast_stage(self,file='/tmp/gather.npz'):
|
||||
if os.path.isfile(file):
|
||||
f=np.load(file)
|
||||
data=f['data']
|
||||
meta=f['meta'].item()
|
||||
meta['file']=file
|
||||
else:
|
||||
#self.init_stage();time sleep
|
||||
phase=False
|
||||
motor=2
|
||||
gpascii = self.comm.gpascii
|
||||
gt = self.gather
|
||||
gt.set_phasemode(phase)
|
||||
address=('Motor[2].ActPos','Motor[8].ActPos')
|
||||
gt.set_address(*address)
|
||||
gt.set_property(Period=1)
|
||||
|
||||
tSrv=gpascii.servo_period
|
||||
tSrv=2E-4 # seconds
|
||||
phOsv = gpascii.get_variable('sys.PhaseOverServoPeriod', float)
|
||||
|
||||
subs={'prgId':999,'mot':motor,'num':100,'phase':'Phase' if phase else ''}
|
||||
|
||||
#the servoloop is called 2 times per servo cycle ?!?
|
||||
#don't know why, but this is the reason why the value L10 is incremented by 0.5
|
||||
prog = '''
|
||||
&1
|
||||
open prog {prgId}
|
||||
P1=Motor[{mot}].DesPos-Motor[{mot}].HomePos
|
||||
Q2=10
|
||||
Gather.{phase}Enable=2
|
||||
Q1={num}
|
||||
while (Q1>0)
|
||||
{{
|
||||
jog{mot}=(P1-1000)
|
||||
dwell 10
|
||||
jog{mot}=(P1)
|
||||
dwell 10
|
||||
Q1=Q1-1
|
||||
}}
|
||||
dwell 10
|
||||
Gather.{phase}Enable=0
|
||||
close
|
||||
&1
|
||||
b{prgId}r
|
||||
'''.format(**subs)
|
||||
|
||||
gpascii.send_line(prog)
|
||||
res=gpascii.sync()
|
||||
res=res.replace(GpasciiChannel.ACK+'\r\n','')
|
||||
print(res)
|
||||
t=time.time()
|
||||
gt.wait_stopped()
|
||||
print('time %f'%(time.time()-t))
|
||||
self.data=data=gt.upload()
|
||||
meta={'motor':motor,'date':time.asctime(),'ts':tSrv if not phase else tSrv*phOsv,'address':address}
|
||||
np.savez_compressed(file, data=data, meta=meta)
|
||||
meta['file'] = file
|
||||
tSrv=meta['ts']
|
||||
t=tSrv*np.arange(data.shape[0])
|
||||
data=data-data[0,:]
|
||||
plt.plot(t,data[:,0],t,data[:,1])
|
||||
plt.figure()
|
||||
plt.plot(t,data[:,0]-data[:,1])
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
|
||||
def bode(mdl):
|
||||
w,mag,phase = signal.bode(mdl,1000)
|
||||
f=w/(2*np.pi)
|
||||
@@ -337,7 +406,7 @@ Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n '
|
||||
|
||||
#plt.ion()
|
||||
#args.host='MOTTEST-CPPM-CRM0573'
|
||||
args.host=None
|
||||
#args.host=None
|
||||
if args.host is None:
|
||||
comm=gt=None
|
||||
else:
|
||||
@@ -490,7 +559,8 @@ Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n '
|
||||
fn=os.path.join(base, 'scratch_%d.npz' % mot)
|
||||
if not init_stage and not os.path.isfile(fn):tune.init_stage();init_stage=True
|
||||
tune.custom_chirp(motor=mot,minFrq=1,maxFrq=20,amp=200,tSec=15,mode=2,file=fn)
|
||||
|
||||
elif mode==10: # record stage x and probe encoder
|
||||
tune.check_fast_stage()
|
||||
print('done')
|
||||
plt.show()
|
||||
#------------------ Main Code ----------------------------------
|
||||
|
||||
Reference in New Issue
Block a user