Help with Arduino uno controlling stepper positions

Hi guys, I am very new in this art and need to learn from the experts. I am trying to control a gadget where the stepper motor is couple to a screw and the screw is driving the position of a head attached to a nut over the screw, similar to one axis on a printer. All I need is get from position zero to position A, from A to zero, from zero to B and from B to zero. I plan to use 3 temporary push on switches. I have found the code for the simple running of the stepper motor but not for 3 positions. Any suggestion where to find similar circuits and codes? I am using arduino uno, the DRV8825, and a nema 23 bipolar stepper.
Thanks in advance for all the help I can get!

Hello.

If you have not already seen our Arduino example code for our stepper motor driver carriers, you can find it on this blog post, which is about limiting the current on our stepper driver carriers. The comments in that code should help you understand how the code works in stepping a stepper motor using one of our stepper motor driver carriers (e.g. DRV8825).

To control your stepper motor movements using buttons (or switches), you would need to create different loops for each behavior (e.g. move from position A to zero or move from position B to zero). Then execute a behavior based on which button or switch is triggered.

You might find it helpful to look at this button tutorial on the Arduino’s website to see how you can trigger an event based on the state of a button. You probably would need to write your own code derived from those two code examples. If you try writing your own code and have issues, you can post your code here, and I would be happy to take a look.

- Amanda

Thanks for your help Amanda. Really and truly I am trying to skip the “Arduino programming” learning steps and get to the end without
starting and learning the basics. I will do my best to understand and practice with simple configurations and then used that learning
to build the final product. I will keep you in mind at times of trouble.

Last summer I built a small CNC controlled machine (ShapeOko2) for my prototypes. The software that is controlling the machine is GRBL which runs on an Arduino UNO. Download and open sketch from GitHub and load to your Arduino, nothing to be configured. Before building my machine I had that software running on my Baby-O as this has the same processor.

For sending instructions to the Arduino UNO I use Universal Gcode Sender, this also has a manual interface where you can order the machine to move a certain number of steps. You need to set the number of steps per inch in this interface.

The stepper output is connected to the Pololu DRV8825 which handles the power to your stepper motor. Follow the Pololu instructions carefully.

If you have only one axis to control you can make a couple of loops with delay_ms and a fixed number of steps in a specific direction. Something like:
if button A is pushed, then 10 steps forward
if button B is pushed, then 20 steps forward
if button C is pushed, then 30 steps backward

A post was split to a new topic: Machine triggering its own movement