Universal Robots Forum

G-Codes used in post processor file

Hi Guys,

I’ve got a question about the G-codes used in the output file from the Solidworks post processor.

I’ve noticed that in my file the G-Code G21 is used at the start of the file. This says that its using Inches and not mm. Will this have an effect on the accuracy of the robot?

I only use mm in my measurements and while the robot is accurate in its run, it is out by 2mm. While I don’t think this will fix my issue, I’m more curious as to where/why its using this G-Code. See example below…

(G - code output for Universal Robots’ Remote TCP & Toolpath URCap)
(UR Toolpath Generator Version : 1.0)
N10 G21 G90
N30 G01 X95.000000 Y45.000000 Z5.000000 F4800.000000
N40 G01 X95.000000 Y45.000000 Z2.000000 F4800.000000

OK, So the internet says G21 is mm and G20 is inches…yet the doco says this…

G00-03*: All the rapid, linear, circular and helical moves
G90-91: Absolute vs incremental programming
G20-21: G-code for units (mm/inch)
G17-19: Plane of motion
G54-59: defining multiple coordinate systems and allowing multiple programs at different locations
The URCap will display an error popup if an incompatible motion-related G-code is present in the imported file (G41, G42). Unsupported G-codes that are not related to robot motion are generally ignored by the URCap.

I’ll be closing this and not trusting the UR doco…

The industry standard for G20 is inches on CNC machining centers. I don’t use our cobots to machine with so I haven’t seen the Gcodes for it for Cobots, but I doubt they would do the opposite of the industry standard. Right? RIGHT? :slight_smile:

Anyway, the “accuracy” between imperial and mm should not be an issue. Set it for what you are used to (mm in your case).

Hope this helps.

1 Like

Hi Fuknrekd,

I was just wondering about the feed rates in the Gcode as well. In the post processor Gcode spat out by Solidworks - in which I’ve set the tool speed to be 60mm/Sec why does it show up in the code as F3600.000000?

Is the F3 a specific code? I’m looking at slowing down the robot at specific coordinates and just need a little insight as to how its translating the 60mm in the Solidworks add in to the F3600.000000 in my previous examples above.

or if you can point me to some doco that would be awesome.


Here is more of the Gcode that shows more of the code…

N10 G21 G90
N30 G01 X103.000000 Y46.000000 Z5.000000 F4800.000000
N40 G01 X103.000000 Y46.000000 Z2.500000 F4800.000000
N50 G01 X103.000000 Y46.000000 Z2.500000 F3600.000000
N60 G01 X102.064264 Y47.888702 Z2.500000 F3600.000000
N70 G01 X100.133457 Y51.918469 Z2.500000 F3600.000000

CNC’s usually process feed rates (F) based on inches (or millimeters) per minute, not per second, so you’ll have to convert it from seconds to minutes to see if it’s what you want.

For the CNC side, 3600 mm per minute converts to 60 mm per second (3600 / 60) so the feed rate is converting the way it should. (The F is the specific code. 3600 is the value.)

I"m not sure what you’re cutting and how, and I don’t speak metric well so I converted 3600 to inches and that’s over 140 inches per minute. Pretty fast for many applications that are not very rigid (robots are inherently not rigid).

If you give more info on what and how you’re cutting I may be able to get you something close.

As for documentation, there’s nothing that I know of that relates specifically to robots and CNCs, but there are a lot of good reference sites out there to help you. CNC Cookbook is a good reference for general CNC, and Practical Machinist has a good forum with a LOT of topics already covered.

Hope this helps.


Thank you,

I have a machinist mate and I spoke with him last night and you’ve hit the nail on the head. He said that he uses minutes and not seconds. He also helped me convert and was surprised at the speed of the bit!

I told him that I’m dispensing Poly Urethane and not cutting at all, to which he was relieved as well.

Thank you so much for your help in this!!!


1 Like

You’re welcome, I’m glad you got it figured out.