- Posts: 6803
- Thank you received: 0
Tool offset patch
The development branch is going to have a big shake up and I am waiting till after that to continue work on this feature.
It was a lot more work then I had thought.
The only way I can think of to debug this is to add a bunch of print statements and see what is different when there is an error.
I am currently too busy to do the work...sorry.
Chris M
Please Log in to join the conversation.
When I paste it into gedit there are line breaks in odd spots.
It seems the comments section is too long.
I wonder if this matters. If you happens again try opening the tool file in gedit and fixxing the comments section.
Chris M
Please Log in to join the conversation.
We have three turning centers running this, and it works perfectly
You need to modify your remap.py adding the following,
def index_fanuc_lathe_tool(self,**words):
try:
# check there is a tool number from the Gcode
cblock = self.blocks[self.remap_level]
if not cblock.t_flag:
self.set_errormsg("T requires a tool number")
return INTERP_ERROR
tool_raw = int(cblock.t_number)
# If it's less then 100 someone forgot to add the wear #, so we added it automatically
# separate out tool number (tool) and wear number (wear), add 10000 to wear number
if tool_raw <100:
tool_raw=tool_raw*100
tool = int(tool_raw/100)
wear = 10000 + tool_raw % 100
# uncomment for debugging
#print'***tool#',cblock.t_number,'toolraw:',tool_raw,'tool split:',tool,'wear split',wear
# check for tool number entry in tool file
(status, pocket) = self.find_tool_pocket(tool)
if status != INTERP_OK:
self.set_errormsg("T%d: tool entry not found" % (tool))
return status
# if there is a wear number, check for it in the tool file
# For wear offset 00, we dont require a tool 10000 entry in the tool file - so we will skip this check
if wear>10000:
(status, pocket) = self.find_tool_pocket(wear)
if status != INTERP_OK:
self.set_errormsg("T%d: wear entry not found" % (wear))
return status
# index tool immediately to tool number
# immediately add tool offset
self.execute("m6 T%d"% tool)
self.execute("g43 h%d"% tool)
# if the wear offset is specified, immediately add it's offset
if wear>10000:
self.execute("g43.2 h%d"% wear)
# all good
return INTERP_OK
except Exception, e:
self.set_errormsg("T%d index_fanuc_lathe_tool: %s" % (int(words), e))
return INTERP_ERROR
Then add this line to your [RS274NGC] section of your INI,
REMAP = T python=index_fanuc_lathe_tool
Then as for the tool table, you need to add tool numbers 10001-10008. This is were the "wear offset" values would be placed, these are the second 2 digits of the tool call.
Thanks
Rick
Please Log in to join the conversation.
If you look at the "lathe-fanucy" sim config you will see a configuration which does what I think you want in non-patched LinuxCNC with tool-change remapped to a G-code subroutine that applies both tool offsets.
git.linuxcnc.org/gitweb?p=linuxcnc.git;a...24cdb4985043e8415368
The G-code routine looks like this:
And performs an M6 and G43 whenever there is a T-command. If you want the offset and base to be the other way round then it is just a case of altering that G-code routine.
I think that this is probably simpler than the patch being discussed in this (old) thread.
Please Log in to join the conversation.
andypugh wrote: Did you notice that in the meantime the G43.2 code was added to LinuxCNC, which makes things rather easier?
If you look at the "lathe-fanucy" sim config you will see a configuration which does what I think you want in non-patched LinuxCNC with tool-change remapped to a G-code subroutine that applies both tool offsets.
git.linuxcnc.org/gitweb?p=linuxcnc.git;a...24cdb4985043e8415368
The G-code routine looks like this:Code:O<toolchange> sub (debug, Tool requested = #<tool>) #<wear> = [10000 + FIX[ #<tool> / 100]] #<tool> = [#<tool> MOD 100] M6 T#<tool> G43 H#<tool> O100 IF [#<wear> GT 10000] G43.2 H#<wear> O100 ENDIF #<pocket> = #<tool> (debug, tool = #<tool> wear = #<wear>) O<toolchange> endsub [0]
And performs an M6 and G43 whenever there is a T-command. If you want the offset and base to be the other way round then it is just a case of altering that G-code routine.
I think that this is probably simpler than the patch being discussed in this (old) thread.
Good Morning Andy,
We no longer run a patch, just a different remap.py flavor than what your lathe-fanucy uses.
I tried running this when you published it, but ran into a few issues, which I couldn't overcome on my own,
We run Gmoccapy, and may be that is why the first issue, but when a toolchange is requested, the g-code subroutine pops up in the current gcode program display, and never goes away.
The other issue was the numbers were backwards from what I could tell, TXXYY should result in the XX number being the "fixed" actual tool position data, and the YY should be the "assignable" wear offset values, when we tried it, it was operating as TYYXX, and I could not figure out how to change it to run as TXXYY.
Thanks
Rick
Please Log in to join the conversation.
LAIR82 wrote: The other issue was the numbers were backwards from what I could tell, TXXYY should result in the XX number being the "fixed" actual tool position data, and the YY should be the "assignable" wear offset values, when we tried it, it was operating as TYYXX, and I could not figure out how to change it to run as TXXYY.
For reference, to switch the numbers just change
to
(if you change the names and not the order, then the #<tool> value doesn't have the same value by the time it tries to calculate #<wear>)
Please Log in to join the conversation.
You need to do the following to your build to be able to remap codes,
linuxcnc.org/docs/html/remap/structure.h...ration_for_remapping
Take a look at it, and see how you come, I will be back in on Monday if you need help.
I don't use the .ngc file setup, I just use the altered remap.py version,
But there's more than one way to skin a cat.
Rick
Please Log in to join the conversation.
I tried a couple of things with no luck.
I think the I need to put the toolchange.ngc file in the proper folder?
If you are interested in helping me with a few things that I need to get working on this machine, I would be happy to pay you or trade parts. My company is in the CNC parts and repair business.
Part of my business is selling CNC parts on an Ebay store. MECNC is the store name. I know CNC machines and controls, but not much about Linuxcnc or coding.
We could Skype or talk on the phone and you could access the machine with Teamviewer?
Thank you
Gary
Please Log in to join the conversation.
gmills46 wrote: I think the I need to put the toolchange.ngc file in the proper folder?
Important bits of the sample config might be...
In the INI file:
This is a bit of a kludge in the sample config, as the files have a slightly odd structure there, so don't blindly copy them. SUBROUTINE_PATH needs to point from the INI file to the .ngc file. I actually like to put remap subs in the actual config directory itself as I consider them to be part of the config. In that case "./" is the correct SUBROUTINE_PATH.
The PATH_PREPEND also points to the config folder in the sample config, and means that the python code is to be found in the same folder as the INI.
I don't think that the PATH_APPEND to python-stdglue is needed in this case, as the config isn't using code from there. But perhaps some experimentation is called for if nothing else works
Please Log in to join the conversation.
I wondered if a modified tool_edit widget would be better for lathes:
The wear number is beside the offset rather then as a separate tool.
interested? It's not quite done yet...
Chris M
Please Log in to join the conversation.
