Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1

More
6 years 1 month ago #180446 by neller
Hi, I am trying to create an automatic tool changer and have the same problems. In python, I control valves and check sensors, then run the g-code, then check the sensors again, and run the g-code again, but it doesn't work in that sequence. For some reason, all the g-code command is executed directly at the end. How did you get around this problem? I am attaching my config. This is an urgent need, please help.

Warning: Spoiler!

Please Log in to join the conversation.

More
6 years 1 month ago #180448 by andypugh
Can you put the code in
Code:
code tags
?

The reason I ask is because it is impossible to follow Python code without the indenting, and the spoiler tags seem to have lost that

Please Log in to join the conversation.

More
6 years 1 month ago #180450 by neller
Code:
#!/usr/bin/python from interpreter import INTERP_OK from emccanon import MESSAGE import hal, linuxcnc, emccanon, time linuxcncStat = linuxcnc.stat(); linuxcncCmd = linuxcnc.command() #Global fork_offset_y = 20 tool1_x = 10 tool1_y = 100 tool2_x = 20 tool2_y = 100 tool3_x = 30 tool3_y = 100 tool4_x = 40 tool4_y = 100 tool5_x = 50 tool5_y = 100 fork_z = 0 fork_y = 110 safety_z = 10 def func1(self,current_tool): if current_tool == 1: self.execute("G0 X%f Y%f" % (tool1_x,tool1_y-fork_offset_y)) elif current_tool == 2: self.execute("G0 X%f Y%f" % (tool2_x,tool2_y-fork_offset_y)) elif current_tool == 3: self.execute("G0 X%f Y%f" % (tool3_x,tool3_y-fork_offset_y)) elif current_tool == 4: self.execute("G0 X%f Y%f" % (tool4_x,tool4_y-fork_offset_y)) elif current_tool == 5: self.execute("G0 X%f Y%f" % (tool5_x,tool5_y-fork_offset_y)) def func2(self): self.execute("G0 Z%f" % (fork_z)) def func3(self): self.execute("G0 Y%f" % (fork_y)) def func4(self): self.execute("G0 Z%f" % (safety_z)) def func5(self,new_tool): new_tool_y=0 #Local if new_tool == 1: self.execute("G0 X%f Y%f" % (tool1_x,tool1_y)) new_tool_y=tool1_y elif new_tool == 2: self.execute("G0 X%f Y%f" % (tool1_x,tool2_y)) new_tool_y=tool2_y elif new_tool == 3: self.execute("G0 X%f Y%f" % (tool1_x,tool3_y)) new_tool_y=tool3_y elif new_tool == 4: self.execute("G0 X%f Y%f" % (tool1_x,tool4_y)) new_tool_y=tool4_y elif new_tool == 5: self.execute("G0 X%f Y%f" % (tool1_x,tool5_y)) new_tool_y=tool5_y return new_tool_y def func6(self,new_tool_y): self.execute("G0 Y%f" % (new_tool_y-fork_offset_y)) def change_prolog_m6(self, **words): store="hal_neller_changer.input0" store_sensor="hal_neller_changer.output0" patron="hal_neller_changer.input1" patron_sensor="hal_neller_changer.output1" new_tool=int(hal.get_value("hal_neller_changer.new_tool")) current_tool=int(hal.get_value("hal_neller_changer.current_tool")) print("\n") print("This is m6 prolog") print("\n") #self.execute("G0X100") #self.execute("G0Y100") #self.execute("G0X0") #self.execute("G0Y0") hal.set_p(store,"TRUE") #Open Store time.sleep(2) #Delay if hal.get_value(store_sensor): print("store sensor activated") #Go to current tool store position func1(self,current_tool) #Z to down (fork) func2(self) #Go to fork func3(self) hal.set_p(patron,"TRUE") #Open patron time.sleep(2) #Delay if hal.get_value(patron_sensor): print("patron sensor activated") #Z to up (safety position) func4(self) #Go to new tool new_tool_y = func5(self,new_tool) #Z to down (fork) func2(self) hal.set_p(patron,"FALSE") #Close patron time.sleep(2) #Delay if hal.get_value(patron_sensor)!=True: print("patron sensor activated") func6(self,new_tool_y) #Z to up (safety position) func4(self) else: print("#Error 03: patron sensor not activated") else: print("#Error 02: patron sensor not activated") else: print("#Error 01: store sensor not activated")

Please Log in to join the conversation.

More
6 years 1 month ago #180451 by andypugh
I only see a few sleep commands, and no wait-for-sensor loops.

I don't think that this is likely to be the problem, but it is an area where an improvement is possible.

It's more clunky in some ways, and less so in others, but controlling the sequence via a G-code routine can work well. G-code has built-in wait-on-input functions which include timeout handling.

There is an example of a G-code tool-change here:
github.com/LinuxCNC/linuxcnc/blob/master...hange/toolchange.ngc

One reason this is potentially useful is that the interpreter does not try to queue moves through a wait-on-input G-code.

It looks like your tool change is all in the prolog code. I am wondering if that is the problem. prolog code is intended to run before the main toolchange sequence and typically just sorts out what need to be done.

Carousel postioning is typically done as part of a remapped T command, and then the change itself as the main M6 remap.

Please Log in to join the conversation.

Time to create page: 0.126 seconds
Powered by Kunena Forum