I am trying to control a stepper motor using a potentiometer. When the potentiometer is at 0 the motor should run in reverse at full speed, in the middle, the stepper motor should stop, which it does fine and at maximum, the motor runs at full speed. The problem I am having is when the stepper motor stops it consumes a large amount of current and the controller would overheat even with the huge heatsink I have on it. I am using the standard stepper library and I am looking for a way just to make the motor stop without consuming current and holding the rotor in place.
My controller is an L298N
#include <Stepper.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
int stepCount = 0; // number of steps the motor has taken
void setup() {
// nothing to do inside the setup
}
void loop() {
// read the sensor value:
int sensorReading = analogRead(A0);
// map it to a range from 0 to 100:
int motorSpeed = map(sensorReading, 0, 1023, 140, 250);
// set the motor speed:
if (motorSpeed > 195)
{
myStepper.setSpeed(motorSpeed);
// step 1/100 of a revolution:
myStepper.step(stepsPerRevolution / 100);
}
if (motorSpeed < 195)
{
myStepper.setSpeed(motorSpeed);
// step 1/100 of a revolution:
myStepper.step(-stepsPerRevolution / 100);
}
}
Wawa:
Which is not suitable for stepper motors.
Leo..
Hi RB358,
What Leo is saying here right. Your Controller is for a DC MOTOR not a STEPPER MOTOR. (Sorry if im wrong Leo) they are totally different systems and not compatible.
(Quick edit add on: Upon further searching i find there are stepper motor units with that number (chip number) sorry for jumping the gun!
The L298 not being the right choice for a stepper motor has been discussed many times in the "Motors, Mechanics, and Power" part of this forum. Not going into that again here.
The poor choice for a low voltage, high current brushed DC motor also has been mentioned here many times.
This ancient lossy BJT-transistor based driver is really only suitable for high voltage/low current motors (12 or 24volt and <= 1Amp). The only reason it's popular is because it's cheap. There are much better mosfet-based H-bridges out there.
Leo..
Daz1712:
(Quick edit add on: Upon further searching i find there are stepper motor units with that number (chip number) sorry for jumping the gun!
That it works/can be made to work doesn't necessarily make it a good solution. OP complaining about an overheating heat sink is a clear indication of that being the case here.