Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: rdean on January 16, 2011, 08:16:08 AM
-
I hope I am posting this in the correct section of the forum.
I have a question about moving around the work piece and running different G codes.
I will try to explain but I may be trying to do something that is not practical.
Example:
G code #1 starts at 0,0 and cuts a rectangle that is 2"X4"
I have a work piece that is 12" square in the machine and the starting point is located at the center of the piece with the DROs at 0,0
I run code #1 at this location and when finished I want to move to another location and run this code again. In other words I want to cut many rectangles out out this piece with out loosing my original location of 0,0 and not having to change the G code.
Thank you
Ray
-
Hi Ray,
The best option is using the G52 offset. Suppose you cut the first one at X0 Y0. Then you want another one at X-3 Y0 and next one at X3 Y0. This is how the program will look like:
(your code to cut rectangle here)
G0 X-3 Y0
G52 X-3 (this will offset the current point by -3 making it X0. Y remains the same)
(your code to cut rectangle here)
G52 X0 (set the offset back to zero)
G0 X3 Y0
G52 X3
(your code to cut rectangle here)
G52 X0
M30
In the same way you can offset in the Y as well.
Dan
-
And, if you put the code to cut the rectangle in a subroutine, you don't need to repeat the code, just call the subroutine after applying each offset.
Regards,
Ray L.
-
There is also a wizard (called nesting if I recall) for doing this, i have not used it since Mach2 days but never heard of it not working but test with caution in case ;)
Hood
-
Thank you for the replies.
I think the sub routine may be the way I want to go as I will be cutting different sizes and shapes.
Where can I find information on this subject?
I read though the Mach 3 manual and watched most of the videos but didn't find anything.
Any direction will be appreciated.
Ray
-
Your answer is only a Google away.... http://lmgtfy.com/?q=G-code+subroutine
-
I went to the different web sites and I did learn how to add a subroutine and number it at the end of the program. I understand how to call it and how to loop it.
My subroutine is a file on my computer.
I learned that in order to call the sub from the main program it must be located in "C:\Mach3\Subroutines\" and then the file name.
I learned that in the main program when you use M98 the file name must have brackets around it.
The sub must end in M99.
Please correct me if I am wrong on any of the above.
What i want to do is to move to a X and Y location and then run the subroutine or my file. Now my file has a starting point of X0 and Y0 and all the cuts in the sub are referenced from this starting point and finish at the starting point. When the sub is finished and passed back to the main program the DROs should read the X and Y locations that were there before the subroutine was run.
Am I trying to do the impossible?
Thanks to all
Ray
-
Dan has answered your question. Where his example has "(your code to cut rectangle here", simply call your subroutine.
Regards,
Ray L.
-
I have taken your advise and started back at the beginning with the code from Dan. This is what I am working with.
G1 X1
G1 Y1
G1 X0
G1 Y0
G0 X-3 Y0
G52 X-3 (this will offset the current point by -3 making it X0. Y remains the same)
G1 X1
G1 Y1
G1 X0
G1 Y0
G52 X0 (set the offset back to zero)
G0 X3 Y0
When I load this code the display window shows two squares on the X axis three inches apart which is what I would expect to see.
When I run the program the crosshairs start at the left lower point of the right square and procedes to cut around until it gets back to 0,0. The propgram then sends the crosshairs to X-3 which is the starting place for the left square. Instead of showing the cut around the left square the crosshairs jump to the right square and retraces the path there. When it is done there the crosshsairs jump to 0,0 of the left square and them moves to X3. Why is it not showing the cut around the left square even though I beleive if I had the motors hooked up it would actually be cutting the left square?
If I step through the program the display will show show all the cuts on both squares but not when I run the program. Do I have something set wrong in the setup or display configuration screens?
I beleive this has been my problem all along as I have relied on the display screen to show me what I would be making. Even after I had checked my code many times the display would not show what i thought thould be there.
Thank you for any help
Ray
-
Hi Ray,
It is a display error in Mach. The actual movement will be correct though.
Dan
-
:o
I am working on the Demo version if I purchase Mach3 will the screen work then?
How do you know if your code is correct if you can not trust what is displayed?
I do want everyone to know that I do appreciate the help given to me on this subject.
Thank you
Ray
-
Ray,
The display error is not specific to the demo version.
You can use the Z Inhibit option on the Program Run screen and specify a value below which the Z will not go. Use a value just above the material and you can visualize your tool moves. Also when I am running a program the first time and not sure about it I usually decrease the FRO to a very low value so I have enough time to hit FeedHold if things go wrong.
Dan
-
I have continued to work on this and found that I had some offsets programed into the fixture and a couple of other problems. I still am not real happy with the display but now I can see what is happening and it makes sense.
I do still have a problem that maybe you or someone can help me with.
This is the code for making two rectangles along the X axis with radius at the corners.
f100
G0 Y1
G52 Y1
G1 X1.5
G3 X2 Y.5 I1.5 J.5
G1 Y1.5
G3 X1.5 Y2 I1.5 J1.5
G1 X-1.5
G3 X-2 Y1.5 I-1.5 J1.5
G1 Y.5
G3 X-1.5 Y0 I-1.5 J.5
G1 X0
G52 X0 Y0
G0 Y0
G0 X4.5
G0 Y1
G52 X4.5 Y1
G1 X1.5
G3 X2 Y.5 I1.5 J.5
G1 Y1.5
G3 X1.5 Y2 I1.5 J1.5
G1 X-1.5
G3 X-2 Y1.5 I-1.5 J1.5
G1 Y.5
G3 X-1.5 Y0 I-1.5 J.5
G1 X0
G52 X0 Y0
G0 Y0
G0 X0
This works fine with no problems but if I try to make the same rectangles only along the Y axis it won't work. I get an error message says the end of the arc doesn't match.
Please look at this and see where I went wrong.
f100
G0 Y1
G52 Y1
G1 X1.5
G3 X2 Y.5 I1.5 J.5
G1 Y1.5
G3 X1.5 Y2 I1.5 J1.5
G1 X-1.5
G3 X-2 Y1.5 I-1.5 J1.5
G1 Y.5
G3 X-1.5 Y0 I-1.5 J.5
G1 X0
G52 X0 Y0
G0 Y5
G52 Y5
G1 X1.5
G3 X2 Y.5 I1.5 J.5
G1 Y1.5
G3 X1.5 Y2 I1.5 J1.5
G1 X-1.5
G3 X-2 Y1.5 I-1.5 J1.5
G1 Y.5
G3 X-1.5 Y0 I-1.5 J.5
G1 X0
G52 X0 Y0
G0 Y0
Thank you to all
Ray
-
Are you using absolute I, J? Why do you use the first G52 Y1?
Try using this code for your rectangle:
(Assuming Incremental I J)
G00 X0 Y0
G01 X1.50 Y0
G03 X2.0 Y.5 I0 J.5
G01 X2.0 Y1.5
G03 X1.5 Y2.0 I-.5 J0
G01 X-1.5 Y2.0
G03 X-2.0 Y1.5 I0 J-.5
G01 X-2.0 Y.5
G03 X-1.5 Y0 I.5 J0
G01 X0 Y0
Dan
-
Yes I am using absolute I,J
Does it have be in incremental?
I wanted to move off the starting point for the first offset and then run the rectangle code. When I get this figured out the rectangle code will be one of many in the subroutine file. I will only have to write the code for the rectangle once and then be able to use it anywhere I want.
I will try using incremental and see how it works.
Ray
-
It works!! After 5 days and countless hours trying different codes it finally works.
Should I be doing all my programing in incremental?
Got to go back and read some more.
Ray
-
Not to state the obvious, but, since you appear to be a newbe to G-code I will point out that you have no Z-axis commands in your program. Therefore, what you have programmed (so far) will do no actual cutting or, it will drag the cutter all over the place possibly breaking it.
You'll probably be adding an equivalent amount of code to manage the Z-axs.
Sage
-
You are right.
I am very new to G code and the mill I was using did not have an automated Z axis. You would move to where you you wanted to be and manually lowered the cutter and ran the program. It did not use any G Code but I wrote a program to access the serial port directly. It worked fine and I have made many replacement dash panels and radio surrounds on it. You could not run the program unattended and the table was limited.
I am refitting a used larger mill to automate the whole process so I thought I should automate the programming also by learning G Code. Sending pulses to each motor makes for a lot of lines of code. I am not a machinist and even after reading through the documentation several times I am still learning how to setup the configuration and settings.
I now have my start up set for Absolute Distance and Incremental I,J.
Thanks for the reply
Ray
-
Ok.
Manual Z is fine but then you're going to need something like an M1 (optional stop) to stop the code while you adjust the Z axis manually before and after each rectangle.
As it is the code is going to move around a particular rectangle and then immediately go to the next one without giving you a chance to get the tool out of the work. And then it will start the next one without giving you a chance to put it back down.
You have a bit more thinking to do.
Sage