PDA

View Full Version : Advice on converting Machine Code from Imperial to Metric



Stressedwoodman
02-05-2021, 08:23 PM
I have agreed to machine some components for someone, as a good gesture and think I have gone in over my head.
I have received some MC files that this person purchased that they are Imperial where as my machine is set up as Metric. I initially thought I would be able to modify the code in an excel spread sheet or with some VBA routines. However looking at the file format it isn’t fully as i expected.
Interesting Mach 3 reads the file in no problem, and changing the g20 to g21 it looks like when air machining it would machine the components- at a 40th scale. I have attached the header of one of the files, I don’t understand how it works without any xcoord data. I assume the N** is just line numbers.

So the question is there some software that can do the conversion properly, feeds and speeds too, and visualise it better than in mach3. Or is it simpler for me just to make an imperial set up file in mach3. With the later I am nervous about using other people’s files - when I don’t understand the pedigree or file format.


PROGRAM NAME - 001.3.NC)
(POST - BC_3X_MILL 3-AXIS GENERIC FANUC)
(DATE - THU. 07/23/2020)
(TIME - 05:03PM)


(FIRST MACHINE SETUP - MACHINE SETUP - 1)

N01 G00 G17 G40 G49 G54 G80 G20 G90

(FIRST CUT - FIRST TOOL)
(MACHINE SETUP - 1-FEATURE 3 AXIS-PLANAR)
(FEATURE 3 AXIS)

(TOOL #4 0.5 0.500 DIA. 0.250 CRAD. 4 FL.1.125 CL)
N02 T4 M06
N03 G54
N04 G00 G90 X-11.781 Y12.2657 S595 M03
N05 G43 H4 D4 Z1. M08
N06 Z0.2
N07 Z-0.65
N08 G01 Z-0.75 F20.
N09 Y12.2888 Z-0.7734 F180.
N10 Y12.3143 Z-0.7971
N11 Y12.3399 Z-0.8184
N12 Y12.3689 Z-0.8405
N13 Y12.398 Z-0.8604
N14 Y12.427 Z-0.8783
N15 Y12.4561 Z-0.8943
N16 Y12.484 Z-0.9082
N17 Y12.5118 Z-0.9205
N18 Y12.5397 Z-0.9316
N19 Y12.5676 Z-0.9413
N20 Y12.5968 Z-0.9502
N21 Y12.626 Z-0.9577
N22 Y12.6538 Z-0.9637
N23 Y12.6817 Z-0.9685
N24 Y12.7101 Z-0.9724
N25 Y12.7386 Z-0.9751
N26 Y12.7953 Z-0.9772
N27 Y12.8239 Z-0.9766
N28 Y12.8526 Z-0.975
N29 Y12.8809 Z-0.9724
N30 Y12.9092 Z-0.9685
N31 Y12.9371 Z-0.9636
N32 Y12.965 Z-0.9576
N33 Y12.994 Z-0.9501
N34 Y13.023 Z-0.9413
N35 Y13.0507 Z-0.9316
N36 Y13.0784 Z-0.9207
N37 Y13.1061 Z-0.9084
N38 Y13.1338 Z-0.8947

johnsattuk
02-05-2021, 08:44 PM
Have a look at "Discriminator"

JAZZCNC
02-05-2021, 09:03 PM
Mach 3 uses generic Fanuc code that's why it works.

The fact it only uses one X coordinate on line #4 makes no difference to mach3. Without seeing the rest of the code and knowing what it's cutting then difficult to say if good or bad code.

Just changing G20 to G21 isn't enough for it to work correctly. G21 will make it the correct size but it won't change the feed rates so all the F codes will be wrong. For instance, F20 on line #8 will mean you'll travel at 20 mm/min instead of 20 inches a minute which was originally coded. So you'll need to multiply all the F numbers by 25.4 to get the correct mm/min feed rate.

When using imperial G-code it's easier to set up an imperial profile in mach3 as this will avoid the feed rate issue.
It's simple to do, just copy the profile you are using now, change the units to imperial, and change all the Steps per settings by multiplying them by 25.4 because now mach3 is working in STEPS PER INCH rather than STEPS PER MM
So let's say you have the STEPS PER at 160, which is a common metric setting if using 10mm pitch screws with 1600 micro steps set on the drives with no ratios applied. This now needs to be 160 x 25.4 = 4064 STEPS PER INCH.

The Velocity and acceleration are the opposite, now you divide by 25.4 because let's say you are set for 10,000 mmm/min this will become 10,000 Inch/Min.!!!

Then restart Mach3 for the units to reset.

Stressedwoodman
02-05-2021, 10:49 PM
Thanks Dean. I will investigate making a second imperial profile. Hopefully it’s a text file I can copy and edit.

I think I will get a coupe of blocks of insulation foam to test out on. It looks like in goes in with a 3/8” cut at one point.. with a 1/2” cutter which seems scary to me even in wood. I prefer light cuts and fast feeds.

JAZZCNC
03-05-2021, 02:27 PM
Thanks Dean. I will investigate making a second imperial profile. Hopefully it’s a text file I can copy and edit.

Don't need to do that just use the mach3 loader and create a new profile, it will then give you the option to Clone an existing profile. Select your current MM profile and make the changes I mentioned in the previous post.

Don't forget to restart Mach3 after you have changed the units from MM to Imperial and made the Steps per changes.

johnsattuk
03-05-2021, 02:41 PM
Or use Discriminator to multiply your axis and feeds by 25.4 and do a save as, 30 secs tops. still got your origional file and not had to reconfigure your M/C

Stressedwoodman
03-05-2021, 02:47 PM
I assume the native units in config is what I must toggle to inches. I assume I have to change all the limits and homing values to imperial too, as well as the parameters under motor tuning. In motor tuning I assume I factor the G’s parameters too - or is this dimensionless?

JAZZCNC
03-05-2021, 02:51 PM
Or use Discriminator to multiply your axis and feeds by 25.4 and do a save as, 30 secs tops. still got your origional file and not had to reconfigure your M/C

The short-sighted approach, in my opinion, literally takes 2mins to create a new profile. You are not reconfiguring the machine just making a few simple adjustments to a completely separate profile, his original config isn't affected at all.
Then from that point on no messing around in a separate program is required, you just load the imperial profile when cutting imperial code.!! . . . Simplzzzz

JAZZCNC
03-05-2021, 02:56 PM
I assume the native units in config is what I must toggle to inches. I assume I have to change all the limits and homing values to imperial too, as well as the parameters under motor tuning. In motor tuning I assume I factor the G’s parameters too - or is this dimensionless?

Yes toggle native untis. If you have Softlimits set then yes they will need changing also.

You can't change the G's it auto-adjusts with the Velocity and Acceleration changes.

Stressedwoodman
05-05-2021, 09:27 PM
Had a chance today to test the imperial set up.. used the MDI screen in Mach 3 to check things. The y and z axis measured accurate enough with the dial gauge. However the x axis however is moving twice the commanded distance. The x axis is the simplest one being 160 steps per mm as a 1:1 drive. Any suggestions on what’s going wrong i have checked what I have typed in to the parameters a number of times, and saved it.

Stressedwoodman
08-05-2021, 01:16 PM
This morning, with foul weather outside, was the perfect opportunity to generate some test G codes to check if the imperial setup is working as it should. I have wasted ages in aspire trying to figure how to write out an imperial set on gcodes. Although you set the units as inches in the setup page, it converts everything to metric when it writes out the gcode. Only noticed it as it tried to set the z height to 10, not the 0.3 I had inputted, thanks go for soft limits. I cannot find any obvious toggles to tell aspire to write out in imperial, and the help is not helpful.

johnsattuk
08-05-2021, 01:20 PM
Overall a bit longer than 2 mins then

Stressedwoodman
08-05-2021, 01:53 PM
Found it... for some strange reason would only allow me to pick a different translator, with a single tool path highlighted.

phill05
08-05-2021, 02:39 PM
This morning, with foul weather outside, was the perfect opportunity to generate some test G codes to check if the imperial setup is working as it should. I have wasted ages in aspire trying to figure how to write out an imperial set on gcodes. Although you set the units as inches in the setup page, it converts everything to metric when it writes out the gcode. Only noticed it as it tried to set the z height to 10, not the 0.3 I had inputted, thanks go for soft limits. I cannot find any obvious toggles to tell aspire to write out in imperial, and the help is not helpful.

Did you chose the Imp "Post Processor" before you saved your toolpath in Aspire.

Phill

Stressedwoodman
08-05-2021, 02:58 PM
All sorted confident that the machine understands and does what it’s told to in the imperial setup. It was as easy as Dean said.... Not sure what was going off with the MDI last time but that working as I would expect.. Any screws up won’t be the machine setup... the idiot driving it or dodgy g code.

Now for the difficult bit.. understanding the gcode... already emailed the vendor of the code to ask why there is a different datum(G90) for each tool change. In my 30 odd years of engineering I have never seen datums refined so many times.

JAZZCNC
08-05-2021, 06:14 PM
Overall a bit longer than 2 mins then

But one time only John.! . . .Not every time he wants to run imperial G-code.

JAZZCNC
08-05-2021, 06:17 PM
Now for the difficult bit.. understanding the gcode... already emailed the vendor of the code to ask why there is a different datum(G90) for each tool change. In my 30 odd years of engineering I have never seen datums refined so many times.

G90 is not a Datum, it's switching the mode to Absolute, G91 puts it into incremental mode.

johnsattuk
09-05-2021, 09:15 AM
But one time only John.! . . .Not every time he wants to run imperial G-code.:thumsup:

Stressedwoodman
18-07-2021, 03:16 PM
A bit of a stupid question, which shows my ignorance in NC coding. These imperial programs I am using have a tool change callout G43. This line is causing me an issue on some of the latter programs I am running, as I have limited Z axis travel and don’t have the luxury of allowing the spindle to go to Z1 an inch above the work piece. It’s weird why the programs have tool changes specified as it’s all one tool.

Can I simply remove the line from the programme ... or do I just modify it to say Z0.25. I am not clear whether the program refers back to the tool change or not. I have searched the program and it only has one g43 callout.
30263

JAZZCNC
18-07-2021, 04:32 PM
Can I simply remove the line from the programme ... or do I just modify it to say Z0.25. I am not clear whether the program refers back to the tool change or not. I have searched the program and it only has one g43 callout.

G43 is tool length compensation, so if you have not set any tool lengths in your tool table then you can just delete it. Or you can just change the Z value.
Somewhere in your CAM program, you will have a setting to change the Z value.