FULLY WORKING incl. sync. but have to fix the display. fy seems wrong
This commit is contained in:
@@ -47,7 +47,7 @@ class MotionBase:
|
||||
gpascii = self.comm.gpascii
|
||||
if mode == 0:
|
||||
try:
|
||||
del self.sync_wait
|
||||
del self.sync_prg
|
||||
except AttributeError:
|
||||
pass
|
||||
self.sync_run = '&{crdId}b{prgId}r'''.format(prgId=prgId, crdId=crdId)
|
||||
@@ -61,25 +61,57 @@ class MotionBase:
|
||||
# - waits raising edge of <flag> and the sets DesTimeBase=ServoPeriod
|
||||
|
||||
# flag ='PowerBrick[0].GpioData[0].0.1==1'
|
||||
flag = 'Gate3[1].Chan[0].UserFlag==1'
|
||||
flag = 'Gate3[1].Chan[0].UserFlag==0'
|
||||
prg = '''close all buffers
|
||||
disable plc {plcId}
|
||||
open plc {plcId}
|
||||
Coord[{crdId}].DesTimeBase=0 // freezes timebase at boot
|
||||
while(flag){{}}
|
||||
L0=Sys.PhaseCount
|
||||
send 1"sync0 %d:%d\\n",Sys.PhaseCount,Sys.PhaseCount-L0
|
||||
while({flag}){{}}
|
||||
send 1"sync1 %d:%d\\n",Sys.PhaseCount,Sys.PhaseCount-L0
|
||||
L1=Sys.PhaseCount
|
||||
while(1)
|
||||
{{
|
||||
if({flag})
|
||||
{{
|
||||
PowerBrick[0].GpioData[0].16.8=255
|
||||
PowerBrick[0].GpioData[0].16.1=1
|
||||
Coord[{crdId}].DesTimeBase=Sys.ServoPeriod
|
||||
send 1"sync2 %d:%d\\n",Sys.PhaseCount,Sys.PhaseCount-L1
|
||||
break
|
||||
}}
|
||||
}}
|
||||
disable plc {plcId}
|
||||
close
|
||||
'''.format(plcId=plcId, crdId=crdId, flag=flag)
|
||||
gpascii.send_block(prg)
|
||||
self.sync_wait = 'Coord[{crdId}].DesTimeBase=0;enable plc {plcId}'.format(plcId=plcId, crdId=crdId)
|
||||
self.sync_run = 'Coord[{crdId}].DesTimeBase=0;&{crdId}b{prgId}r'''.format(prgId=prgId, plcId=plcId, crdId=crdId)
|
||||
self.sync_prg = 'Coord[{crdId}].DesTimeBase=0'.format(prgId=prgId, plcId=plcId, crdId=crdId)
|
||||
self.sync_run = 'enable plc {plcId};&{crdId}b{prgId}r'''.format(prgId=prgId, plcId=plcId, crdId=crdId)
|
||||
|
||||
elif mode == 2:
|
||||
# code block to insert in the program
|
||||
# - waits untis <flag> is false
|
||||
# - 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'
|
||||
prg = '''
|
||||
//L0=Sys.PhaseCount
|
||||
//send 1"sync0 %d:%d\\n",Sys.PhaseCount,Sys.PhaseCount-L0
|
||||
while({flag}){{}}
|
||||
//send 1"sync1 %d:%d\\n",Sys.PhaseCount,Sys.PhaseCount-L0
|
||||
//L1=Sys.PhaseCount
|
||||
while(1)
|
||||
{{
|
||||
if({flag})
|
||||
{{
|
||||
//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)
|
||||
self.sync_prg = prg
|
||||
self.sync_run = '&{crdId}b{prgId}r'''.format(prgId=prgId, plcId=plcId, crdId=crdId)
|
||||
|
||||
def run(self):
|
||||
'runs the code sync_run which has been generated with setup_sync()'
|
||||
|
||||
Reference in New Issue
Block a user