issues with iocontol and M6 remap in python
- bevins
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 1937
- Thank you received: 335
14 Mar 2019 14:59 - 14 Mar 2019 16:38 #128587
by bevins
issues with iocontol and M6 remap in python was created by bevins
In a pure python remap in master, when the command emccannon.TOOL_CHANGE gets sent in the epilog to task, task is suppose to send and EMC_TOOL_LOAD message to iocontrol and wait for iocontrol to assert tool-change pin. iocontrol never asserts the tool-change pin.
Since the tool-change pin and tool-changed pin never gets asserted, I can never apply the offsets because the tool number never gets set. the tool change happens, and I send G43 but it does not get set on the selected tool.
I am having a hard time trying to track down why iocontrol is not asserting the change-tool pin.
Any ideas?
relevant hal lines:
epilog snippet
Since the tool-change pin and tool-changed pin never gets asserted, I can never apply the offsets because the tool number never gets set. the tool change happens, and I send G43 but it does not get set on the selected tool.
I am having a hard time trying to track down why iocontrol is not asserting the change-tool pin.
Any ideas?
relevant hal lines:
Warning: Spoiler!
net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed
epilog snippet
Warning: Spoiler!
print("Change epilog executing....")
if self.return_value > 0.0:
print("pass return value")
self.selected_pocket = int(self.params["selected_pocket"])
print("before emccannon CHANGE TOOL")
emccanon.CHANGE_TOOL(self.selected_pocket)
print("emccannon CHANGE TOOL sent")
self.current_pocket = self.selected_pocket
self.selected_pocket = -1
self.selected_tool = -1
# cause a sync()
print("Lets Sync this Bitch, NOW")
self.set_tool_parameters()
self.toolchange_flag = True
return INTERP_EXECUTE_FINISH
else:
self.set_errormsg("M6 aborted (return code %.1f)" % (self.return_value))
return INTERP_ERROR
except Exception, e:
self.set_errormsg("M6/change_epilog: %s" % (e))
return INTERP_ERROR
Last edit: 14 Mar 2019 16:38 by bevins. Reason: Adding the code snippets.
Please Log in or Create an account to join the conversation.
- bevins
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 1937
- Thank you received: 335
14 Mar 2019 15:09 #128588
by bevins
Replied by bevins on topic issues with iocontol and M6 remap in python
I never get the print message after the CHANGE_TOOL command gets sent.
Please Log in or Create an account to join the conversation.
- bevins
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 1937
- Thank you received: 335
15 Mar 2019 04:13 - 15 Mar 2019 04:43 #128637
by bevins
Replied by bevins on topic issues with iocontol and M6 remap in python
Anyone having issues with this?
Remap pure python is broken again. The interpreter is ignoring emccannon commands.
I have nothing in the remap, no Q-busters nothing, and it wont run the epilog.
ini entry:
M6 Remap:
This is showing that meets the if criteria for epilog
Remap pure python is broken again. The interpreter is ignoring emccannon commands.
I have nothing in the remap, no Q-busters nothing, and it wont run the epilog.
ini entry:
Warning: Spoiler!
REMAP=M6 modalgroup=6 python=M6_Remap_BiesseRover346
M6 Remap:
Warning: Spoiler!
#!/usr/bin/env python
# Mar 2017 Code by Michel Trahan, Bob Bevins and Sylvain Deschene
# Remap of M6 in Pure Python, remap.py includes change_epilog
# Machine is Biesse 346 1995, with 3 position rack toolchanger
#-----------------------------------------------------------------------------------
import linuxcnc
from interpreter import *
from emccanon import MESSAGE, SET_MOTION_OUTPUT_BIT, CLEAR_MOTION_OUTPUT_BIT,SET_AUX_OUTPUT_BIT,CLEAR_AUX_OUTPUT_BIT
from util import lineno
#-----------------------------------------------------------------------------------
throw_exceptions = 1 # raises InterpreterException if execute() or read() fail
#-----------------------------------------------------------------------------------
#from stdglue import change_prolog, change_epilog
import xmlBiesse
import sys
#def queuebuster(self, **words):
# print 'GhostBusters'
# yield INTERP_EXECUTE_FINISH
def M6_Remap_BiesseRover346(self, **words):
#--------------------------------------------------
# if in preview mode exit without doing anything and all ok
#----------------------------------------------------------
if self.task==0:
return INTERP_OK
try:
change_prolog1(self, **words)
print("prolog finished executing")
#-----------------------------------------
# We have errors ! catch and return error
#-----------------------------------------
except InterpreterException,e:
msg = "BOB look at this error : %d: '%s' - %s" % (e.line_number,e.line_text, e.error_message)
self.set_errormsg(msg) # replace builtin error message
print("%s" % msg)
return ReturnERROR()
except IOError as e:
print "I/O error({0}): {1}".format(e.errno, e.strerror)
return ReturnERROR()
except ValueError:
print "Could not convert data to an integer."
return ReturnERROR()
except ZeroDivisionError as detail:
print 'Handling run-time error:', detail
return ReturnERROR()
except:
print "Unexpected error:", sys.exc_info()[0]
raise
finally:
print 'Finally, have a nice GD Bobish day!'
print("Current pocket = %s" % self.current_pocket)
print("Selected pocket = %s" % self.selected_pocket)
print("Param.Selected pocket = %s" % int(self.params["selected_pocket"]))
print("Current tool in spindle = %s" % self.current_tool)
print("Selected tool = %s" % self.selected_tool)
print("Self return value = %s" % self.return_value)
#-----------------------
# all fine, return ok !
#-----------------------
print 'Final!'
self.return_value = self.selected_tool
print("Self return value = %s" % self.return_value)
change_epilog(self, **words)
print 'returned from epilog journey'
return INTERP_OK
#----------------------------------------------------------
#----------------------------------------------------------
def change_prolog1(self, **words):
try:
if self.selected_pocket < 0:
return "M6: no tool prepared"
if self.cutter_comp_side:
return "Cannot change tools with cutter radius compensation on"
self.params["tool_in_spindle"] = self.current_tool
self.params["selected_tool"] = self.selected_tool
self.params["current_pocket"] = self.current_pocket
self.params["selected_pocket"] = self.selected_pocket
return INTERP_OK
except Exception, e:
return "M6/change_prolog: %s" % (e)
def change_epilog(self, **words):
try:
print 'Change epilog executing....'
if self.return_value > 0.0:
# commit change
self.selected_pocket = int(self.params["selected_pocket"])
emccanon.CHANGE_TOOL(self.selected_pocket)
self.current_pocket = self.selected_pocket
self.selected_pocket = -1
self.selected_tool = -1
# cause a sync()
self.set_tool_parameters()
self.toolchange_flag = True
yield INTERP_EXECUTE_FINISH
else:
self.set_errormsg("M6 aborted (return code %.1f)" % (self.return_value))
yield INTERP_ERROR
except Exception, e:
self.set_errormsg("M6/change_epilog: %s" % (e))
yield INTERP_ERROR
This is showing that meets the if criteria for epilog
Last edit: 15 Mar 2019 04:43 by bevins.
Please Log in or Create an account to join the conversation.
- bevins
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 1937
- Thank you received: 335
15 Mar 2019 12:33 - 15 Mar 2019 12:37 #128650
by bevins
Replied by bevins on topic issues with iocontol and M6 remap in python
I think I may try ngc. oword remap.
remap Mcodes for existing python functions, subs and see if this doesnt work better.
remap Mcodes for existing python functions, subs and see if this doesnt work better.
Last edit: 15 Mar 2019 12:37 by bevins.
Please Log in or Create an account to join the conversation.
- pl7i92
- Offline
- Platinum Member
Less
More
- Posts: 1875
- Thank you received: 355
15 Mar 2019 13:31 #128653
by pl7i92
Replied by pl7i92 on topic issues with iocontol and M6 remap in python
Yoiu better send the Full comands as you are interfearing
so G43 Hx
as yoiu know the toolnumber x = toolnumber to be set
so G43 Hx
as yoiu know the toolnumber x = toolnumber to be set
Please Log in or Create an account to join the conversation.
- bevins
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 1937
- Thank you received: 335
15 Mar 2019 16:26 - 15 Mar 2019 16:26 #128667
by bevins
it needs the toolnumber to be able to set G43. Its not getting the tool number out of the remap. iocontrol is not getting the nml message to set to change.
Replied by bevins on topic issues with iocontol and M6 remap in python
Yoiu better send the Full comands as you are interfearing
so G43 Hx
as yoiu know the toolnumber x = toolnumber to be set
it needs the toolnumber to be able to set G43. Its not getting the tool number out of the remap. iocontrol is not getting the nml message to set to change.
Last edit: 15 Mar 2019 16:26 by bevins.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23178
- Thank you received: 4864
16 Mar 2019 11:55 #128725
by andypugh
Replied by andypugh on topic issues with iocontol and M6 remap in python
Have you tried iocontrolV2?
Documentation seems sparse-to-missing
linuxcnc.org/docs/2.7/html/config/ini-co....html#_emcio_section
But here is a sample INI file with some comments:
github.com/LinuxCNC/linuxcnc/blob/0f91c5...ntrolv2-demo.ini#L65
Documentation seems sparse-to-missing
linuxcnc.org/docs/2.7/html/config/ini-co....html#_emcio_section
But here is a sample INI file with some comments:
github.com/LinuxCNC/linuxcnc/blob/0f91c5...ntrolv2-demo.ini#L65
Please Log in or Create an account to join the conversation.
- bevins
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 1937
- Thank you received: 335
16 Mar 2019 12:53 #128729
by bevins
I looked at it and thought about it but I dont understand the way it works. The docs didnt help much in the way the internals work so I didnt try it.
I am pretty sure it is the interpreter ignoring commands issue. I am trying to get in touch with Michael H at machinekit but no luck yet.
My code is at github.com/bobbevins/Linuxcnc_python_remap_M6 . There is alot of work went into the implementation of this machine. Its getting frustrating, lol, I had thoughts of trying it in oword, but I'm not brave enough yet......
Replied by bevins on topic issues with iocontol and M6 remap in python
Have you tried iocontrolV2?
Documentation seems sparse-to-missing
linuxcnc.org/docs/2.7/html/config/ini-co....html#_emcio_section
But here is a sample INI file with some comments:
github.com/LinuxCNC/linuxcnc/blob/0f91c5...ntrolv2-demo.ini#L65
I looked at it and thought about it but I dont understand the way it works. The docs didnt help much in the way the internals work so I didnt try it.
I am pretty sure it is the interpreter ignoring commands issue. I am trying to get in touch with Michael H at machinekit but no luck yet.
My code is at github.com/bobbevins/Linuxcnc_python_remap_M6 . There is alot of work went into the implementation of this machine. Its getting frustrating, lol, I had thoughts of trying it in oword, but I'm not brave enough yet......
Please Log in or Create an account to join the conversation.
- bevins
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 1937
- Thank you received: 335
16 Mar 2019 13:06 - 16 Mar 2019 13:41 #128730
by bevins
Replied by bevins on topic issues with iocontol and M6 remap in python
I also tried a bare bones remap with no queuebuster and it still doesn't send the emccanon.CHANGE_TOOL nor the
self.set_tool_parameters() or self.toolchange_flag = True.
EDIT: I am basing the fact that the interpreter is ignoring the command because when I send emccannon.CHANGE_TOOL, task is suppose to send an NML message to iocontrol and iocontrol.o.tool.change get set to true. thats not happening also when I send tool-change_flag = true, that should tell iocontrol and iocontrol.0.tool.changed happens, which is suppose to send message back and then the offsets get set depending on the selected pocket. emccannon.CHANGE_TOOL gets sent with "selected_pocket" parameter.
None of this is happening, I dont know wether I should loop the iocontrol or not in this case. /EDIT
So I think something is broken.
If I yield throughout the toolchange, then the interpreter starts ignoring commands and things get haywire.
So I am deadlocked.
self.set_tool_parameters() or self.toolchange_flag = True.
EDIT: I am basing the fact that the interpreter is ignoring the command because when I send emccannon.CHANGE_TOOL, task is suppose to send an NML message to iocontrol and iocontrol.o.tool.change get set to true. thats not happening also when I send tool-change_flag = true, that should tell iocontrol and iocontrol.0.tool.changed happens, which is suppose to send message back and then the offsets get set depending on the selected pocket. emccannon.CHANGE_TOOL gets sent with "selected_pocket" parameter.
None of this is happening, I dont know wether I should loop the iocontrol or not in this case. /EDIT
So I think something is broken.
If I yield throughout the toolchange, then the interpreter starts ignoring commands and things get haywire.
So I am deadlocked.
Last edit: 16 Mar 2019 13:41 by bevins.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23178
- Thank you received: 4864
16 Mar 2019 13:59 #128737
by andypugh
Replied by andypugh on topic issues with iocontol and M6 remap in python
You need to trigger this code here:
github.com/LinuxCNC/linuxcnc/blob/master...sk/ioControl.cc#L825
And it looks like CHANGE_TOOL should do that:
github.com/LinuxCNC/linuxcnc/blob/master...sk/emccanon.cc#L1984
As it does create a EMC_TOOL_LOAD_TYPE
There is a rtapi_print_msg(RTAPI_MSG_DBG in the iocontrol code, it would be useful to know if the code is being called. Unforunately the messageing level here is _not_ set from the INI file. You might even need a HAL component to call linuxcnc.org/docs/2.7/html/man/man3/rtap...sg_level.3rtapi.html
(It used to be possible to set a value in /proc/ but I don't think that works any more.)
However, looking at your code I see
Maybe change that toso that you have access to all the canonical commands.
github.com/LinuxCNC/linuxcnc/blob/master...sk/ioControl.cc#L825
And it looks like CHANGE_TOOL should do that:
github.com/LinuxCNC/linuxcnc/blob/master...sk/emccanon.cc#L1984
As it does create a EMC_TOOL_LOAD_TYPE
There is a rtapi_print_msg(RTAPI_MSG_DBG in the iocontrol code, it would be useful to know if the code is being called. Unforunately the messageing level here is _not_ set from the INI file. You might even need a HAL component to call linuxcnc.org/docs/2.7/html/man/man3/rtap...sg_level.3rtapi.html
(It used to be possible to set a value in /proc/ but I don't think that works any more.)
However, looking at your code I see
from emccanon import MESSAGE, SET_MOTION_OUTPUT_BIT, CLEAR_MOTION_OUTPUT_BIT,SET_AUX_OUTPUT_BIT,CLEAR_AUX_OUTPUT_BIT
Maybe change that to
import emccanon
The following user(s) said Thank You: bevins
Please Log in or Create an account to join the conversation.
Time to create page: 0.153 seconds