# Thread: function of the Z axis

1. ## function of the Z axis

Hi everybody, i'm new and i want to know this.
I'm programing a cnc software for my cnc machine, this software is capable to read a cnc file (g-code) and move my machine, but i'm a little confuse how z should move.
if i want to go to X100 Y250 Z50, Z is moving at the same time of the other axis or first go to X100 Y250 and then Z is going down to Z50.

The other case would be X100 Y250 Z0, first go X100 Y250, Z doesnt move, and then X100 Y250 Z50 go to Z50. the code complete wolud be:

X100 Y250 Z0 go ot 100,250
X100 Y250 Z50 already in 100,250 move Z50

My doubt is because sometimes i want to make a rect cut without moving the Z axis and sometimes, a circular cut moving the Z axis with the other axis.

Thanks for your help.

2. If you do not want to axis to move do not put it in that line of code.

X100Y25--this will move your X100 and Y250 at the same time
Z50--This will move to the 50 once the previous block is complete

Your example of the program
X100Y250Z0-- this moves X100,Y250,Z0
X0Y0Z50--now you will move X,Y back to 0 and Z 50 positive.

I am not 100% on what you are trying to do.

Stevo

3. Unless you're using incremental code, in which case

X0 Y0 Z50 would only move the Z axis.

4. Thanks Stevo1 for your answer.

I'm tring to finish a software that im writing for my machine, reading your answer i'd found a mistake, in my code

X100Y250Z0, the other part of code isnt X0 Y0 Z50, obviusly go to 0,0, the correct code is.

X100Y250Z0
X100Y250Z50

If you analize the code, the firs part go to 100,250 and Z doesnt move, already in this point, after the first move, the second instruction move Z go to 50 and ends.

What i exactly want to know is, if i write X100Y250Z50 my machine move the 3 axis at the same time, or first move X,Y and after Z "in the same instruction".

• It will move all 3 axis at the same time. What kind of machine control are you writting this for? I am mainly familiar with Fanuc controls and they would need to have the simultaneous 3 axis control option in the control. This is an option that allows you to move 3 axis at the same time.

To help shorten your code and not being so redundent you do not need the X,Y positioning in the second line. Once you have reached a distance in a axis it will not move again unless you program it to do so. So you can write
X100Y250Z0
Z50----------X,Y will stay put at X100, Y250.

This also works for your modal commands so if you were to do rapid positioning you only need the G0 in the first line and any move after that will be rapid. Once you program a G1 feed move for example it will stay active in each line until another G0 is programmed.

Stevo

• Ok Stevo.

If i understand right, if i want my machine move to a X,Y position an then Z position, for example to do a drill this could be the code:

N0001 X100Y250 first instruction
N0002 Z50 second instruccion (obviusly the G-code is missing, and the others).

But if i want to move the 3 axis at the same time, the code could be:
N0001 X100Y250Z50 (for a milling)

That's right?

• Yes that is correct. I do move all 3 axes no matter if I am drilling or milling. This just saves time. This is also a safer way because you should always have a Z move when positioning the X,Y either before the line or in the same line. This will prevent if the tool is down in the part somewhere not cleared of clamps ect. and the program is started it will move its X,Y and wipe out the part or clamps. So I always program a Z-clearance in my first X,Y move. So if you wanted to drill a 25mm deep hole using the code that you have in absolute mode.

G43H1Z100---instates tool height 1
G0G90---rapid positioning, absolute mode
X100Y250Z100M3---position over hole in X,Y with Z100 above the part, turn on spindle
Z3----Z to 3mm above the part
G1Z-25.F30M8—feed down 25mm turn on coolant set feed rate
G0Z100---rapid out of the hole 100mm above the part
M30---end program

I have attached a document that walks through some steps of setting up a program for a simple part. I have it using work coordinates G54.

Hope this helps.

Stevo

• Stevo thank you for your time and your tips have been so instructive.

• Your welcome. Feel free to ask questions if you need help.

Best of luck.
Stevo

### About CNCzone.com

We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

### Follow us on

Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.