CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Machine Controllers Software and Solutions > G-Code Programing


G-Code Programing Discuss G-code programing and problems here!


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 11-04-2005, 12:20 PM
 
Join Date: Jul 2005
Location: UK
Posts: 212
sploo is on a distinguished road
Paths to G-Code

Hi all,

I'm hoping to soon enter the world of CNC ownership, and I'm expecting to end up with a system with servos, controlled by Geckos and Mach 2/3.

I have a plan for making some cuts, for which I already know the path (rather than having a CAD model) - i.e. goto (x1, y1, z1) -> (x2, y2, z2) -> (xn, yn, zn).

Looking at the basics of G-Code, it would appear fairly easy to write a file with a series of "G1 linear interpolation" lines.

However, this of course assumes an infinitely thin cutting bit, whereas something around 1/4" is much more likely.

Can you simply add the nc program word "D tool radius compensation" with the right data and expect Mach to correctly process this?

Otherwise, does anyone know of any docs that give a good explaination of how to account for cutting radius when given a path, so I can create the correct G-Code moves. My paths aren't hugely complex, and I will always know which side of the 'line' I should be cutting on.

Alternatively, is there any software that will do this already (i.e. some form of CAM program that will accept a path in x,y,z format)?

Many thanks for any info,

Sploo.
Reply With Quote

  #2  
Old 11-04-2005, 12:48 PM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 20,454
ger21 is on a distinguished road
Buy me a Beer?

With Mach3, you can use G41 and G42 for cutter compensation. The only tricky part is that you need to add a lead-in move and lead out move for the compensation to take place. Say you want to cut a 2" square, from 1,1 to 3,3.

G0 X0 Y0 Z.125 ( Move into start position)
G42 P0.125 (Offset tool to the right with a .25"D tool)
G1 X0.75 Y1 Z-.125 (this is where the comp takes place, I like it end just outside my part)
G1 X3 Y1
G1 X3 Y3
G1 X1 Y3
G1 X1 Y0.75 (finish the square just outside your part)
G40 (turn off comp)
G1 X0 Y0 Z.125 (lead-out move)
__________________
Gerry

Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Reply With Quote

  #3   Ban this user!
Old 11-05-2005, 04:17 PM
 
Join Date: Jul 2005
Location: UK
Posts: 212
sploo is on a distinguished road

Gerry,

Many thanks for the post.

I've found some useful info at http://linuxcnc.org/handbook/gcode/diacomp.html which describes the radius compensation in a little detail.

Their example (of the triangle) sets the compensation, moves straight to the first coordinate, then moves through the rest of the triangle corners.

In your example you're performing lead-in and lead-out moves. Is this just required for Mach3, or is it an oversight of the info on linuxcnc?

Also, I don't quite follow the "G1 X0.75 Y1 Z-.125" line. The 0.75 is obviously 1-0.25, but why isn't the Y coordinate 0.75? Does the compensation mean that Mach3 realises the true start position should be X0.75, Y0.75? The sames goes for finishing at "G1 X1 Y0.75", rather than X1 Y1.

EDIT: Reading that webpage a little more closely, I note there's a conceptual difference between a "Material Edge Contour" and a "Tool Path Contour", and that they do note the need for a lead-in move - though it's a little different to your square example.

What would be the result (with your example) of setting compenation for a 0.25" tool, and starting/finishing at 1,1?
Reply With Quote

  #4  
Old 11-05-2005, 08:16 PM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 20,454
ger21 is on a distinguished road
Buy me a Beer?

Mach2's cutter comp was basically the same as EMC's (the site you linked). Imo, some of the info there is quite confusing. Mach'2s manual was basically a copy of that.

A few months ago, Art added an enhanced comp mode for Mach3. It's much easier to write code for. It won't gouge inside corners, either, so you won't get errors like in Figure 8 in your link.

Originally Posted by sploo
Their example (of the triangle) sets the compensation, moves straight to the first coordinate, then moves through the rest of the triangle corners.

In your example you're performing lead-in and lead-out moves. Is this just required for Mach3, or is it an oversight of the info on linuxcnc?
You do need a leadin and leadout move, that's where the compensation is applied and removed.


Also, I don't quite follow the "G1 X0.75 Y1 Z-.125" line. The 0.75 is obviously 1-0.25, but why isn't the Y coordinate 0.75? Does the compensation mean that Mach3 realises the true start position should be X0.75, Y0.75? The sames goes for finishing at "G1 X1 Y0.75", rather than X1 Y1.
The reason I start and end just outside the part, is to make sure the comp applied before the tool starts cutting the part. Mach3 will start the tool at the coordinates you tell it. The tool is comped before it get's to the next point. But it ends up at a point tangent to the programmed path and the comped path, so if the programmed point was 1,1, the tool wouldn't actually touch that point. I did a little drawing to make it easier to understand. The black line is the programmed path, whose coordinates are specified in the G-code. The red line is the actual path of the tool's center. Here is the g-code for the drawing.:

G1 X0.0000 Y0.0000 Z0.0000
G42P0.125
G1 X0.2500 Y1.0000 Z-0.1250
G1 X3.0000 Y1.0000 Z-0.1250
G1 X3.0000 Y3.0000 Z-0.1250
G1 X1.0000 Y3.0000 Z-0.1250
G1 X1.0000 Y0.5000 Z-0.1250
G40
G1 X0.7500 Y0.0000 Z0.0000

Notice that I use the leadin to ramp into the cut, and the leadout to ramp out. Much better than plunging.
Attached Thumbnails
Click image for larger version

Name:	G42.gif‎
Views:	138
Size:	15.3 KB
ID:	11763  
__________________
Gerry

Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Reply With Quote

  #5   Ban this user!
Old 11-07-2005, 04:09 AM
 
Join Date: Jul 2005
Location: UK
Posts: 212
sploo is on a distinguished road

Most interesting, thanks Gerry.

Thinking about it, there's obviously a lot more going on than just following a line at a fixed (radius) distance, as you need to perform all these turns at corners.

What would happen if you programmed a cut with that bit for the inside of the square? Would it perform the compensation, and result in slightly rounded internal corners, or would the compensation just fail?

Do you know where the Mach author(s) would had got the info on how to perform radius compensation? As I know the shape path I could probably generate the actual cutter path for a given bit, without the need for leadin/leadout cuts.

I can just about work out how I'd program a simple radius compensation algorithm, but if there's a good explanation/example code around then it's always better to use something that's tried and tested.
Reply With Quote

Sponsored Links
  #6  
Old 11-07-2005, 06:29 AM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 20,454
ger21 is on a distinguished road
Buy me a Beer?

If you comp it inside, it would work fine, with radius inside corners due to the round tool. Mach's old comp method (and EMC's) would gouge the corners.

I think he came up with the method on his own, but if you search do some searching I'd think you could find some info.

I don't know why you want to reinvent the wheel when it's so easy to add a lead-in and lead-out move. Just extend your normal start and end points roughly the tool radius beyond the part, and add new start and end points for the lead-in and lead-out. They can be virtually anywhere.
__________________
Gerry

Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Reply With Quote

  #7   Ban this user!
Old 11-07-2005, 10:19 AM
 
Join Date: Jul 2005
Location: UK
Posts: 212
sploo is on a distinguished road

I've downloaded a very impressive simulator from http://www.cncsimulator.com/ and had a play with the code you listed (and modified it to mill a 2" square hole).

I think I'm starting to get an idea of how this works, though still seeing things I don't quite understand with leadin lines.

The reason why it'd be a good idea if I could produce the exact paths myself is that I want to cut many concentric circles out of a single sheet. This means I woudn't have much room for leadin/out lines between the outside of one circle and the inside of the next.

I'll have a search for info on how it's done, but if anyone has details of how cncsimulator, or Mach, processes radius compensation I'd be most greatful.
Reply With Quote

  #8   Ban this user!
Old 11-21-2005, 12:09 PM
 
Join Date: Jul 2005
Location: UK
Posts: 212
sploo is on a distinguished road

OK, well, I've found some code over at http://www.linuxcnc.org/handbook/fileref/emc/files.html and taken a look at the comp algorithms in rs274ngc.cc.

Using these routines, I can simulate compensation (just putting coords into a simple app, and seeing what it outputs).

However, as Gerry notes "Mach's old comp method (and EMC's) would gouge the corners.". This code too will gouge internal corners, and infact will complain when given pretty much any concave corner.

It occurs to me that a not insignificant amount of 'looking ahead' would be required to ensure a path is followed that wouldn't gouge a concave corner on a shape - imagine walking a straight line which suddenly turned a sharp internal corner (which actually consisted of several G1 instructions).

So... how do the decent compensation methods work? Any advice greatly appreciated, as I'm a little stumped right now...
Reply With Quote

  #9  
Old 11-21-2005, 12:18 PM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 20,454
ger21 is on a distinguished road
Buy me a Beer?

Originally Posted by sploo
So... how do the decent compensation methods work? Any advice greatly appreciated, as I'm a little stumped right now...
With some fancy math. That's why I said it's much easier to just let Mach3 do it.
__________________
Gerry

Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Reply With Quote

  #10   Ban this user!
Old 11-21-2005, 12:22 PM
 
Join Date: Jul 2005
Location: UK
Posts: 212
sploo is on a distinguished road

*LOL* Fair point.

The problem is that I don't think I'm going to have the room for the lead in/out cuts as I need to pack the circles quite tightly, or I'm going to spend forever swapping sheets in and out of the machine (and wasting far more material than I'd want).

If I can generate compensated paths then I can ensure it's only ever going to cut where it's supposed to - with no 'overspill' from lead cuts.

However, the more I think about what's required, the more it looks like I'll be forced to use the automatic compensation, but I'd love to nail this myself.
Reply With Quote

Sponsored Links
  #11  
Old 11-21-2005, 12:55 PM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 20,454
ger21 is on a distinguished road
Buy me a Beer?

Lead in and out with an arc that's tangent to the circle, and starts just a little over 1/2 the tool diameter away. You'll have to check to see exactly how much clearance you need, but I think you can make it work without cutting much more than the tool diameter. If you need a picture to clarify this, let me know and I'll post one later.
__________________
Gerry

Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Reply With Quote

  #12   Ban this user!
Old 11-22-2005, 07:28 AM
 
Join Date: Jul 2005
Location: UK
Posts: 212
sploo is on a distinguished road

Yea, the problem is that the circle may not actually be a circle (I plan to deform the radii around the circle, so you could make things like star shapes, or rippled edges).

However, I think I understand vaguely what's going on now, so I can have a play with the cnc simulator to ensure I'd always leave enough room.

The other thing which occurred to me is that, surely you could start with your z axis above the workpiece, turn radius comp on, perform an (x/y) lead in move, then plunge in (knowing your x/y is correct), do your cut, then lift out of the workpiece before turning compensation off and moving away?

By doing that, I could stack the concentric rings close to one another (within the bit diameter) and know that the inside of one ring wouldn't be fouled when performing the lead moves for cutting the outside of the next smaller ring.

I have spoken to Art (author of Mach) who tells me he came up with his own algorithms, and that it's not nice. I've had a think about what's involved, and reckon I could code something that does a sensible look ahead (to produce moves safe for concave corners) but I suppose it's best not to reinvent the wheel, if I can get away with it.

Cheers,

Sploo.
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -5. The time now is 08:03 PM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361