Hello Guest it is September 17, 2021, 03:41:50 PM

### Author Topic: Locating question  (Read 6506 times)

0 Members and 1 Guest are viewing this topic.

#### rdean

• 94
##### Locating question
« 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

#### Dan13

• 1,208
##### Re: Locating question
« Reply #1 on: January 16, 2011, 09:56:24 AM »
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

#### HimyKabibble

• 1,687
##### Re: Locating question
« Reply #2 on: January 16, 2011, 10:28:30 AM »
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.
Regards,
Ray L.

#### Hood

• 25,838
• Carnoustie, Scotland
##### Re: Locating question
« Reply #3 on: January 16, 2011, 11:21:36 AM »
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

#### rdean

• 94
##### Re: Locating question
« Reply #4 on: January 16, 2011, 12:39:25 PM »
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

#### HimyKabibble

• 1,687
##### Re: Locating question
« Reply #5 on: January 16, 2011, 12:53:21 PM »
Regards,
Ray L.

#### rdean

• 94
##### Re: Locating question
« Reply #6 on: January 16, 2011, 06:40:06 PM »
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

#### HimyKabibble

• 1,687
##### Re: Locating question
« Reply #7 on: January 17, 2011, 12:30:28 AM »

Regards,
Ray L.
Regards,
Ray L.

#### rdean

• 94
##### Re: Locating question
« Reply #8 on: January 18, 2011, 07:37:10 AM »
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

#### Dan13

• 1,208
##### Re: Locating question
« Reply #9 on: January 18, 2011, 09:10:25 AM »
Hi Ray,

It is a display error in Mach. The actual movement will be correct though.

Dan