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-10-2010, 05:51 AM
Apples's Avatar  
Join Date: Feb 2004
Location: Australia, Queensland
Posts: 416
Apples is on a distinguished road
Ok, how do I do write a simple program in gcode?

Ok, how do I do write a simple program in gcode?

I want to make the mill go from say 0 to 100, then back to 50 then up to 200 and back to 150 then up to 250 etc.

So far I know G0y100 will move me from home, to y100mm position at full speed.

There is an F200 command for feed speed, but where abouts in that line would that F code go?

And can I add in a dwell too.
And do I have to then number the lines as N1, N2, N3 with each seperate command on each line etc.

Peter
__________________
My little site on MIG welding http://www.learn-how-to-weld.com/mig-welding/
Reply With Quote

  #2   Ban this user!
Old 11-10-2010, 06:41 AM
 
Join Date: Jan 2005
Location: USA
Posts: 2,348
mactec54 is on a distinguished road
Buy me a Beer?

Apples

G0 is for rapid moves, G1Y100F50. G1 is what you want to use for a feed move

G1Y100F50.
G1Y-50F50.

A Dwell is G04P500 The 500=0.5 second dwell (place this on a line by its self were ever you want it to stop/Dwell)

Try this to start to see how it will work for you, You can ajust the numbers to suit
__________________
Mactec54
Reply With Quote

  #3   Ban this user!
Old 11-10-2010, 07:22 AM
Apples's Avatar  
Join Date: Feb 2004
Location: Australia, Queensland
Posts: 416
Apples is on a distinguished road

Cool thanks for that, I will give it a shot tomorrow and see how I go.

yes G01 makes sense now..

In this code G04P500 What does the 4 mean? Or is it G04 together which means dwell, it looks like that.
__________________
My little site on MIG welding http://www.learn-how-to-weld.com/mig-welding/
Reply With Quote

  #4   Ban this user!
Old 11-10-2010, 08:20 AM
 
Join Date: May 2007
Location: US
Posts: 779
Andre' B is on a distinguished road

Here is a run down on G-Code, standards are not strictly adhered to so things do change from machine to machine.
G-code - Wikipedia, the free encyclopedia

One of the better books I have found on CNC programming.
CNCProgramming Handbook: Acomprehensive Guide to Practical Cnc Programming by Peter Smid - ISBN 9780831133474

And yes the dwell command is G04 or most machines will also take G4
Reply With Quote

  #5   Ban this user!
Old 11-10-2010, 08:21 AM
 
Join Date: Jul 2007
Location: Canada
Posts: 1,087
rowbare is on a distinguished road

Apples, whitespace within a block and leading zeros aren't significant in G-Code so G04P500 is the same as:

G04 P500
G4 P500
G4P500

I suggest you download http://www.machsupport.com/docs/Mach3Mill_1.84.pdf and read chapter 10. It gives a good introduction to g-code and will answer a lot of your questions.

bob
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 11-10-2010, 09:01 AM
 
Join Date: Jan 2005
Location: USA
Posts: 2,348
mactec54 is on a distinguished road
Buy me a Beer?

Apples

G04 is the code P500 is the time for the Dwell
__________________
Mactec54
Reply With Quote

  #7   Ban this user!
Old 11-12-2010, 05:45 AM
Apples's Avatar  
Join Date: Feb 2004
Location: Australia, Queensland
Posts: 416
Apples is on a distinguished road

Hey, I could get it to dwell. But then it just kept on dwelling, like chilling out and not moving at all.

Here is a similar code

o0001 (program name)
N10 G00 Y100
N20 G4 P500
N30 G00 Y0

Do I need to add a start/go code after the dwell command?
__________________
My little site on MIG welding http://www.learn-how-to-weld.com/mig-welding/
Reply With Quote

  #8   Ban this user!
Old 11-12-2010, 10:59 AM
 
Join Date: Jan 2005
Location: USA
Posts: 2,348
mactec54 is on a distinguished road
Buy me a Beer?

Apples

Try this G0Y0.

You need a ./ period after the zero
__________________
Mactec54
Reply With Quote

  #9   Ban this user!
Old 11-12-2010, 02:40 PM
 
Join Date: Sep 2010
Location: Australia
Posts: 733
angelw is on a distinguished road

Originally Posted by Apples View Post
Hey, I could get it to dwell. But then it just kept on dwelling, like chilling out and not moving at all.

Here is a similar code

o0001 (program name)
N10 G00 Y100
N20 G4 P500
N30 G00 Y0

Do I need to add a start/go code after the dwell command?
What controller is on the machine you're using?

Posted by mactec54

Try this G0Y0.
You need a ./ period after the zero

If its a Fanuc Control a period (decimal point) makes not difference for a zero value, Y0, Y0., Y0.0 are treated all the same by the Fanuc control. If a period is omitted in a coordinate value, the control will count 3 or 4 places to the left, depending on whether the control is in imperial or metric mode. In metric mode G21, Y100000 is read as Y100., similarly, Y100 is read as Y0.100

With a Fanuc control, G04 can be specified as Revs of the spindle by specifying G95 before the G04 dwell call, either on the same line of prior to the call. If your machine is in G95 (feed per revolution) mode and the spindle is not running, the program will stop at the dwell line waiting for the required number of rotations to be completed. You only show the move lines in your program snippet, so I don't know if you have the spindle running or not. If the spindle is not running, that may be the reason for the program dwelling for an indefinite period.

The fact that the move lines are in rapid traverse will allow those moves to occur irrespective of the control being in G95 (feed per revolution), or G94 (feed per minute) mode as rapid positioning does not rely on the spindle rotating. Put G94 in your program prior to the G04 command and that should fix the problem if the spindle is not running.

That's about the only thing that I can see in your program that would make it stop indefinitely once the G04 command has been launched.

Again depending on the control, an X value will work with a G04 and is my preference. G04 X0.5 will initiate a dwell of 0.5 seconds in G94 mode and 0.5 spindle revs in G95 mode. With a Fanuc control, there is a parameter that can be set that will cause the G04 to be treated as a dwell in seconds for both G94 and G95 mode.

Regards,

Bill
Reply With Quote

  #10   Ban this user!
Old 11-16-2010, 10:33 AM
BobWarfield's Avatar  
Join Date: May 2005
Location: USA
Posts: 2,395
BobWarfield is on a distinguished road

Yes indeed, welcome to the wonderful world of different controls which have slightly different g-code dialects.

Some controls want that trailing decimal point even if there is no fraction, so we have to write "X1.". Some don't care and we can write "X1".

RE your G4 (and there are controls that make you write G04) Dwell, the P500 may be interpreted as 500 milliseconds = 1/2 second on some controls or 500 seconds = over 8 minutes on others. That may be one reason why your Dwell just went on and on. As was pointed out, Dwell may also be expressed as revolutions (handy for some operations like making sure the bottom of the hole has seen a rev or two before you withdraw the twist drill).

So, your first task is to lay hands on the programming book for your controller. Otherwise all these little idiosyncracies will make no sense as each person gives you advice from the context of their controller.

You might find my G-Wizard G-Code Editor a helpful tool for learning:

GWizardE: A Machinist's CNC G-Code Editor

It lets you setup the g-code to match your controller's preferences. BTW, CAM programs call that a "post" informally. GWE has a "post" capability.

In addition it has "Wizards" to help you get the syntax right entering the g-codes and "Hints" that tell you what the g-code does in plain English.

Since it's in Beta test, it's free to play around with.

Cheers,

Bob Warfield
__________________
Try G-Wizard Machinist's Calculator for free:
http://www.cnccookbook.com/CCGWizard.html
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 11-16-2010, 07:01 PM
 
Join Date: Jan 2009
Location: US
Posts: 24
Jaxbubba is on a distinguished road
G code programming

For Fanuc style controls, always use a decimal point in your moves. Example
X5 means move .0005, X5. means move 5 inches. Big difference. Use your G0 to X, Y, rapid to where you want to do your work. You have to use height offset to rapid to where you want to start. Example G43H1Z.1 would use the value in height offset register 1 to move your Z axis to .10 above the top of your part. Use a G1 with a feedrate of say F5. for 5 inches per minute to feed to the depth required, since the G1 is modal, that means it is in a feed rate mode until you give it a different G0 code, you can just write the coordinates that you want to machine too. Example G1 Z-.25 F5.; X-1.Y1.;
Y-1.;X1.;Y1.;X-1.;X0.Y0.;G0Z1.;M30; If you were using a .50 mill, the above program would cut you a 1.5 square pocket .25 deep, go back to the center and rapid the Z up 1.0 from the top of your part. Hope this helps from an old timer.
Reply With Quote

  #12   Ban this user!
Old 11-16-2010, 09:22 PM
Torsten's Avatar  
Join Date: Nov 2004
Location: U.S.A.
Posts: 260
Torsten is on a distinguished road

Originally Posted by Apples View Post
Hey, I could get it to dwell. But then it just kept on dwelling, like chilling out and not moving at all.

Here is a similar code

o0001 (program name)
N10 G00 Y100
N20 G4 P500
N30 G00 Y0

Do I need to add a start/go code after the dwell command?
May need to make sure the Controller is in G90 absolute mode.
Else if a G91 incremental mode is active the N30 G00 Y0 line will not move anywhere.
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
Simple GCode Reference / Commands? WarrenW G-Code Programing 14 11-30-2010 03:03 AM
Need A Quote- Write knife grinding program tr4252 Employment Opportunity 17 03-10-2010 07:57 PM
How to write a code program to cut threads jjenks NCPlot G-Code editor / backplotter 7 04-21-2008 09:18 PM
Possible to write variables to a program? Heavy D G-Code Programing 2 08-21-2006 11:08 PM
someone wanna write a program? ljoe1969 DIY-CNC Router Table Machines 2 06-06-2004 07:47 PM




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