Programmable stepper motor

Hi! Had no problem wiring up a nema 17 with Arduino uno to control speed and direction of the motor.

*Apologies if this question has been answered!

Now I'm hoping to make it programmable. Idea is to have two pairs of buttons (4 buttons total). Button a1 inputs the current position of the stepper motor into the Arduino's memory, button a2 returns the stepper to that position. Button b1 would input a second position, b2 would turn the motor to that position.

Goal is to make a follow focus for my camera with the ability to rack focus based on programmable positions. As a bonus it would be great to be able to have different settings for speed and easing. As an additional bonus any tips about gearing down the motor for smoother motion would be appreciated!

Seb

sebazistan:
Now I'm hoping to make it programmable.

What have you tried? Please post the program that represents your best attempt and tell us in detail what it actually does and what you want it to do that is different. It will make it much easier to focus on the parts you need help with rather than wasting time on things that you can do.

As a bonus it would be great to be able to have different settings for speed and easing.

When you say "easing" do you mean acceleration? Have you looked at the AccelStepper library.

I think the user interface would be too confusing if you try to do too much with 4 buttons.

As an additional bonus any tips about gearing down the motor for smoother motion would be appreciated!

Are you already using micro-stepping?

...R
Stepper Motor Basics
Simple Stepper Code

Thanks for the reply!

  1. Mostly looking for tips on how to a. measure the position of the stepper and b. store that value in the Arduino's memory so it can be retrieved later. Haven't attempted this yet... I'm a novice and not sure where to start.

I imagine the code might look a little like (sorry this isn't proper formatting)

//Declare global variables
variable stepperRotation= 0;
variable valueA= 0;
variable valueB= 0;

//Functions

Function gotoValue(value){
//Turn the stepper motor to variable "value"//
}

//Call functions

//Get the numerical value for the stepper motor position continually//
everySecond(){
stepperRotation= actual rotation;
}
On buttonA1 press(){
valueA= stepperRotation;
}
On buttonB1 press(){
valueB= stepperRotation;
}
On buttonA2 press(){
gotoValue(valueA);
}
On buttonB2 press(){
gotoValue(valueB);
}

OnButtonReset press(){
valueA= 0;
valueB= 0;
}

  1. Will check out AccelStepper for stuff like acceleration/ deceleration for smoother motion.

  2. Not too sure about microstepping. Will look into it.

sebazistan:

  1. Mostly looking for tips on how to a. measure the position of the stepper and b. store that value in the Arduino's memory so it can be retrieved later.

It's not clear from your description how you intend to get the motor to the position that is to be recorded.

One way to do that is to move the motor one step at a time while a button is pressed and keep count of the number of steps. When the desired position is reached release the motion button and press another button to tell the Arduino to save the current count value.

...R