How to make the remapping code realize the jog movement?

More
4 years 10 months ago #228998 by chen1234
I encountered a problem when controlling the operation of the scan head.
I needed to receive a high level signal, and I had to control the Z axis to move to a position (this position can be set) every time I receive it.
But I can't execute this code in the G code file at present (error: can't do that (EMC_TASK_PLAN_EXECUTE) in auto mode with the interperter reading ...), it tells me that it must be executed in MDI mode,
what should I do To realize the remapping code to control the movement of the Z axis?I use Linuxcnc2.9
Please help me, thanks, here is my code:
Code:
#!/usr/bin/env python3 import struct import sys  import os from interpreter import * import hal import linuxcnc def m203(self,**words):     yield INTERP_EXECUTE_FINISH     if self.task:         list = []         for key in words:             print("word '%s' = %f" % (key, words[key]))             list.append(words[key])                  a = list[0]         print("a=",a)         while 1:             x = hal.get_value('lcec.0.5.RXPDO-5') #io address              print('x_in5 =',x)             if x == 1:                 print("in5 = 1")                 c = linuxcnc.command()                 c.mdi("G0 Z%d"%a)                 break             elif x == 0:                 print("in5 = 0")                 break 

Please Log in to join the conversation.

More
4 years 10 months ago #229027 by cmorley
Dont use c.mdi
Use self.execute()

Yield command should be usef only after a command that you must wait for it to finish before the next command.

Please Log in to join the conversation.

More
4 years 10 months ago #229033 by chen1234

Dont use c.mdi
Use self.execute()

Yield command should be usef only after a command that you must wait for it to finish before the next command.
Thank you for your answer, but how should I use it: self.execute(), where can I see this function?

Please Log in to join the conversation.

More
4 years 10 months ago #229034 by cmorley
instead of
Code:
  c.mdi("G0 Z%d"%a)

use:
Code:
self.execute("G0 Z %d"%a)

Please Log in to join the conversation.

Time to create page: 0.480 seconds
Powered by Kunena Forum