update motion sync

This commit is contained in:
2018-11-12 15:10:19 +01:00
parent 4927a02706
commit 1e676bcd18
4 changed files with 76 additions and 39 deletions

View File

@@ -95,23 +95,24 @@ close
# - waits raising edge of <flag> and the sets DesTimeBase=ServoPeriod
# flag ='PowerBrick[0].GpioData[0].0.1==1'
flag = 'Gate3[1].Chan[0].UserFlag==0'
flag0 = 'Gate3[1].Chan[0].UserFlag==0'
flag1 = 'Gate3[1].Chan[1].UserFlag==0'
prg = '''
//L0=Sys.PhaseCount
//send 1"sync0 %d:%d\\n",Sys.PhaseCount,Sys.PhaseCount-L0
while({flag}){{}}
while({flag0}){{}}
//send 1"sync1 %d:%d\\n",Sys.PhaseCount,Sys.PhaseCount-L0
//L1=Sys.PhaseCount
while(1)
{{
if({flag})
if({flag1})
{{
//PowerBrick[0].GpioData[0].16.8=255
//send 1"sync2 %d:%d\\n",Sys.PhaseCount,Sys.PhaseCount-L1
break
}}
}}
'''.format(plcId=plcId, crdId=crdId, flag=flag)
'''.format(plcId=plcId, crdId=crdId, flag0=flag0, flag1=flag1)
self.sync_prg = prg
self.sync_run = '&{crdId}b{prgId}r'''.format(prgId=prgId, plcId=plcId, crdId=crdId)

View File

@@ -142,7 +142,8 @@ class ShapePath(MotionBase):
comm=self.comm
gt=self.gather
gt.set_phasemode(False)
gt.set_address("Motor[3].ActPos","Motor[2].ActPos","Motor[1].ActPos","Motor[3].DesPos","Motor[2].DesPos","Motor[1].DesPos")
#gt.set_address("Motor[3].ActPos","Motor[2].ActPos","Motor[1].ActPos","Motor[3].DesPos","Motor[2].DesPos","Motor[1].DesPos")
gt.set_address("Motor[3].ActPos","Motor[2].ActPos","Motor[1].ActPos","Motor[3].DesPos","Motor[2].DesPos","Motor[1].DesPos","Gate3[1].Chan[1].UserFlag")
gt.set_property(MaxSamples=1000000, Period=acq_per)
ServoPeriod= .2 #0.2ms #Sys.ServoPeriod is dependent of !common() macro
#ServoPeriod=comm.gpascii.servo_period
@@ -555,7 +556,8 @@ if __name__=='__main__':
sp.setup_gather(acq_per=2)
#setup_sync(self, crdId=1, prgId=2, plcId=2, mode=0, **kwargs):
sp.setup_sync() #no sync at all
#sp.setup_sync(mode=1) #sync with timing system
#sp.setup_sync(mode=1) #sync with timing system (PLC)
sp.setup_sync(mode=2) #sync with timing system (PROG)
#sp.gen_grid_points(w=2,h=2,pitch=50,rnd=.2);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=10,acq_per=1)
sp.gen_swissmx_points(scale=10);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=40,acq_per=1)