CNC-ish application

I need to control a stepper to move the Z axis on a machine to a specific height. The movement part is pretty easy with all of the examples available, the part I'm not finding is how to set a zero and have the ability to specify a Z height to move to. I can do this easily using something like Mach3, but I really want to do it with Arduino instead. Any ideas or places to look for this to happen? I'm brand-new at Arduino and really want to learn as much as I can, not looking for someone to do it for me but I"m happy modifying existing code to make it work for me. Thanks for any help! Gary

If you can do it with Mach3 I'm guessing that there is a limit switch to identify the HOME or ZERO position.

Whenever you need to identify the ZERO position all your Arduino code needs to do is move the motor one step at a time towards the limit switch. Think of the kids in the back of the car shouting "Are we there yet?"

...R Stepper Motor Basics Simple Stepper Code

Thanks for the reply and the links to your other posts, that’s exactly the help I was looking for! I’ll start experimenting and see if I can make this happen.

Gary

You need to consider how accurate your "Z" position needs to be. Just moving until a microswitch is closed is pretty rough positioning. Much more accurate is to then move the opposite way, one step at a time until the microswitch opens back up.

Paul

It needs to be extremely accurate. I'll use a hall effect switch like I have on my cnc mini-mill, it is so accurate that I don't have the equipment to measure how far off it is... In Mach3, there is a homing routine that moves rapidly until you trigger the switch then it reverses a short distance then moves very slowly back to trigger the switch again. From the sample code I've seen so far I don't think it will be a problem to do this.

laserimage: It needs to be extremely accurate. I'll use a hall effect switch like I have on my cnc mini-mill, it is so accurate that I don't have the equipment to measure how far off it is... In Mach3, there is a homing routine that moves rapidly until you trigger the switch then it reverses a short distance then moves very slowly back to trigger the switch again. From the sample code I've seen so far I don't think it will be a problem to do this.

Our selective solder machine runs Mach3 and it does exactly that sequence on 3 axes.

Paul

Mach makes it pretty easy. I have a Gecko G540 driving 3 Keling steppers and have HE switches on both ends of each axis. Zeroing and end stop are as accurate as can be with Mach. I could go the easy(easier) route and just use Mach for this application but I really wanted to get my feet wet with Arduino...

laserimage: In Mach3, there is a homing routine that moves rapidly until you trigger the switch then it reverses a short distance then moves very slowly back to trigger the switch again.

The only purpose of that is to reach the HOME position quickly. If you are content to get there slowly it can all be done on the first movement.

...R

If you have to deal with more than one axis, you could also go with GRBL, which is a kind of firmware loaded to your Arduino and then you can send G-Code via PC to your Arduino. The Arduino (GRBL) converts the G-Code via a motor driver in stepper movements - just like Mach3.

GRBL also supports limit switches.

The G-Code can be sent by some special G-Code sender software, e.g.: - Universal G-Code sender - BCNC - GRBL Controller - Chilipeppr

I have built a Z axis as a starting phase of a long term CNC project. This axis, as well as the future X & Y axes, incorporates a SDPT momentary contact limit switch positioned at each end of the axis travel. At the mid point of travel there is an opto-interrupter. On the moving table of the axis is a vane of approximately one inch in length that passes through the opto-interrupter.

The test sketch I am working on is being based on the logic that initially the axis' moving table's position is unknown. First i want to check whether or not the opto-interrupter is blocked. If blocked, move slowly in any direction until it becomes unblocked. Reverse direction and slowly move, while counting steps, until the opto-interrupter again becomes unblocked. Reverse direction again and move to counted steps/2. This is the mid point of the vane and 'home' position.

If the opto-interrupter is initially not blocked, move at a moderate speed in either direction until a limit switch is encountered. Reverse direction and move at a moderate speed until the opto-interrupter becomes blocked. Now move slowly until the opto-interrupter becomes unblocked. Reverse direction and slowly move, while counting steps, until the opto-interrupter again becomes unblocked. Reverse direction again and move to counted steps/2. This is the mid point of the vane and 'home' position.

  • Scotty