Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: ryder2012 on May 04, 2026, 11:52:42 AM

Title: mach3 pneumatic z axis setup
Post by: ryder2012 on May 04, 2026, 11:52:42 AM
hey everyone,

ive been building a CNC machine purely for drilling so accuracy doesnt need to be 1/100th of a milimeter perfect.

for reasons ive been instructed to move forward with using a pneumatic cylinder to control the Z axis.

im planning on having 2 physical stops and a 24v 2 possition solenoid to control this. im just in need of help in setting up mach3 to be able to control this. i know it will need a signal pin assigning to the solenoid but im concerned about timing. i dont want mach 3 to start moving the X or Y while the cylinder still has the spindle below the top of the working surface.

any and all advice will be greatly appreciated.
Title: Re: mach3 pneumatic z axis setup
Post by: marktuan on May 04, 2026, 07:07:39 PM
Hey,

Simplest way is to add a small delay after activating the solenoid. In Mach3 you can use a G04 (dwell) so it waits before moving X/Y.

Example:

M7 (turn on solenoid)
G04 P0.5 (wait half a second)

Better option (more reliable) is to add a switch/sensor at the top so Mach3 knows the Z is fully up before moving.

If it’s a simple drilling setup, the delay usually works fine.

Title: Re: mach3 pneumatic z axis setup
Post by: ryder2012 on May 04, 2026, 11:03:27 PM
ok thats cool, the dwell can be written into the gcode software too as a standard implementation.

is there any configuration to tell mach3 that its not using a stepper motor for z anymore?
Title: Re: mach3 pneumatic z axis setup
Post by: ryder2012 on May 05, 2026, 01:01:43 PM
wait, the dwell would only work at the bottom of the plunge, the concern is the return.

im going to go about installing an upper and lower sensor but how would i configure mach3 to read these sensors and know that one is activated when the axis is at its lowest, trigger the vertically upward movement then read the upper sensor and know its then safe to move the X and Y?
Title: Re: mach3 pneumatic z axis setup
Post by: ZASto on May 05, 2026, 11:37:51 PM
Or, you can use DIR signal for Z axis to control your cylinder.

eg.

G0 X100 Y100 // gantry moves to coordinate for drilling
G1 Z-10 // your cylinder gets energized and your drill goes down
G0 Z0 // your cylinder gets deenergized and your drill goes up
G4 P1.0 // wait a certain amount of time for the drill to clear the material surface

proceed to next hole
...

You can easily implement it in your postprocessor of your CAM software, or whatever you use to generate G-code

No switches, no aditional M codes, no extra configuration in Mach3