Hello Guest it is March 28, 2024, 02:42:48 PM

Author Topic: changing mach from inches to run a gcode output in mm  (Read 2780 times)

0 Members and 1 Guest are viewing this topic.

changing mach from inches to run a gcode output in mm
« on: April 15, 2019, 03:09:53 PM »
Hi,

I always run my machine in inches, but now I have some code output from different software that only does mm.
So should i create a new profile and set unit to mm and change motor tuning settings accordingly.

Just figure its easier to just fire up the appropriate profile then...one for inches, one for mm.

thoughts? suggestions...
Re: changing mach from inches to run a gcode output in mm
« Reply #1 on: April 15, 2019, 03:15:31 PM »
Hi,
you could do that but there is a much better way.

If you put a line of Gcode at the top of the new file:
G21

Thereafter Mach will interpret all axis positions and feed rates as mm. If you code:
G20

Mach will interpret all measurements as inch units.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: changing mach from inches to run a gcode output in mm
« Reply #2 on: April 15, 2019, 03:17:49 PM »
okay...so i dont need to change my units at all...keep it the same (inches) and put the code in the file.??

Is there a specific spot the code should go?? can you give example?
Re: changing mach from inches to run a gcode output in mm
« Reply #3 on: April 15, 2019, 03:19:51 PM »
okay...i see...so just switch out that line in the file..only used once...
Re: changing mach from inches to run a gcode output in mm
« Reply #4 on: April 15, 2019, 03:36:19 PM »
Hi,
quite commonly the first line of code at the top of a Gcode job will have a long string of codes, something like:
G15 G17 G40 G90 G94 G54 G49 G99 G64........to which you can append a G20 for inch unit Gcode or G21 fro mm unit
Gcode. You could just as easily code it on its own line right at the top of the file.

I'll leave you to work out what all and each of those codes are but they set the machine up, G17 for instance declares
the XY plane with Z vertical, ie a VMC. You could use G18 which declares XZ plane with Y as spindle axis, ie a horizontal
milling machine.

The codes are all 'modal', that is that once set they stay in force until they are changed or overwritten by a new code.
Thus when you have finished the metric Gcode job you need to switch it back to inch units with a G20, otherwise you will
get a surprise the next time you use the machine.

It is common for CAD/CAM programs to include a G20/G21 command at the beginning of the file so that the machine
correctly interprets the units that the CAD/CAM package used.

Try and find a copy of:

'CNC Programming  Hanbook', any edition, by Peter Smid. Its considered the bible of CNC Gcode.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: changing mach from inches to run a gcode output in mm
« Reply #5 on: April 15, 2019, 03:40:21 PM »
ok..yes my code has a line for g20 already...so just switch that to g21 and vice versa etc...

..but you don't have to do anything else even if your mach is set to inches??
sounds like voodoo magic...
« Last Edit: April 15, 2019, 03:48:16 PM by airbrush »
Re: changing mach from inches to run a gcode output in mm
« Reply #6 on: April 15, 2019, 03:49:20 PM »
Hi,

Quote
..but you don't have to do anything else even if your mach is set to inches??
sounds like voodoo magic...

Mach is a computer program....it has no bias. By issuing a G20/G21 Mach applies a numerical procedure to all
measurements...pretty simple.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: changing mach from inches to run a gcode output in mm
« Reply #7 on: April 15, 2019, 03:50:27 PM »
okay so its just doing it in the background...if its 1 inch it will make it 25.4mm etc etc etc
Re: changing mach from inches to run a gcode output in mm
« Reply #8 on: April 15, 2019, 03:52:53 PM »
Hi,
its just a shame that Mach (Mach3 and Mach4) always interprets angles as degrees, I would prefer radians, but
neither version of Mach support that.

It would be so much more convenient for 4 and 5 axis machines when trying to match angular and linear axis velocity.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: changing mach from inches to run a gcode output in mm
« Reply #9 on: April 15, 2019, 03:53:54 PM »
ok..now you're confusing me...ha...

so you're saying just change it to g21 and all is good...maybe i didn't explain well?

so the code i have will be in mm....change it to g20....so how does it know to do a conversion? if the original line of code was x25.4 y25.4 z25.4 and i change it to inches...won't it just read it as 25.4 inches?...
« Last Edit: April 15, 2019, 04:01:25 PM by airbrush »