Experimenting back-emf motion feedback

It’s been weeks since I’ve tried to build a DC motor controller board. Particularly, this board must include a way to control and monitor the motor speed. This is an important step since it’ll be used as a dead-reckoning system on my future robot.

There are several ways to do this. Using code wheels (or encoder discs) with photoelectric or Hall effect detectors seems to be the easiest way, in a software point of view, but requires mechanical adaptations to include the code wheels. This would affect the design of the bot, and would be too invasive to include in a “hacked toy” (such as a tank rc, this is what I plan to do, the mechanical parts on the tank cannot be modified, and shouldn’t be). Anyway…

Another way to do this is measuring the back-emf feedback. This is well described here. Basically, voltage coming from the motor, while it’s turned off (not powered), must be measured using ADC. The value is proportional to the speed of the motor. Compared to the voltage applied, it’s possible to know if the motor is turning as expected or not (too fast, or more plausible, too slow). And possibly to adjust the applied voltage to correct the speed.

I found this nice page on back-emf using control feedback, with the same parts I use (16F88, L293D). This is what I’m currently trying to implement. Master Patrick also helped me a lof, with advices, suggestions and patience…

After several tries, first results are quite interresting. Here’s a series of screenshots from an experiment. There’s one DC motor. Its speed is increased at each step, using PWM. One step consists in activating the motor for 2 seconds, then shutdown the motor for 1 second. When PWM is turned off, an ADC measure is acquired and sent through serial link. This gives…

Lot’s of noise (more on this later), but we can clearly see how the motor is accelerating, step by step. As expected, while the PWM increase step is constant, acceleration is not linear.

Also note, during  the very steps, PWM is not high enough to make the motor rotates. There’s a voltage applied to it, but none generated…

  Zooming on a step show interesting things… First, each step looks the same:

  • an acceleration phase (not linear). PWM is turned on
  • a constant phase. The end of the phase is when PWM is turned off.
  • and a deceleration phase, quite linear. No more voltage is applied to the motor, but it produces voltage while “slowly” spinning down…
As said, there’s a lot of noise. Precisely, while measuring voltage produced by the motor, measures vary a lot. The motor produces a lots of electrical noise. Looking at the graphs clearly shows a main trend. Master Fenyo suggests to compute a sliding average in order to extract this trend. This is can be easily computed with:

An = k.An-1 + (1-k).an

where:

  • n is the current step,
  • An is the current average being computed
  • An-1 is the average at previous step
  • an is the new measure for current step
  • k is a coefficient used to balance the average with the new measure. 0 < k < 1

During this last experiment, I voluntarily slow down the motor several times. The green line is the sliding average, using k = 0.98 (the new measure has only 2% weight in the average). More readable, heh ?

Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>