Arduino Forum

Using Arduino => Motors, Mechanics, Power and CNC => Topic started by: ampedimagery on Sep 16, 2020, 09:14 pm

Title: Stepper Motor Speed and Direction with one Potentiometer
Post by: ampedimagery on Sep 16, 2020, 09:14 pm
Looking for the best way to control speed and direction of a stepper motor using 1 pot
Title: Re: Stepper Motor Speed and Direction with one Potentiometer
Post by: Robin2 on Sep 16, 2020, 09:34 pm
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 (http://forum.arduino.cc/index.php?topic=284828.0)
Simple Stepper Code (http://forum.arduino.cc/index.php?topic=277692.0)
Title: Re: Stepper Motor Speed and Direction with one Potentiometer
Post by: ampedimagery on Sep 16, 2020, 09:38 pm
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
Title: Re: Stepper Motor Speed and Direction with one Potentiometer
Post by: CrossRoads on Sep 16, 2020, 09:39 pm
potVal = potVal = 512; // range -512 to + 511

Typo perhaps?

Maybe this:
potVal = potVal - 512; // range -512 to + 511
Title: Re: Stepper Motor Speed and Direction with one Potentiometer
Post by: Robin2 on Sep 16, 2020, 10:40 pm
potVal = potVal = 512; // range -512 to + 511

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

...R
Title: Re: Stepper Motor Speed and Direction with one Potentiometer
Post by: Robin2 on Sep 16, 2020, 10:41 pm
I am very new to this and really dont know anything yet.
Have you carefully considered Reply #1 - does it meet your need?

...R
Title: Re: Stepper Motor Speed and Direction with one Potentiometer
Post by: jremington on Sep 17, 2020, 01:40 am
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.