nav111 / heekscnc

Automatically exported from code.google.com/p/heekscnc
Other
0 stars 0 forks source link

G43 command needed for tool changes using Mach3 (Fanuc) #238

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Here is an enhancement I made to the code to get tool changes to work right 
with my setup of Mach 3.  I noticed that the g-code using standard ISO output 
of HeeksCNC did not include a G43 (tool length offset (plus)).  I use Mach3 to 
control my mill machine and Mach3 needs a G43 command to take into account tool 
offsets before tool changes. Without it, this can cause tool crashes, since the 
new tool offset is not taken into account with a tool change.  Mach 3 uses the 
'fanuc' flavor of G-codes, and not standard ISO, as far as I can tell.  Other 
than this change, I have not run across anything else in the HeeksCNC g-code 
that was a problem for Mach3.   

Here is the g-code produced by the 'Standard ISO' setting for a tool change:

(tool change to 1/4 inch HSS Roughing Mill)
N70T2M06

Mach 3 expects this for tool changes in the g-code (addl first line added):

(tool change to 1/4 inch HSS Roughing Mill)
N70G43H2
N80T2M06

The fanuc G43 command is needed to tell Mach 3 to use the Z offset for tool 2.  
I copied the iso.py and called it iso_with_tooloffset.py and made the following 
change to the tool change code: 

def tool_change(self, id):
#Added the below 2 lines so that tool length offset occurs for mach3
        self.write_blocknum()
        self.write('G43H%i'% id +'\n')
# Added the above two lines for mach3
        self.write_blocknum()
        self.write((iso.codes.TOOL() % id) + '\n')

        self.t = id

I just re-used the iso_read.py file since no changes were needed, I made a copy 
called iso_with_tooloffset_read.py.

There is probably a better OO way to do this, to create a small fix file for 
adding this flavor, rather than duplicating the whole file.  I am no 
professional programmer, and this is the first time I worked in Python, so I 
was lucky enough getting it to work this way.  I attached all the files I use.

I am guessing there are others who use Mach3 and might have this problem if 
they change tools.  Might be nice to have a Mach3 machine setup, in addition to 
the ISO.

Original issue reported on code.google.com by filipmul...@q.com on 9 Aug 2010 at 2:26

Attachments:

GoogleCodeExporter commented 8 years ago
I haven't used Mach3 so I'm unsure but I wondered if you thought it appropriate 
to define a 'mach3.py' and 'mach3_read.py' file in a similar fashion to the 
emc2.py and emc2_read.py files.  The beauty with Python is that you can 
'inherit' from the iso.py file and just replace those methods that are 
different.  eg: we can effectively have a 'mach3.py' post processor file that 
does everything just like iso.py EXCEPT for those methods that have been added 
to the mach3.py file.

I did this for EMC2 so that space characters could be included in the GCode. I 
then based my machine's post processor on the emc2.py code rather than on 
iso.py.  In my case I mean the HM50.py post processor.  In HM50.py, I replaced 
the tool change command to include a rapid movement in machine coordinates so 
that the Z axis was as high as my machine would allow before issuing the T2M6 
tool change command.  The scenario being the HM50 is just like EMC2 except for 
the tool change command.  The EMC2 processor is, in turn, just like iso.py 
except for some other exceptions.

If the need to add the G43H? command is something that Mach3 requires then we 
could add all Mach3-specific changes to that.

I would be happy to setup a mach3.py file as an example but I don't want to do 
that if you believe I've missed the point.  I should also mention that this is 
just what I think.  If you would prefer to leave it as you have it here then 
that's fine with me too.

Original comment by David.Ni...@gmail.com on 9 Aug 2010 at 3:09

GoogleCodeExporter commented 8 years ago
David,
Yes, I think a 'mach3.py' and 'mach3_read.py' would be appropriate for him.
It would be great if you could add these.
Dan.

Original comment by danhe...@gmail.com on 9 Aug 2010 at 6:59

GoogleCodeExporter commented 8 years ago
Fillip,
  I have gone ahead and added a mach3 post process pair of files.  Feel free to modify them as you need.
  David Nicholls

Original comment by David.Ni...@gmail.com on 9 Aug 2010 at 1:10

GoogleCodeExporter commented 8 years ago
Thanks for making this change.  This makes total sense to create a machine type 
for Mach3.  Based on my usage so far I think this is the only change that is 
needed to get the output to work with Mach3.  If I discover anything more I 
will let you know.

Original comment by filipmul...@q.com on 10 Aug 2010 at 2:30

GoogleCodeExporter commented 8 years ago

Original comment by David.Ni...@gmail.com on 10 Aug 2010 at 3:52