Position controlled Stepper Motor

Hi, I believe that my questions have been asked somewhere but I really appreciate if you can help me out again. I have a Stepper motor 42HS4013A4 Sumptor motor, an arduino uno, and an A4988 chopper driver. I was trying to control the position of the stepper using the potentiometer, but I found that the potentiometer was quite sensitive to the potentiometer value. Do you have any recommendation as to how to control the position of the stepper motor?

Thanks

Two switches. One for FWD, one for REV. When you press a switch the stepper will advance in that direction, when you let go it will stop where it is.

Thank you for your information. I am using the stepper to control a linear actuator to conduct an experiment. For this reason, I need to tell how much the steppers should turn in advance and ensure that the steps meet the desired position of the linear actuator. I have been thinking about potentiometer and/or other positioning encoders, but I have no clue where to begin with.

You have not told us what level of positioning accuracy you need and over what range.

The most accurate input will be with a rotary encoder, but the programming is more complex.

If you just want (say) up to 12 preset positions you could use a rotary switch with some resistors and detect the position with analogRead(). The switches are cheap and the programming is easy.

...R

Robin2: You have not told us what level of positioning accuracy you need and over what range.

The most accurate input will be with a rotary encoder, but the programming is more complex.

If you just want (say) up to 12 preset positions you could use a rotary switch with some resistors and detect the position with analogRead(). The switches are cheap and the programming is easy.

Thank you for you response, the range for the linear actuator is 2 foot and accuracy within 0.1 inch. I need to tell my testing object to go a certain distance on x,y,z axis (on an 3 axes linear actuator). Can you give me a typical positioning sensor (with example) that can help me with my experiment?

Thanks

Hey,

i did something like that with a servo myself. i try to keep it simple here, to see if this is going your direction, feel free to ask if you need more detailed infos on this matter.

#1 the motor: first step was to take the motor and program it with the values directly to move to its start and end position. that done i knew i could make the motor move.

#2 the rotary encoder: next step was to take a rotary encoder and read its output values in the serial monitor. this is explained in the basic arduino lessons. (i did this in a complete new setup/project, just to get this working and understanding without interference of the first step)

#3 value conversion:
take the rotary encoder values and convert them to the needed motor values:

“rotary encoder value” diveded through “needed motor value” = “conversion factor”

with that factor you can now convert the rotary encoder values in the values you need to give to the motor his needed values:

“rotary encoder value” diveded through “conversion factor” = “needed motor value”

example: in my case the rotary encoder value was ranging from “0” to “1023” which had to be converted to a motor value range of “0” to “180”, so my factor was 1023:180=5.683333333333333

#4 put it all togehter:
put together the motor control and the reading of the rotary encoder and all comes togehter:
“servo.write(sensorvalue/5.683333333333333);”

everytime i turn the rotary encoder now, the value will be given to the motor as its diveded state:
full left end rotary position = 0/5.683333333333333 = 0 for servo.write
middle rotary position = 512/5.683333333333333 = ~90 for servo.write
full right end rotary position = 1023/5.683333333333333 = 180 for servo.write

… which gave my servo a perfect left, middle, right position of its servo arm.

that basic principle can be refined in a lot of ways, for example cutting out only a limited range of the way the rotary encoder can be turned.

int eingang= A0;
int sensorwert = 0;

#include <Servo.h>  
Servo servoblau;

void setup()
{
Serial.begin(9600);
servoblau.attach(8);
}

void loop()
{
sensorwert =analogRead(eingang);
Serial.println(sensorwert);
servoblau.write(sensorwert/5.683333333333333);
}

TOM-d: Hey Robin,

Wrong addressee

...R

I have looked at couple of proximity sensors. I realized that Sharp proximity sensor is not very precise. For the proximity sensor with the range from 10-80cm, if my choice of distance is about 50cm, the error could be more than 3 cm. Do you have better options in term of precision and budget less than $30 with the range from ~20-~80cm?

Thanks

What are you measuring? Are you measuring the position of an unknown object or are you just trying to get the linear actuators to extend to a known position?

Actuators with analog feedback (a linear potentiometer) are readily available. Usually it's only a few dollars more than the 'bare' actuator. With an Arduino you can turn this analog input into 0-1023 steps. This should meet the accuracy requirement of 0.1" over 24". If you already have the actuators then buying 24" potentiometers may be difficult.

XYZ sounds more like what a 3D printer does. That gets accuracies down to 0.1mm or better. (1/245") This is usually done with slide bearings and toothed belt drives on cheap stepper motors. The only feedback is 3 'home' switches and then the printer counts steps from there.

…but I found that the potentiometer was quite sensitive to the potentiometer value…

…here just some wild brainstorming ideas:

#better hardware: … invest in a better potentiometer? cheap ones are <1€, one for 5€ should already be a whole different league.

#mechanical: … hmmm, you could connect a turning knob to your potentiometer with gears, so that you have to turn the knob numerous times to make the poti turn only once. that would make it much more controllable.

#keypad: … or build a little keypad with 5 buttons. totally different approach, but very precise:

(+1) (+10) (+100) … for precision, mm or steps or °, combined with a selection status led

(left) (right) … for direction

that approach will also add up nicely with a little display showing status & selections

Hi, Have you got a picture of your linear actuator project? All the proposed methods of obtaining distance are valid, but for reliability and accuracy, I'd go for a self contained actuator with built in distance feedback , either a pot or even better an encoder.

Tom.... :)

Thank you very much for so many feedbacks. I am basically need to move the actuators to a predetermined position. Ex, I will set the x,y,z coordinate of the target position and will program it to arduino to make the actuators move to that target position. I personally think the Potentiometer leans toward a manual approach than an automatic approach for the linear actuator.

Thank you for any feedback