Tool offset patch

More
27 Aug 2013 13:09 #38133 by cmorley
Replied by cmorley on topic Re:Tool offset patch
Thank you for your report.
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 or Create an account to join the conversation.

More
27 Aug 2013 13:20 #38134 by cmorley
Replied by cmorley on topic Re:Tool offset patch
I did find an oddity in the tool file you posted in the Gscreen thread.
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 or Create an account to join the conversation.

More
10 Apr 2015 18:22 #57655 by LAIR82
Replied by LAIR82 on topic Re:Tool offset patch
I should have made this final post last september when we finally, after 2 long years of work, got everything ironed out, and working as it should. This is how most all "commercial CNC" turning centers handle a tool change, using fixed and assignable offset values.

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 or Create an account to join the conversation.

More
10 Apr 2015 18:42 - 10 Apr 2015 18:42 #57658 by andypugh
Replied by andypugh on topic Re:Tool offset patch
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:
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.
Last edit: 10 Apr 2015 18:42 by andypugh.

Please Log in or Create an account to join the conversation.

More
10 Apr 2015 19:40 #57660 by LAIR82
Replied by LAIR82 on topic Re:Tool offset patch

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:
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 or Create an account to join the conversation.

More
10 Apr 2015 20:28 #57661 by andypugh
Replied by andypugh on topic Re:Tool offset patch

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
#<wear> = [10000 + FIX[ #<tool>  / 100]]
#<tool> = [#<tool> MOD 100]

to
#<wear> = [#<tool> MOD 100]
#<tool> = [10000 + FIX[ #<tool>  / 100]]

(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 or Create an account to join the conversation.

More
12 Apr 2015 04:33 #57695 by LAIR82
Replied by LAIR82 on topic Re:Tool offset patch
Hey Gary,

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 or Create an account to join the conversation.

More
13 Apr 2015 06:07 #57732 by gmills46
Replied by gmills46 on topic Re:Tool offset patch
Hi Rick
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 or Create an account to join the conversation.

More
13 Apr 2015 20:51 #57750 by andypugh
Replied by andypugh on topic Re:Tool offset patch

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:
[DISPLAY]
...
PROGRAM_PREFIX = ../../nc_files/
...
[RS274NGC]
SUBROUTINE_PATH = ./:../
...
[PYTHON]
# where to find Python code
# code specific for this configuration  
PATH_PREPEND=./
 # generic support code
PATH_APPEND=../../nc_files/remap_lib/python-stdglue/

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 or Create an account to join the conversation.

More
15 Apr 2015 09:34 #57811 by cmorley
Replied by cmorley on topic Re:Tool offset patch
Lairs:

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
Attachments:

Please Log in or Create an account to join the conversation.

Time to create page: 0.405 seconds
Powered by Kunena Forum