How to control the Motor?

Hi,

I’ve now met the problem of controlling motor rotating speed.
I thought that motor rotating speed should be controlled in the same manner as servos.
But I do not know how to set the length and frequency of the signal because when I use the suggested length and frequency for servos, it does not work for motor.
I can only hear beep sound from the motor but no rotation.
Does anyone know how this could be solved?

Thanks!

Peter

Peter, can you describe your setup? Do you use an ESC?

ECS require that you first send impulses of certain length (1ms) so that it won’t start rotating immediately. This is a safety feature. All this time it will be beeping.

Hi,

Yes, I connected an ESC to the servo rail.
By starting a shorter pulse length, it works now.
But one thing I do not understand.
In fact, I created my own C++ class to drive it based on your sample code.
But each time when I first run my own code after reboot, I need to run your sample Servo code once so that I can hear the motor sound to be ready.
Only after that, my own code can work.
If I reboot again, I need to rerun your Servo sample code again.
I am curious where the problem is? In fact I am doing exactly as what the Servo example does.

Thanks for your answer!

Peter

Peter, the PWM generator has an output enable pin (it is disabled by default), take a look at these lines:

I got what the problem is.
My code was based on an earlier download from GitHub which has something related to pin initialization missing, and now the files there are complete, and I can drive the servo and motor now.

Thanks again!

Peter