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 07-07-2011, 03:09 PM
 
Join Date: Jul 2011
Location: USA
Posts: 3
gcodehelp is on a distinguished road
Exclamation Simple G code loop needed!

Hello everyone! I am an undergraduate student who just got into a research laboratory with a professor. My task is to program our laser (which functions with G code) to make fairly simple designs, but a lot of them. I need to find a way to run a simple loop where I can designate the start point (probably absolute coordinates), allow it to run maybe 20-30 times, making a simple design (in a horizontal x direction) and then return to the start position, only an increased y amount upwards, so I may begin another row. I think I have the other parts down, I just need a way to run the loop a specified number of times without having to program the same code 100000 times and I am not very familiar with G code.

Thank you all very much!
Reply With Quote

  #2   Ban this user!
Old 07-07-2011, 03:24 PM
 
Join Date: Jul 2011
Location: USA
Posts: 3
gcodehelp is on a distinguished road

https://docs.google.com/viewer?a=v&p...Z3RMN&hl=en_US

This is the manual for controlling the stage. I am afraid there might be limiting factor because of what G codes it allows. Please let me know. Thank you very much.
Reply With Quote

  #3  
Old 07-07-2011, 03:28 PM
Al_The_Man's Avatar
Community Moderator
 
Join Date: Dec 2003
Location: Canada
Posts: 16,539
Al_The_Man is on a distinguished road
Buy me a Beer?

You need something called Nesting S/W, this takes a single part/shape and nests it efficiently on a certain material sheet size, it will also rotate parts in order to reduce waste.
Al.
__________________
CNC, Mechatronics Integration and Machine Design.
“Logic will get you from A to B. Imagination will take you everywhere.”
Albert E.
Reply With Quote

  #4   Ban this user!
Old 07-07-2011, 07:50 PM
 
Join Date: Sep 2010
Location: Australia
Posts: 733
angelw is on a distinguished road

Originally Posted by gcodehelp View Post
Hello everyone! I am an undergraduate student who just got into a research laboratory with a professor. My task is to program our laser (which functions with G code) to make fairly simple designs, but a lot of them. I need to find a way to run a simple loop where I can designate the start point (probably absolute coordinates), allow it to run maybe 20-30 times, making a simple design (in a horizontal x direction) and then return to the start position, only an increased y amount upwards, so I may begin another row. I think I have the other parts down, I just need a way to run the loop a specified number of times without having to program the same code 100000 times and I am not very familiar with G code.

Thank you all very much!
The example uses the code for a Fanuc control, but most controls have Sub Program, and repeat of Sub Program functionality.

1. Write the code for your simple design in Incremental
2. Main program has the call of the ROW logic
Go to the Absolute position of the starts of the first component offset in X and Y by the X and Y pitch of the individual parts

Lets say that the pitch of the start of each part in X and Y is 50mm and 100mm respectively, and that the start point of the first part is X0.0 Y0.0, then:
G90 G00 X-50.0 Y-100.0 (G90 is Absolute Mode G code)
M98 P1000 L10
where:
M98 is the Sub program call command
P1000 is the Sub program number
L is the number of ROW repeats of your design

Sub program 1000 logic follows
O1000
G90 X-50.0 (Absolute start position of the first column of each row, minus the pitch of the columns)
G91 G00 Y100.0 (incremental pitch of rows)
M98 P2000 L50
M99
where:
M98 is the Sub program call command
P2000 is the Sub program number
L is the number of COLUMN repeats of your design

Sub program 2000 logic follows
O2000
G91 G00 X50.0 (incremental pitch of columns)
code for design goes here, all written in incremental moves.
........
........
........
........
........
........
M99

3. The program works by the head of the machine starting at a position offset by the pitch of the part in X and Y in the main program.
4. A Sub Program is called from the main program to repeat a number of times equal to the number of rows to be cut.
5. Program control is transferred to the Sub called in the main program (O1000) and repeats it L times (number of Rows)
6. The first line of Sub O1000 will make no move when control is first transferred from the main program because the head has already been positioned there in the main program.
7. The second line will move incrementally in Y the pitch of the Rows and will now be in the correct Y start position for the design.
8. The NESTED program O2000 is called and repeated L times (number of columns of parts). Control stays with O2000 until it has completed L number of repeats.
9. The first line of O2000 moves incrementally in X the pitch of Columns and will be in the correct X start position of the design.
10. O2000 will repeat the process of moving X pitch of the design and then running the shape of the design L number of times.
11. Control then returns to O1000, where the head of the machine is returned to the Absolute X start position for the next Row and calls O2000 again. This process repeats until O1000 has repeated its L number of times.
12. After O1000 has repeated L number of times, control is passed back to the main program.

The above logic works if the Start and End point of each design component is the same Absolute point. You will have to manipulate the Absolute coordinates and the Row/Column pitch moves if the the Start and End point of each design component is not the same Absolute point; but the general logic will work.

The above is not as difficult as it may appear in written form. It results in the code for the shape of the design only being written once and its start position being changed and controlled by two Sub programs.

There are other ways of achieving what you want by using User Macro techniques, or using work coordinate shifts. However, not knowing the type of control you have, the above method will work on just about any control.

You will have to look in your programming manual of your machine's control to get the correct syntax for Subs and nesting Subs.

Regards,

Bill

Last edited by angelw; 07-09-2011 at 07:53 AM.
Reply With Quote

  #5   Ban this user!
Old 07-10-2011, 09:02 PM
 
Join Date: Jul 2011
Location: USA
Posts: 3
gcodehelp is on a distinguished road
Exclamation Another Question-thanks so far

Thank you very much for the replies, I've researched the nesting/G98/99 and I think I understand it. Unfortunately we are having a more fundamental problem with controlling the stage. I am going to call the programmer tomorrow but I thought I'd ask on here first because it might be a simple problem solvable by someone with a little experience.

So we are trying to operate in relative coordinates (G91) while also using linear motion (G01) instead of (G00). For some reason, even if I include the G91 code, once I also include G01, the entire code changes to absolute coordinates, even if everything is help constant and this is the only change in the entire code. Its my understanding that you can program G01 and G91 at the same time. If I do not include G01 then it will move in G00 mode with relative coordinates but the diagonal motions will come out in a hockey stick looking manner. Please advise if you have any advice. I am afraid there is something wrong with the program.
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 07-12-2011, 02:36 PM
 
Join Date: Jun 2008
Location: United States
Posts: 1,507
stevo1 is on a distinguished road

You should be able to program them in the same line but you could try programming the G91 before your G1 line. These codes should stay modal until you change them.

Stevo
Reply With Quote

  #7  
Old 07-12-2011, 02:55 PM
Al_The_Man's Avatar
Community Moderator
 
Join Date: Dec 2003
Location: Canada
Posts: 16,539
Al_The_Man is on a distinguished road
Buy me a Beer?

Originally Posted by gcodehelp View Post
If I do not include G01 then it will move in G00 mode with relative coordinates but the diagonal motions will come out in a hockey stick looking manner. Please advise if you have any advice. I am afraid there is something wrong with the program.
G01 is interpolated motion under feedrate command, G00 is a non-interpolated move in rapid motion.
Al.
__________________
CNC, Mechatronics Integration and Machine Design.
“Logic will get you from A to B. Imagination will take you everywhere.”
Albert E.
Reply With Quote

  #8   Ban this user!
Old 08-13-2011, 01:45 PM
 
Join Date: Aug 2011
Location: Sweden
Posts: 8
RogerHq is on a distinguished road
Absolute and relative coordinates...

Ok, your last post is as mentioned in conflict with Standard ISO G-codes

G90 and G91 is NOT related to G00, G01

If G01 takes your machine out of relative coordinate mode then there is a break of standard.
Only G90 is intended to switch the controller to absolute coordinate mode.
G01 is as mentioned used in linear work mode and G00 is NOT used for anything else than rapid movements WITH NO machining of any sort taking place.
That i I believe, the standard.
OF course anyone can create an G-code interpreter who treats the G-codes differently and they do...
If that is true in your case only You can tell us.
Check it up again!

/ Roger
Reply With Quote

Reply

Tags
g code




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 (hopefully simple)G code Help inventor30 General CNC (Mill and Lathe) Control Software (NC) 2 11-12-2010 05:32 AM
Is it possible to loop a g-code program? sul1 G-Code Programing 4 04-03-2009 02:49 PM
Need help with simple G code Step by Step Coding 2 10-24-2008 08:49 PM
Need Help!- Simple loop program for mazak katsbobo Mazak, Mitsubishi, Mazatrol 3 04-07-2008 06:11 PM
simple start up code needed jrick CNCzone Club House 0 02-08-2007 12:05 AM




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