Go Down

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

ampedimagery

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

Robin2

#1
Sep 16, 2020, 09:34 pmLast Edit: Sep 16, 2020, 10:39 pm by 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

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

#6
Sep 17, 2020, 01:40 amLast Edit: Sep 17, 2020, 01:41 am by jremington
Quote
This is my first arduino project.