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 03-22-2011, 03:29 PM
 
Join Date: Feb 2011
Location: United States
Posts: 25
cjluke is on a distinguished road
Need help with G3 code

I am a noobie... that said I wrote the following program and it does exactly what I intended:

G21 (sets the file units to millimeters. )
#1 = 38 (Rough Diameter of Post)
#2 = 12.7 (Cutter diameter)
#3 = -5 (Z depth increment value )
#4 = [#1 + #2] (Diameter of POST to mill... post diameter + tool diameter )
#5 = [#4 / 2] (Radius of POST to mill )
#8 = 100 (travel speed )

(rough cut the post)
G90
G0 X[#5 * -1] Y0 Z5 F#8
#6 = 1 (tool depth counter)
#7 = 0 (actual Z depth variable )
M98 P100 L4

(finish cut the post)
#1 = 35.50 (Finish Diameter of Post)
#4 = [#1 + #2] (Diameter of POST to mill... post diameter + tool diameter )
#5 = [#4 / 2] (Radius of POST to mill )
G1 X[#5 * -1] Y0
G17 G3 x[#5 * -1] y0 i#5 j0 (select the XY plane and do arc counter clockwise )

(cut relief for tube seam weld)
G0 Z5
G0 X#5 Y0
G0 Z#7
G1 X [#5 - 1]

(cut the hole---lighten the finished piece)
#1 = 25 (Diameter of Hole)
#4 = [#1 - #2] (Corrected Diameter of HOLE to mill... hole diameter - tool diameter )
#5 = [#4 / 2] (Radius of HOLE to mill )
G0 Z5 (clear the Z axis from the work surface)

G0 X[#5 * -1] Y0 Z5 F#8
#6 = 1 (tool depth counter)
#7 = 0 (actual Z depth variable )
M98 P110 L4

M30

O100 (mill a POST)
#6 = [#6 + 1] (increment counter)
#7 = [#3 * #6] (adjust tool depth for this count)
G1 Z#7 (set tool depth)
G17 G3 x[#5 * -1] y0 i#5 j0 (select the XY plane and do arc counter clockwise )
M99 (return from subroutine)

O110 (mill a HOLE)
#6 = [#6 + 1] (increment counter)
#7 = [#3 * #6] (adjust tool depth for this count)
G1 Z#7 (set tool depth)
G17 G2 x[#5 * -1] y0 i#5 j0 (select the XY plane and do arc clockwise )
M99 (return from subroutine)



Then I wrote the following and it did exactly what I expected:

G21 (sets the file units to millimeters. )
#1 = 38 (Diameter of large arc)
#2 = 12.7 (Cutter diameter)
#3 = -5 (Z depth increment value )
#4 = [#1 + #2] (Diameter of POST to mill... post diameter + tool diameter )
#5 = [#4 / 2] (Radius of POST to mill )
#8 = 100 (travel speed )
#9 = 11.4 (diameter of small arc)

G90

G0 X0 Y#5 Z5 F#8
#6 = 1 (tool depth counter)
#7 = 0 (actual Z depth variable )
M98 P100 L4

M30

O100 (mill a POST)
#6 = [#6 + 1] (increment counter)
#7 = [#3 * #6] (adjust tool depth for this count)
#4 = [#1 + #2] (Diameter of large arc to mill... post diameter + tool diameter )
#5 = [#4 / 2] (Radius of large arc )
G1 Z#7 (move the tool to starting depth)
G17 G3 X0 Y[#5 * -1] i0 j[#5 * -1] (select the XY plane and do large arc counter clockwise )
#4 = [#9 + #2] (Diameter of small arc to mill... post diameter + tool diameter )
#5 = [#4 / 2] (Radius of small arc )
G1 X25.45 Y[#5 * -1] (cut to starting point of small arc)
G17 G3 X25.45 Y#5 i0 j#5 (select the XY plane and do small arc counter clockwise )
#4 = [#1 + #2] (Diameter of large arc to mill... post diameter + tool diameter )
#5 = [#4 / 2] (Radius of large arc )
G1 X0 Y#5 (cut to starting point of large arc)
M99 (return from subroutine)


Now comes the problem:
I want the second program to create the large arc and the small arc such that they end on a line that is tangent to both arcs. That way I have a smooth transition from the large arc to the small arc. I have wrote many test programs trying to understand the G3 command but try as I might... I can only seem to get it to do a half circle instead of the "little more" that I need

can anyone help me? If you consider that the center point of the large arc is 0,0 I know where I want to start milling the arc and I know where I want to stop milling the arc. From there I want to mill a "straight line" to the tangent of the small arc, mill the small arc, and mill a "straight line" back to my starting point.

thanks in advance
cj
Reply With Quote

  #2   Ban this user!
Old 03-22-2011, 06:19 PM
 
Join Date: Sep 2010
Location: Australia
Posts: 733
angelw is on a distinguished road

A quick look at your program, gives me to believe that in the attached picture, the Green is the tool path that you currently achieve, but your question indicates that you want a combination of the Green Arcs and the Red Lines.

Click image for larger version

Name:	LS_Circles.JPG
Views:	33
Size:	16.3 KB
ID:	129614

The above being the case, you need to do some maths with your User MAcro code to calculate the 4 Tangent Points of the 2 circles and 2 Red lines. Having done that, you will have the Start Point, End Point, I and J values to use in the G03 command line. The blue triangles in the attached picture have to be calculated to gain this information. Its not shown in the picture, but you would use the same method to calculate the tangent points of the small circle as was used for the large circle.

Click image for larger version

Name:	LS_Circles2.JPG
Views:	30
Size:	23.0 KB
ID:	129617
The following code is an example of what your coordinates should be, and how applied to the G03 command lines. Of course, you would substitute the X, Y, I, and J values where applicable with the Macro Variables used to receive the calculated data.

Regards,

Bill

G01 X13.790 Y21.271
G03 X13.790 Y-21.271 I-13.790 J-21.271
G01 X31.005 Y-10.111
G03 X31.005 Y10.111 I-6.555 J10.111
G01 X13.790 Y21.271

Last edited by angelw; 03-22-2011 at 09:16 PM.
Reply With Quote

  #3   Ban this user!
Old 03-22-2011, 06:31 PM
 
Join Date: Feb 2011
Location: United States
Posts: 25
cjluke is on a distinguished road

you are correct Anglew. That is the end result I am looking for but my problem is not the math to calculate where the two tangent lines begin and end. My problem is making the arcs start and end at those tangent points. I just can't seem to make the arc begin and end where I want them to
Reply With Quote

  #4   Ban this user!
Old 03-22-2011, 07:00 PM
 
Join Date: Feb 2011
Location: United States
Posts: 25
cjluke is on a distinguished road

Angelw.... I love u

I ran your little code snippit and it does exactly what I want. After playing with it some... commenting out some steps... I figured out why I was having problems.

I'm off and running now... thanks a bunch
Reply With Quote

  #5   Ban this user!
Old 03-22-2011, 07:14 PM
 
Join Date: Feb 2011
Location: United States
Posts: 25
cjluke is on a distinguished road

I need to ask you one more thing Anglew. You came up with the correct numbers for the tangent intercepts awfully quickly... how did you do that?
cj

and thanks again for the help
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 03-22-2011, 08:14 PM
 
Join Date: Sep 2010
Location: Australia
Posts: 733
angelw is on a distinguished road

Originally Posted by cjluke View Post
I need to ask you one more thing Anglew. You came up with the correct numbers for the tangent intercepts awfully quickly... how did you do that?
cj

and thanks again for the help
Like a lot of people that answer questions on this forum, I've been doing this a long time. I started in the days of NC, when paper tapes had to be created to run a program and programming was predominately done by calculating the tool path manually (no CAM systems). The math in your problem is simple so its a relatively quick program to do.

By the way, the early Fanuc Mill, Conversational program was based on the User Macro executable, (not sure about more recent models; I haven't bothered to look). Pocket clearing was achieved by altering the value of the Macro Variable holding the Tool Radius data. This method was also used to accurately size the feature, by applying a value to the Tool Radius Variable and not using G41 or G42 (cutter radius comp). This worked pretty well, as you didn't have to worry so much about how you had the cutter approach the cutter path, as you do when using G41 or G42.

You could expand your Macro program by applying a Tool Radius System Variable to #2 used in your program. That way you could tweak the size of the feature via a Tool Offset, rather than hard coding the value. You will find the reference to the System Variables in your Fanuc programming manual.

Regards,

Bill
Reply With Quote

  #7   Ban this user!
Old 03-22-2011, 10:09 PM
 
Join Date: Feb 2011
Location: United States
Posts: 25
cjluke is on a distinguished road

And you thought you were through with me

I have one more question. I have figured out everything you calculated but one value:

G0 X13.790 Y21.271
G03 X13.790 Y-21.271 I-13.790 J-21.271
G01 X31.005 Y-10.111


G03 X31.005 Y10.111 I-6.555 J10.111
______

G01 X13.790 Y21.271

how did you arrive at the value I-6.555?????
Reply With Quote

  #8   Ban this user!
Old 03-22-2011, 11:40 PM
 
Join Date: Sep 2010
Location: Australia
Posts: 733
angelw is on a distinguished road

Originally Posted by cjluke View Post
And you thought you were through with me

I have one more question. I have figured out everything you calculated but one value:

G0 X13.790 Y21.271
G03 X13.790 Y-21.271 I-13.790 J-21.271
G01 X31.005 Y-10.111


G03 X31.005 Y10.111 I-6.555 J10.111
______

G01 X13.790 Y21.271

how did you arrive at the value I-6.555?????
No problem, ask as many questions as you like; I'm glad to be able to help.

I and J are specified in the circular interpolation (G02/G03) command line in terms of distance and direction from the Start Point of the arc, to the Center Point of the same arc. Coincidentally, during the process of calculating the tangent point of the small circle and line, you also gain the I and J value. See the attached picture.

Click image for larger version

Name:	LS_Circles3.JPG
Views:	41
Size:	28.4 KB
ID:	129657


Regards,

Bill
Reply With Quote

  #9   Ban this user!
Old 03-23-2011, 03:16 AM
 
Join Date: Jul 2003
Location: New Zealand
Posts: 1,039
Kiwi is on a distinguished road

This may help with your macro.
R1 = radius of larger circle
R2 = radius of smaller circle
CC = centre to centre

Angle = ASine(R1-R2) / CC

X1 = Sine(Angle) * R1
Y1 = Cos(Angle) * R1

X2 = (Sine(Angle) * R2) + CC
Y2 = Cos(Angle) * R2
Attached Thumbnails
Click image for larger version

Name:	Tangent Points.JPG‎
Views:	42
Size:	33.4 KB
ID:	129668  
Attached Files
File Type: zip Tangent Points.zip‎ (5.9 KB, 17 views)
Reply With Quote

  #10   Ban this user!
Old 03-23-2011, 10:48 PM
 
Join Date: Feb 2011
Location: United States
Posts: 25
cjluke is on a distinguished road

Thanks Kiwi and thanks Angelw.... problem was this 65 year old man's brain not wanting to get back into trig and geometry

I finally managed to see what I was doing wrong and have generated the following code that behaves like I wanted it to. If not for you two, I would still be working on it. Thanks again and I will probably come knocking on your doors again. A friend and I bought a Kondia Powermill 3 axis CNC running Mach 3. Neither of us are machinist so we have much to learn

here is the code I wrote. I have a lot I need to add to it but the hard part was the outside shape:
thanks again
cj

G21 (sets the file units to millimeters. )
#1 = 38 (Diameter of large arc)
#2 = 12.7 (Cutter diameter)
#3 = -5 (Z depth increment value )
#4 = [#1 + #2] (Diameter of large arc to mill... arc diameter + tool diameter )
#5 = [#4 / 2] (Radius of Large arc to mill )
#8 = 100 (travel speed )
#9 = 11.4 (diameter of small arc)
#10 = [#9 + #2] (diameter of small arc to mill )
#11 = [#10 / 2] (radius of small arc to mill )
#12 = 25.5 (distance between the two arc centers)
#13 = [2*ACOS[[#5-#11]/#12] * 57.2957795] (angle Theta in degrees start of large arc)
#15 = [#5 * COS[#13]*-1] (x position to start of large arc)
#16 = [#5 * SIN[#13]*-1] (y position to start of large arc)
#17 = [[#9 * COS[#13]*-1] + #12] (x position to start of small arc)
#18 = [#9 * SIN[#13]*-1] (y position to start of small arc)
(rough cut the outside of the part)
G0 X#15 Y#16
#6 = 1 (tool depth counter)
#7 = 0 (actual Z depth variable )
M98 P100 L4
M30
O100 (mill the shape)
#6 = [#6 + 1] (increment counter)
#7 = [#3 * #6] (adjust tool depth for this count)
G1 Z#7 (set tool depth)
G17 G03 X[#15] Y[#16 * -1] I[#15 * -1] J[#16 * -1]
G01 X#17 Y[#18*-1] (cut to start of small arc)
G17 G03 X#17 Y[#18] I[[#17 - #12]*-1] J#18 (select the XY plane and do small arc counter clockwise )
G01 X#15 Y#16 (cut to starting point of large arc)
M99 (return from subroutine)
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 03-24-2011, 01:29 AM
 
Join Date: Feb 2006
Location: india
Posts: 1,187
sinha_nsit is on a distinguished road

Instead of multiplying a variable with -1, why don't you just put a minus sign before the variable? It works on my machine.
Reply With Quote

  #12   Ban this user!
Old 03-24-2011, 02:18 AM
 
Join Date: Sep 2010
Location: Australia
Posts: 733
angelw is on a distinguished road

Originally Posted by cjluke View Post
Thanks Kiwi and thanks Angelw.... problem was this 65 year old man's brain not wanting to get back into trig and geometry


G21 (sets the file units to millimeters. )
#1 = 38 (Diameter of large arc)
#2 = 12.7 (Cutter diameter)
#3 = -5 (Z depth increment value )
#4 = [#1 + #2] (Diameter of large arc to mill... arc diameter + tool diameter )
#5 = [#4 / 2] (Radius of Large arc to mill )
#8 = 100 (travel speed )
#9 = 11.4 (diameter of small arc)
#10 = [#9 + #2] (diameter of small arc to mill )
#11 = [#10 / 2] (radius of small arc to mill )
#12 = 25.5 (distance between the two arc centers)
#13 = [2*ACOS[[#5-#11]/#12] * 57.2957795] (angle Theta in degrees start of large arc)
#15 = [#5 * COS[#13]*-1] (x position to start of large arc)
#16 = [#5 * SIN[#13]*-1] (y position to start of large arc)
#17 = [[#9 * COS[#13]*-1] + #12] (x position to start of small arc)
#18 = [#9 * SIN[#13]*-1] (y position to start of small arc)
(rough cut the outside of the part)
G0 X#15 Y#16
#6 = 1 (tool depth counter)
#7 = 0 (actual Z depth variable )
M98 P100 L4
M30
O100 (mill the shape)
#6 = [#6 + 1] (increment counter)
#7 = [#3 * #6] (adjust tool depth for this count)
G1 Z#7 (set tool depth)
G17 G03 X[#15] Y[#16 * -1] I[#15 * -1] J[#16 * -1]
G01 X#17 Y[#18*-1] (cut to start of small arc)
G17 G03 X#17 Y[#18] I[[#17 - #12]*-1] J#18 (select the XY plane and do small arc counter clockwise )
G01 X#15 Y#16 (cut to starting point of large arc)
M99 (return from subroutine)

I'm sure I speak for Kiwi and all contributors of this forum, when I say that its good to get some feedback and see a positive outcome as a result of suggestions made.

As with most things, there are a number of ways to skin this cat. Shown in Red is one of a few ways of repeating a profile down in Z without having to be concerned about over cutting, whilst giving you the opportunity of changing the depth of cut without having to ensure that its exactly divisible into the full depth.

Also, you should take a look at passing your variable values to the Macro using a simple call statement as follows. This example is only passing the values for the cut in and full depth, but other variables could be passed as well. It just makes for a more organized program; you will create better structured programs as you do more.

G65 C-5.0 D0.0 I-23.0 P100

In the above example C=#3, D=#7 and I=#4 when passed to you Macro program

I've just used -23.0 for full depth to show that the cut in depths don't have to be exactly divisible into the full depth.

Regards,

Bill


M98 P100 (just call the program once without repeats)

O100
(#7 = 0 (Z start level)) from main program
(#3 = -5.0 (Z depth of cut)) from main program
#4 = -23.0 (Z full depth) example depth
N10
#7 = #7 + #3 (adjust tool depth)
IF [#7 LT #4] THEN #7 = #4
(make #7 = full depth to stop over cutting)

G1 Z#7 (set tool depth)
G17 G03 X[#15] Y[#16 * -1] I[#15 * -1] J[#16 * -1]
G01 X#17 Y[#18*-1] (cut to start of small arc)
G17 G03 X#17 Y[#18] I[[#17 - #12]*-1] J#18 (select the XY plane and do small arc counter clockwise )
G01 X#15 Y#16 (cut to starting point of large arc)
IF [#7 GT #4] GOTO10 (go back to N10 if not to depth)
M99 (return from subroutine)
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help!- My Milling OKK with fanuc 6M can't recognize G-code & M-code nessei Fanuc 4 03-29-2011 08:39 AM
fanuc program code vs. Haas code sixty8frbrd Fanuc 6 03-10-2011 09:05 PM
Converting Fanuc G code to Seimens 840D G code Jasbinder Siemens Sinumerik CNC controls 2 02-20-2011 10:02 AM
Newbie- Takeout Unused G Code commands in Mastercams Generated G Code shneek Mastercam 8 12-15-2010 02:32 PM
looking for g code 3d from bobcadcam or simmilar for indexer lpt v5 with g code soft troyswood Ability Systems - LPT Indexer and G-Code 2 12-24-2006 09:21 PM




All times are GMT -5. The time now is 07:55 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