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 12-22-2008, 01:53 AM
 
Join Date: Sep 2008
Location: Hungary
Posts: 15
s_volenszki is on a distinguished road
How to build cycle in g-code

Dear All!

I am new to g-code programming but not blind I this matter, because I know uncountable languages to make programs (c,php,tp etc.).

My question is that, has anybody a good free documentation about making g-code functions (subrutins, labels, do...while or for...next)?

I don't know the way in g-code to make a cycle, and increase a variable between each cycle-s for a predefined value.

For example, if I want to cut 10mm plastic in 20 cycle, and I want to decrease the Z axe -0.05mm between each cycle (something pseudo like I want):

?????????????
[label: SHAPE]
Here is the g-code for the shape, included the variable (ZPOS) for Z pos
[end label]

ZPOS = 0
FOR X=1 TO X=20
ZPOS = ZPOS -0.05
SHAPE
NEXT X
?????????????

Take a look on this, thanks,
Alex
Reply With Quote

  #2   Ban this user!
Old 12-22-2008, 03:53 AM
 
Join Date: May 2005
Location: New Zealand
Age: 57
Posts: 404
paulC is on a distinguished road

Start by getting manuals.
Art has a Hungarian version of his manual that you may find useful.
http://www.machsupport.com/documentation.php

Have a look at G10 and G52
Just be careful as not all interpreters handle all commands.
Paul
Reply With Quote

  #3   Ban this user!
Old 12-22-2008, 04:22 AM
 
Join Date: Feb 2007
Location: Sweden
Posts: 8
nanopile is on a distinguished road

Here is a crude example of the specifications of G-code:
http://www.cmcsystems.com/techtips_gcodes.html

But i wouldnt suggest making G-code by hand because it quickly grow in size and the room for erros is nonexisting because you easily can destroy your machine if there is a sigle error in the file.
I make my G-code in RhinoCAM from 3D models of stuff i have made in SolidWorks or Ironcad.
The G-code files is usually between 15 KB and 80 MB.
I would for sure not want to risk my equipment by making it by hand.
I rather make a program that write it if i didnt have any suitable software.
Reply With Quote

  #4   Ban this user!
Old 12-22-2008, 06:55 AM
 
Join Date: Mar 2008
Location: usa
Posts: 1
ol geezer is on a distinguished road
Macros

(Macros)

If you know the old BASIC computer language, you can make your own G-code subroutine using variables. You will need your controller’s programming manual to see what variables and commands are available. If then, dowhile, goto, GT, LT, local variables, system variables the list goes on and on and on.

You will need to prove the sub on the machine; yes you can hurt a machine if the code is wrong. Something’s never change such as “garbage in garbage out”.

But, on the other side of things a well written, thought out macro for a family of parts or functions on a machine, can save untold amounts of time in programming, and machine operations. Macros can also help the operators interface with the machine, helping them be a better machinist.

There are many advantages to macro programming, and macros can have disadvantages. It all depends and what you want to do, and the tools you have available to program with.

If you have a big family of parts, where changes could happen across the board in the family a well wrote macro can smoke any cam system. But that macro depending on the family could take over a month to create and prove out.

One of the reasons a macro COULD be faster is:
On a family of parts; engineering changes a radius on all parts. You have 500 parts in the family, which means 500 programs to look at. Or change one macro.

A good source of info is Mike Lynch at CNC concepts he has a web site. Search for it.
Reply With Quote

  #5   Ban this user!
Old 12-22-2008, 07:33 AM
 
Join Date: Oct 2006
Location: USA
Posts: 16
nstaley is on a distinguished road

Originally Posted by s_volenszki View Post
Dear All!

I am new to g-code programming but not blind I this matter, because I know uncountable languages to make programs (c,php,tp etc.).

My question is that, has anybody a good free documentation about making g-code functions (subrutins, labels, do...while or for...next)?

I don't know the way in g-code to make a cycle, and increase a variable between each cycle-s for a predefined value.

For example, if I want to cut 10mm plastic in 20 cycle, and I want to decrease the Z axe -0.05mm between each cycle (something pseudo like I want):

?????????????
[label: SHAPE]
Here is the g-code for the shape, included the variable (ZPOS) for Z pos
[end label]

ZPOS = 0
FOR X=1 TO X=20
ZPOS = ZPOS -0.05
SHAPE
NEXT X
?????????????

Take a look on this, thanks,
Alex
You're Kidding Right?
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 12-22-2008, 11:36 AM
 
Join Date: May 2007
Location: USA
Posts: 8
Phyrexii is on a distinguished road

Ol geezer has it right - your machine tool programming manual should have information in it regarding macro programming, if your machine tool supports it. It will also tell you which specific variables control the different functions of the machine.

Many older machine tools don't support macro programming, or the option wasn't turned on. Once upon a time, I ran two machines with FANUC 18i controllers, one accepted macro programs, and the other one didn't. However, most newer controllers / machines will allow you to program them.

Macro programming is fairly simplistic compared to the more robust languages (C, php, etc), but is very similar to BASIC, as was mentioned earlier. I am no expert at macro programming, but the way I would write up your little example is:

(SHAPE)
(HERE IS THE G-CODE FOR THE SHAPE)
(VARIABLE #501 IS THE DEPTH PER PASS)
(VARIABLE #502 IS THE MAXIMUM DEPTH)
(VARIABLE #503 IS THE START DEPTH)

#501=.02
#502=-1.
#503=0
WHILE [#503 GT #502] DO1
#503=#503-#501
IF [#503 LE #502] GOTO20
N10 G01 Z[#501] F10.
GOTO30
N20 #503=#502
GOTO10
N30 G01 X... Y... (SHAPE SECTION)
END1

In this program, it will step down .020 at a time (#501) and run the defined shape, until it gets to the predefined depth (#502). It is important to end the shape by bringing the machine back to where you started before you end the loop (END1). You can nest other loops in, and I'm pretty sure you can call subprograms as well (M98).

There is A LOT of things you can do with macros, especially when combined with subprograms, and it is a powerful programming tool. Unfortunately, most of the machinists and operators I know don't even know these things exist, let alone be able to understand them or edit them. When I write programs for the shop utilizing macros, my guys get angry and frustrated with me, so I usually reserve them for when I'm going to run the job myself (very rarely). I feel it would be better if they took a little time to learn this stuff, but for some reason, they just don't want to put forth the effort. Too bad :-(.
Reply With Quote

  #7   Ban this user!
Old 12-22-2008, 01:21 PM
 
Join Date: Jun 2008
Location: United States
Posts: 1,507
stevo1 is on a distinguished road

Originally Posted by nstaley View Post
You're Kidding Right?
kidding about what???

s_volenszki,
There is a few different ways that you can set this up to keep picking away at a part. I will just do something like moving across the top of a part starting at 0 and moving 5” in the X. It will keep going deeper on each pass based on the variables you set up.

#1=0(Z-START)
#2=1.(FINAL DEPTH)
#3=.05(PICK SIZE)
G0X0Y0Z#1
WHILE[#1LT#2]DO1
#1=#1+#3
IF[#1GE#2]THEN#1=#2
G0Z-#1
G1X5.F50
G0Z.1
X0
END1
M30

This can also be done by using IF and GOTO statements.

Good luck,
Stevo
Reply With Quote

  #8   Ban this user!
Old 12-22-2008, 01:32 PM
 
Join Date: Jun 2008
Location: United States
Posts: 1,507
stevo1 is on a distinguished road

Phyrexii,
Sorry I didn't see you post. I started typing earlier and then got pulled away and didn't bother to refresh.

I have a lot of guys that dont' like the macros. I also have quite a few that do. My last place was 100% macros on our lathes and machining centers. The way that I have been getting through to some of the guys here is to prove out a macro for bolt circle drillng as an example then lock it in the higher program numbers. I gave them a list that says A=# of holes, B=angle to start, C=final depth ect. They didn't like it at first because they didn't understand the macro. I explained to them they did not need to understand the macro. They only needed to know what A,B,C was. Once they knew it wont' mess up they started taking the time to watch the code and learn.

We never locked are macros at my last place because everyone knew them in and out. I still lock them here but they are picking them up pretty quick. I actually get yelled at by them when they dont' have a macro for a part .

Stevo
Reply With Quote

  #9   Ban this user!
Old 12-22-2008, 01:35 PM
 
Join Date: Sep 2008
Location: Hungary
Posts: 15
s_volenszki is on a distinguished road

Thank you, I download and study it!

Alex
Reply With Quote

  #10   Ban this user!
Old 12-22-2008, 01:52 PM
 
Join Date: Sep 2008
Location: Hungary
Posts: 15
s_volenszki is on a distinguished road

This is exactly what I was looking for! I thought that this will be complicated, but this isn't!

I have program to make g-code form vector files or cad solids, but I want to understand what to do and why!

Thanks for every comment, I start to discover the making of g-code macros!

Alex
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 12-22-2008, 09:43 PM
 
Join Date: Sep 2008
Location: INDIA
Posts: 12
PRADEEP R.KHARE is on a distinguished road
g coading

DEAR ALEX
WHY ARE YOU WORRIED G CODE?
WE HAVE A SOFTWARE MADE BY CADEM(BANGLORE) IN INDIA WHICH MAKES YOUR PROGRAM ON WINDOWS XP COMPUTER & YOU CAN DOWNLOAD THE PROGRAM TO MACHINE THROUGH RS232 PORT OR BY USB PORT OR WIRELSS.
WITH THIS SOFTWARE YOU CAN RUN SIMULATION ON YOUR PC.
IF INTERESTED PL.EMAIL ON THE FOLLOWING ADDRESS
THANKING YOU
WITH BEST REGARDS
PRADEEP R. KHARE
prkhare@hotmail.com


Originally Posted by s_volenszki View Post
Dear All!

I am new to g-code programming but not blind I this matter, because I know uncountable languages to make programs (c,php,tp etc.).

My question is that, has anybody a good free documentation about making g-code functions (subrutins, labels, do...while or for...next)?

I don't know the way in g-code to make a cycle, and increase a variable between each cycle-s for a predefined value.

For example, if I want to cut 10mm plastic in 20 cycle, and I want to decrease the Z axe -0.05mm between each cycle (something pseudo like I want):

?????????????
[label: SHAPE]
Here is the g-code for the shape, included the variable (ZPOS) for Z pos
[end label]

ZPOS = 0
FOR X=1 TO X=20
ZPOS = ZPOS -0.05
SHAPE
NEXT X
?????????????

Take a look on this, thanks,
Alex
Reply With Quote

  #12   Ban this user!
Old 12-23-2008, 01:27 AM
 
Join Date: Sep 2008
Location: Hungary
Posts: 15
s_volenszki is on a distinguished road
To know the details of g-code first.

Dear Pradee!

As I wrote I am new in g-code and also new in cnc machining. A few days ago I have finished my first hobbc CNC mill and now I want to know the main g-code rules.

Based on the posts, what I have got, I wrote a little text file phrasing and replacing routin in php, and now I load a plt file generated from CorelDraw, I input the tool diamaeter, the cutting depth, the cutting speed, and any other compenzation values, and It is outputs the necessary g-code. Now it is, what I wanted, anyway if I will start to do cnc machining for business, I will contact you or any other software maker.

Till than I take a look on http://www.cadem.com!

Thank you for your attention,

Alex.
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
Newbie - To build or not to build Router/Plasma Table dfranks CNC Plasma and Waterjet Machines 10 04-07-2011 11:16 PM
New Large Table Build in Houston, TX (Build Log) anitel Plasma, EDM and other similar machine Project Log 12 12-30-2008 02:45 AM
M Code in Canned Cycle Question banausicjosh Fanuc 2 08-27-2008 03:03 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 12:09 AM.





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