![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| G-Code Programing Discuss G-code programing and problems here! |
| This forum is sponsored by: |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
| ||||
| ||||
Hi Guys During my research of G and M codes I found a handy technique for patterning tool paths. By using a combination of sub routines and the function G52, which is basically a way of defining a temporary work co-ordinate system, you can pattern a toolpath which has been written based around a co-ordinate system of 0,0,0. Once you have zeroed your work co-ordinates, G52 calls will reference from that 0,0,0 not your machine co-ordinates. Each G52 call you make 'fools' the controller into thinking that your work 0,0,0 is in a different place. If you want to pattern by +100mm in Y you would call G52 Y100. If you wanted to pattern by -200mm in X you would call G52 X-200. Once you understand the princliple of 'shifting' a co-ordinate system you can do any pattern you like based on a few simple toolpaths and subroutines. Cuts your line count down and troubleshooting becomes easier to manage since you are re-using the same code over and over. Once your patterning has been finished dont forget to call G52 X0Y0Z0 to make sure the work co-ordinate system is back to its original position otherwise you may end up with some unwanted tatttoes on your machine, fixture or workpiece. An example is as follows which works in Mach2, maybe Mach3, I haven't tried. This example will execute a toolpath at 0,0,0 then once it has finished that toolpath it will translate the co-ordinate system in Y by 100, execute the toolpath again and so on until it has executed the toolpath 5 times. The subprogram P1 is actually redundant but I left it in there to show that you can nest sub routines within G-code just like in other programming languages. In the example below where it says "put your program in here", you could just put a movement in X to prove the subroutine O2 was executed and that the subprograms and G52 offsets work as you expect. Once you get confident start cutting. Good luck! % M98 P1 (this calls the sub routine P1, designated by label O1) M30 (program end and rewind) O1 (this is the sub routine label number) M98 P2 (this calls the sub routine P2, designated by label O2) G52 Y100. (this shifts the co-ordinate system to think Y0 is at Y100) G0 Y0.Z10. (this sets the tool centre point 10 in Z above the point) (at which the program is to be executed, checking only) M98 P2 G52 Y200. G0 Y0.Z10. M98 P2 G52 Y300. G0 Y0.Z10. M98 P2 G52 Y400. G0 Y0.Z10. M98 P2 G52 X0Y0Z0 (this resets the co-ordinate system back to original Y0) G0 X0.Y0.Z10. (move to a safe Z above the original 0,0) M99 (return from subroutine P1) O2 (put your program in here remembering) (to bring Z to a safe height before translation in Y) (and that your program should be referenced to 0,0,0) M99 (return from subroutine P2) M05 (stop spindle rotation) % Cheers Derek keywords; pattern, copy, translate, subroutine, routine, offset, repeat
__________________ <insert witty comment here> derekj308 |
|
#3
| ||||
| ||||
| Hi Switcher I'm only new to this so I'm not fluent in G & M codes. I had a look at G91 which set the machine to incremental mode so I can see how you could move from one pattern position to another but I could only see that working for an operation that acts only in Z. I can't see how a subprogram toolpath could be run at each of the incremental points as the toolpath must reference a co-ordinate system. My understanding of G91 is that the work co-ordinate system does not change, only that the movements are incremental instead of absolute. Cheers Derek
__________________ <insert witty comment here> derekj308 |
|
#4
| ||||
| ||||
| You could do something like this (draws 4 offset squares):
. Last edited by Switcher; 01-17-2007 at 09:30 AM. |
|
#5
| |||
| |||
|
G91 does not give you the same thing as G52. Using G52 you reposition your work zero and then work using absolute within the new work zero. This means you can repeat the same shape easily at different locations. With G91 you have to program in incremental which is much more awkward than absolute in many cases. A search of the zone for references to G52 should pull up several threads where it has been discussed along with G92. |
| Sponsored Links |
|
#6
| ||||
| ||||
Does the example I posted look "awkward". The only possible way G91 is "awkward" is If a person doesn't understand how to use G91. ![]() Just trying to help derekj308. ![]() . . |
|
#8
| ||||
| ||||
| Hi Guys Switcher I did have a think about programming in incremental moves before reading post#4 and did see how (in my minds eye) it could be done. Thanks for the example now I have an alternate method if required. Geof I did do a search of "G52" on the 'zone and it returned no results so its why I posted in the first place. I wanted to share my findings with the 'zone community so others could use what I had found. Now the zone has a post which shows two methods for patterning. My work here is done (whooshing sound as I fly back to my sanctuary of solitude or maybe I'll just walk to the garage which is basically the same except for the flying bit ).Cheers Derek
__________________ <insert witty comment here> derekj308 Last edited by derekj308; 01-17-2007 at 09:08 PM. |
|
#10
| ||||
| ||||
| I've never used G52 yet, I've always programmed subs in incremental. This gets annoying to deal with though, if you have to translate Z moves, it can get quite confusing as to what level you are currently at with the tool. I have a hunch though, that creating subroutines with the assistance of cadcam would benefit greatly from using G52. This is because it is likely not possible to switch a post from absolute to incremental and back again, within one posting. So by using G52, you should avoid that necessity altogether, yet could still benefit from using subs. Anybody done this within CAM yet? Does it work as I've theorized?
__________________ First you get good, then you get fast. Then grouchiness sets in. (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management) |
| Sponsored Links |
|
#11
| |||
| |||
| Hu we have both posted in the past on G52 yes? Or is my ancient memory failing me? edit: 'annoying' Hu's synonym for 'awkward' |
|
#12
| ||||
| ||||
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |