Hi everyone,
I was recently able to control the speed of my 24V geared electric motor, with a driver, an arduino UNO and a joystick controller.
However, when I do a quick deceleration of the motor from full speed to nothing (e.g duty cycle=250 -> duty cycle=0), I cannot understand why he does a little "jump"..
if(sensor <200) {
analogWrite (pin1, 0);
digitalWrite(pin2,LOW);
digitalWrite(pinEN,HIGH);
}
if(sensor >200 && sensor < 400) {
analogWrite(pin1,80);
digitalWrite(pin2,LOW);
digitalWrite(pinEN,HIGH);
}
if(sensor > 400 && sensor <600) {
analogWrite(pin1, 127);
digitalWrite(pin2,LOW);
digitalWrite(pinEN,HIGH);
}
if(sensor > 600 && sensor < 800) {
analogWrite(pin1,180);
digitalWrite(pin2,LOW);
digitalWrite(pinEN,HIGH);
}
if(sensor > 800) {
analogWrite(pin1,250);
digitalWrite(pin2,LOW);
digitalWrite(pinEN,HIGH);
}
This is the code I'm using just to change the speed of the motor.
My question is: if there's a way that I can obtain smoother speed changes using my arduino UNO to avoid those motor "jumps"? I hope I can do that with some algorithm.
Thanks in advanced!