Go Down

Topic: Stepper Motor Speed and Direction with one Potentiometer (Read 192 times) previous topic - next topic

ampedimagery

Looking for the best way to control speed and direction of a stepper motor using 1 pot

Robin2

Something like this ?

Code: [Select]
int potVal  = analogRead(potPin); // range 0-1023
potVal = potVal - 512; // range -512 to + 511
If (potVal < 0) {
  dirn = 'F';
}
else {
  dirn = 'R';
}
absPotVal = abs(potVal); // make sure it's positive
millisBetweenSteps = map(absPotVal, 0, 511, xx, mm) // xx = high value for slow speed, mm = low value for high speed


...R
Stepper Motor Basics
Simple Stepper Code
Two or three hours spent thinking and reading documentation solves most programming problems.

ampedimagery

I am very new to this and really dont know anything yet. This is my first arduino project. we are using a 12v nema 17 and eventually a 12v 12Nm Nema 34 to drive our machine. We are using 12v power supply, arduino, motor and l298n driver. i am wanting to change direction and speed in real time with a single pot

CrossRoads

potVal = potVal = 512; // range -512 to + 511

Typo perhaps?

Maybe this:
potVal = potVal - 512; // range -512 to + 511
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Robin2

potVal = potVal = 512; // range -512 to + 511

Typo perhaps?
Thanks for spotting that. I have corrected it.

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

Robin2

I am very new to this and really dont know anything yet.
Have you carefully considered Reply #1 - does it meet your need?

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

jremington

Quote
This is my first arduino project.
Start with something simpler, like getting your stepper to work.

You need an Arduino, an appropriate motor power supply, wire the driver to the motor without using a breadboard (because the breadboard connectors will burn) and importantly, set the motor driver current limit properly. You will need a multimeter for that.

Go Up