How can I make the axis movement immediate in the remapping code?

More
4 years 9 months ago #233144 by chen1234
I did an io signal detection in the remapping code, it can control the Z axis movement after reading a high level signal, I use the (self.execute("G0 Z %d"%b)) function to Control the Z axis, b is my parameter, but I found in the test that self.execute will not be executed in the loop, but will be executed after the loop ends, which cannot achieve my needs. I would like to know how to control the axis to make it execute immediately? Please give me some advice.
Thanks, here is my code:
Code:
def m203(self,**words):     #yield INTERP_EXECUTE_FINISH     if self.task:         a = (words['s'])         b = a         c = 0         while 1:             x = hal.get_value('lcec.0.5.RXPDO-4')               if x == 1:                 y = hal.get_value('lcec.0.5.RXPDO-5')                   if y == 1:                     while 1:                         y = hal.get_value('lcec.0.5.RXPDO-5')                          if y == 0:                             c += 1                             print("c = ", c)                             if b < 44 and b >-44:                                 self.execute("G0 Z %d"%b)                                 b += a                                 break                  elif y == 0:                     time.sleep(0)             elif x == 0 or hal.get_value('lcec.0.5.TXPDO-2') == 1:                 break 

Please Log in to join the conversation.

More
4 years 9 months ago #233151 by cmorley
try:
yield INTERP_EXECUTE_FINISH

after execute statement

Please Log in to join the conversation.

More
4 years 9 months ago #233249 by chen1234
Thanks for your answer,
I solved the problem, I found that (self.execute("G0 Z %d"%b)) can't go to execute the Z axis movement immediately.
I solved the Z axis control delay using ( External Axis Offsets ) and it got my Z axis feeds working. I thought I should share the solution, below is my code and configuration.
remap.py:
Code:
def m203(self,**words):     yield INTERP_EXECUTE_FINISH     if self.task:         a = (words['s'])         b = a         while 1 :             y = hal.get_value('lcec.0.5.RXPDO-4')               if y == 1:                             x = hal.get_value('lcec.0.5.RXPDO-5')                   if x == True:                     while 1:                         x = hal.get_value('lcec.0.5.RXPDO-5')                         if x == False:                             hal.set_p("axis.z.eoffset-counts","%d"%b)                             print("b=",b)                             b += a                             break                   elif x == False:                     time.sleep(0)                elif y == 0 or shal.get_value('lcec.0.5.TXPDO-2') == 1:                 time.sleep(0)                 break          hal.set_p("axis.z.eoffset-counts","0")        
myaxis.ini:
Code:
[AXIS_Z] OFFSET_AV_RATIO  =   0.2
myaxis.hal:
Code:
setp axis.z.eoffset-enable 1 setp axis.z.eoffset-scale 1

 

Please Log in to join the conversation.

Time to create page: 0.446 seconds
Powered by Kunena Forum