# Script to reset x,y axis...



## MT Stringer (Aug 15, 2012)

I have been browsing the internet, but haven't found the answer to my question.

There are times I use the x,y axis in the center of the project. Other times, I use the bottom left corner for x,y=0

*How would I go about programming a script/file, whatever to reset the x,y axis to a predetermined spot on my spoil board?* I think this could be a really handy utility that would save a little time, at least for my work.

For example, say I decided x,y,zero would be x=1.5, y=1.5 inches. After completing a project that used the center, I would like to start the next project that has the bottom left corner (and any other project with this setting).

I use VCarvePro and Linuxcnc on the Probotix Asteroid.

Suggestions and advice appreciated.
Thanks


----------



## 4DThinker (Feb 16, 2014)

There are different G-Codes coordinate systems which might be the key to your quest. There is a machine coordinate system (G53) and G54 to G59 are work coordinate systems. 

You might be able to use two (or more) different post processors where the only difference is the coordinate system they set for the job. I'm pretty sure linuxCNC remembers where 0,0,0 is set for each once you've set them. Homing the CNC sets the machine coordinate system. They should end up the same each time the machine is homed. 

You can play around while in LinuxCNC by typing in G54 (or G55 through G59), setting the origin, then picking another and setting a new origin. Type in the previous G(coordinate number) and then G0x0y0 to see if the machine moves over to the appropriate location. 

Google: https://www.google.com/search?q=g-c.....69i57j0l2.8511j1j7&sourceid=chrome&ie=UTF-8

4D


----------



## MT Stringer (Aug 15, 2012)

Thanks. I will check some of those links to see what I can come up with.

Disclaimer: Not a programmer but willing to learn.


----------



## 4DThinker (Feb 16, 2014)

You don't need to be a good programmer, but just need to know how to edit a simple text file. Post processors are text files, and not too hard to understand when opened in notepad. 

I spent the last few minutes testing my own advice above. While the set origin button used on the left side of linuxCNC didn't seem to work to save x/y/z origins for different coordinate systems, the Set XY and Set Z origins on the right side did.


----------



## beltramidave (Jan 6, 2016)

Pretty much what 4D said... I think the easiest way would be to move to the location that you want to have X0Y0, then go into MDI tab and type in the offset #, ie: G55 (just G55) and hit enter. Then go to Manual Control Tab, and click on 'Set X/Y Origin' button on the right. Now your G55 work offset X0Y0 is set to that spot.
Now as 4D said, copy and modify a post processor for G55. Not much programming involved, you are just changing more than likely G54 to G55 (or whatever work offset you want). Then when you save your toolpath, just pick the post processor with the correct work offset. Sounds way more complicated than it really is..

Dave


----------



## BalloonEngineer (Mar 27, 2009)

Not familiar with LinuxCNC, but in Mach 3 or 4, you can set how far the machine backs off from the home switches. Set it to back off 1.5 inches on each axis. I’m sure there is a setting to do this in LinuxCNC as well. Then each day when you home, you will already be at your G54. Set your G55 for the center of the table, and any projects you set up using the center, you can line up with your table center.


----------



## MT Stringer (Aug 15, 2012)

*Got it!*



beltramidave said:


> Pretty much what 4D said... I think the easiest way would be to move to the location that you want to have X0Y0, then go into MDI tab and type in the offset #, ie: G55 (just G55) and hit enter. Then go to Manual Control Tab, and click on 'Set X/Y Origin' button on the right. Now your G55 work offset X0Y0 is set to that spot.
> Now as 4D said, copy and modify a post processor for G55. Not much programming involved, you are just changing more than likely G54 to G55 (or whatever work offset you want). Then when you save your toolpath, just pick the post processor with the correct work offset. Sounds way more complicated than it really is..
> 
> Dave


Thanks 4D and Dave. And a couple of YouTube videos. :grin:

It took some time and video watching to get a little better understanding of what you guys were saying, but I managed to use the MDI to set the G55 coordinates. The Set Origin Axis buttons for x & y on the left side of the screen worked just fine. After zeroing x&y, I was good to go. I switched back and forth between the two coordinate systems, and hit the return to xy origin and the machine responded perfectly.

Then I modified the post processor file. The one I use is EMC2-G64_Arcs (inch). I modified the file name to read 
POST_NAME = "EMC2 -G64 Arcs(inch)-G55(*.ngc)"

Then I added "G55" to the start line (or whatever it is called).

begin HEADER

"%"
"T[T] M6"
"G0 G17 G20 G90 G40 G49 G64 *G55* P0.001"
"G0 [ZH]"
"G0 [XH] [YH] M3 M8 "

I made a test file using the G55 post processor, loaded it into the CNC and used the mdi to switch to G55 coordinates.

I ran the file and it worked perfect!:grin:

Thanks again for all the help.

OK, I can go to bed now!


----------



## 4DThinker (Feb 16, 2014)

Glad to hear you got it working! The more I figure out about LinuxCNC the more I love using it. I rarely do a job more than once where these tips would be handy, but knowing about them can/might help me solve future challenges. G-Code is a pretty powerful programming language. 

4D


----------



## beltramidave (Jan 6, 2016)

Glad you got it figured out and working. Think you will find this very handy. I have several post processors set up with different work offsets and also G64 tolerences.


----------



## 4DThinker (Feb 16, 2014)

MT Stringer said:


> begin HEADER
> 
> "%"
> "T[T] M6"
> ...



You should move the G55 to before the G64 as the P-0.001 is a parameter used for the G64 command. : "G0 G17 G20 G90 G40 G49 G55 G64 P0.001"

Consider P to mean "precision". G64 

4D


----------



## MT Stringer (Aug 15, 2012)

4DThinker said:


> You should move the G55 to before the G64 as the P-0.001 is a parameter used for the G64 command. : "G0 G17 G20 G90 G40 G49 G55 G64 P0.001"
> 
> Consider P to mean "precision". G64
> 
> 4D


Will do.
Thanks.


----------



## MT Stringer (Aug 15, 2012)

Update. It's working!

Today I had a file with the reference in the center. My material already had a mark in the center so I carefully positioned the CNC over the center mark, then changed the machine coordinates to G55, and zeroed the x and y axis.

When I finished my file, I used the post processor for G55. And it all worked perfect. When I got through, I returned the machine coordinates to G54 and clicked the return to xy axis, and sure enough, it returned to the original xy zero I had set up in the bottom left corner of the machine. Yippeee!

I'm learning.
Thanks all for your input and suggestions.


----------

