How to make the remapping code realize the jog movement?
13 Dec 2021 07:34 #228998
by chen1234
How to make the remapping code realize the jog movement? was created 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:
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:
#!/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 or Create an account to join the conversation.
13 Dec 2021 21:08 #229027
by cmorley
Replied by cmorley on topic How to make the remapping code realize the jog movement?
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.
Use self.execute()
Yield command should be usef only after a command that you must wait for it to finish before the next command.
The following user(s) said Thank You: chen1234
Please Log in or Create an account to join the conversation.
14 Dec 2021 00:46 #229033
by chen1234
Replied by chen1234 on topic How to make the remapping code realize the jog movement?
Thank you for your answer, but how should I use it: self.execute(), where can I see this function?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 or Create an account to join the conversation.
14 Dec 2021 01:39 #229034
by cmorley
Replied by cmorley on topic How to make the remapping code realize the jog movement?
instead of
use:
c.mdi("G0 Z%d"%a)
use:
self.execute("G0 Z %d"%a)
The following user(s) said Thank You: chen1234
Please Log in or Create an account to join the conversation.
Time to create page: 0.075 seconds