Best way to control DC motor speed

Hi.

 

I'm new to this world and I'm trying to make a autonomous robot to chase around my cat. 

I bought a chinese electric car, a sharp sensor, 2 LDR and an arduino uno.

I was able to put everything together and the robot is running. I'm currently controling speed of the motor with a L293 and PWM output signal.

My problem is when I put the PWM outputing about 150, the motor runs slowly like I want but gives a high frequency pitch. If I go lower than that the motor just gives the pitch and doesn't move. If I go higher the motor runs fine. 

Does this kind of behaviour ruins the motor longevity? Should I always run it at full speed? What about if I hook up a digital potentiometer to control the speed, would I still get that pitch from the motor?

Thanks in advance.

normal

The high-pitch noise associated with PWN motors seems to be quite typical. When I experimented with it, I was told not to worry. A saviour/knowledgeable response is bound to be posted. But for the time being I wouldn’t worry too much.

Ok good to know.I’ve noticed

Ok good to know.

I’ve noticed if the PWM if too low the motor only starts if I give it a little push with my hand or if it was already running. Is there some way to give a “kick” to the motor to always start no matter what the speed is? 

Should I put a diode somewhere to protect my arduino? The motor is running with an external source through the L293 and he goes back and forth, left and right, a lot of times and I don’t want to fry anything. I already gave a delay time in the software when the traction motor goes reverse, but the left and right motor doesn’t have a delay.

Well each motor as a stall

Well each motor as a stall current value, and in laymen’s terms this means that a motor to start running has to achieve said value so that it does start to spin, in other words it’s kind of like the activation energy.

Regarding controling the motors I’m using this motor driver and can’t complain.
https://www.robotshop.com/letsmakerobots/node/32462

P.S. Always remember to have a common ground for  your circuits, I’ve busted a few pins on an Atmega on account of that.  

One way to kick your motor no matter what speed

insert an if statement ahead of your PWM call.

if (motorSpeed < 150) { // if the speed requested is less than 150
   analogWrite(motorEnable, 175); // set the speed at 175
   delay(100); // wait 100mS
}

analogWrite(motorEnable, motorSpeed); // now set the speed to the requested speed 

The numbers and variable names I have used are for example only. Use the names you have, and, find a your low and kick speeds through trial and error.

Also, the hum is due to the frequency of the PWM signal.

If you are using a L293D

If you are using a L293D then you don’t need to be worried. The L293D already has flyback diodes embedded.