Go Down

Topic: Full control of a stepper motor (Read 49 times) previous topic - next topic

rhjpires

Dear forum members,

My question is about code, more than hardware, but since it is related with motors I thought it would fit well here.

I am currently running a 1.0A 3.5V bipolar stepper motor with an Arduino Nano and DRV8825 driver. Using the minimal wiring installation where full steps are taken, I have also added a 10kOhm potentiometer to help regulate the speed of the motor. The implementation of the code was simple but worked for the demonstration of the principles of duty cycle, i.e. used used something of this sort:

   speedState = analogRead(potPin);
   speedState = map(speedState, 0, 1023, 25, 100);
   digitalWrite(stepPin, HIGH);
   delayMicroseconds(speedState);
   digitalWrite(stepPin, LOW);
   delayMicroseconds(100-speedState);

However, I know that currently I am not able to take full advantage of the performance of the motor and of Arduino and that there are ways to improve in order to have better control of the step size (M0, M1 and M2 in DRV8825 have to be HIGH) and on the side of the code something can be improved

I'm new to Arduino so please be gentle with me. I have seen code were people use the "stepper" library, others use "accelStepper", or maybe something else like "stepperDriver" I came across in Github.

So my confusion starts at:
#1 Understanding which library offers more features for control of stepper movement (direction, speed, rate of acceleration, step size, etc).
#2 How much are the features present in the library in any way associated with the drivers and motors used.
#3 How much should I have to program the PWM routine (got a bit scared when I read some articles on this) or will a library take the load of me?
#4 Exactly which aspects of motor specifications do I have to pay attention to in order to drive the motor in a dynamically smooth and accurate way.

Hope you guys are able to help.

Many thanks & have a good day!!

Robin2

The  AccelStepper library is a great deal more comprehensive than the standard Stepper library. Also the standard library is not designed for stepper drivers that take step and direction signals.

With that sort of driver it is also easy to write your own code without using a library.

These links may help
Stepper Motor Basics
Simple Stepper Code

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up