DEV Community

Stack All Flow
Stack All Flow

Posted on • Originally published at stackallflow.com on

controlling motor with PWM?

I am using a RCS-Model-M2313 R/C Servo and I have managed to create a PWM. My problem is that my motor doesn’t react as I was expecting. I would like to control the motor angle with the duty cycle but it doesn’t work.

Indeed, with a 28% duty cycle, a 550 Hz frequency, 1.7V offset, a 3.3V signal from my MCU I can control it to come back to the same position. I have powered the servo with a 3.7 tension.

When I change the duty cycle, the motor turn but doesn’t stop anymore.

The datasheet doesn’t give any information, I really need your advices.

Thank you.

Regards,

Mattew

Accepted Answer:

Your frequency is way too high, or conversely, you are not waiting long enough between pulses. You should be sending a 1 to 2 ms pulse every 20 to 50 ms. Note that this means 50 Hz maximum.

Also, your “1.7 V offset” makes no sense. These pulses should generally be 0 to 5 V digital signals. I followed the link you provided, but that only goes to a product sell page not a datasheet, so we can’t tell exactly what voltage levels the digital signal must be. When in doubt with hobby servo units, use 5 V logic.

Try a 1 ms pulse every 20 ms. That should send the arm to one end. Then try 2 ms every 20 ms. That should send the arm to the other end. Try it with the 3.3 V signal straight out of your processor and see if that works. If it doesn’t, make it a 0-5 V signal instead. That really should work if everything else is hooked up right. If you don’t have a level translator chip, you can rig up something with a NPN transistor and pullup resistor. That will invert, but just invert the processor output to compensate. A HCT (note the T) logic gate powered at 5 V can also be used as a 3.3 V to 5 V converter.

Are you sure the processor power is properly filtered so that the current spikes the motor draws doesn’t effect it? A schematic and scope traces with a clear description of what happens in each case would help a lot.

Electronic #controlling #motor #PWM

The post controlling motor with PWM? appeared first on Stack All Flow.

Top comments (0)