PID Speed Control

Hello All,

I am new to the site and would like some help with DC motor speed loop control.

A basic proportional control loop actually works. The problem I am having is that I need my main power supply to vairy, yet keep the motor speed constant. The project deals with a helicopter where I need to keep constant speed independent of the battery voltage slowy dropping off.

I have designed and used PID loops for DC gear motor position control, but I am having trouble using similar equations in this application that required speed control and not position control.


A little ground work:

I'm using an ATTINY861, 8bit controller. Optical tachometer. FET amplifier.

To measure speed I am using the Input Capture HW feature of Timer/Counter 0.

To output PWM, I am using Channel A of Timer/Counter 1.

All of the above HW and SW components work correctly.


The test code changes between two speeds. When I test the controller on a bench power supply, and vary the voltage, the controller tracks the two speeds, but they are higher and lower speeds based on the power supply and not the tachometer.


Also, in a speed control loop, is it required to add the desired set point speed to the calculated PID term when updating the PWM output?


Thank you for your help,



Yes. Your great comments are what actaully brought me to this site.

I must have something wrong in the control loop software. I will have to debug it further.



RPM per Volt
One possible thought, is that motors have a speed constant measured in “rpm per volt” that can be seen on the datasheet for the recent 1524E006S123 gearmotors posted here. That would indicate that a particular angular velocity would require a voltage level to the motor, with the PID calculation providing an adjustment around that voltage. If you were going to a point, in positional PID, no level is needed as nothing is required to maintain that spot other than the PID error formula, but maintaining a movement would seem to need the set level adjusted by adding PID based on the error from the setpoint.