View Single Post
Old 12-04-2010, 08:07 AM   #4086 (permalink)
DJBecker
EcoModding Apprentice
 
Join Date: Nov 2010
Location: Annapolis
Posts: 159
Thanks: 0
Thanked 32 Times in 27 Posts
Quote:
Originally Posted by jackbauer View Post
Something i've wanted to do for sometime has been to add motor rpm feedback to the controller. Does the micro have sufficent resources left to do this in software? I'm playing with a little frequency detection circuit based on an lm2917.
The controller easily has the cycles to do this. The problem is what kind of sensor your motor installation will support.

I initially expected to use an interrupt or timer capture input. But a motor spinning at 6000RPM is only turning at 100 turns per second. Even if sampled at the Cougar's 976 Hz event loop, you can do a little digital filtering on two-edge-per-turn signal.

I'm sampling the PortD digital inputs at the 4KHz rate, just after starting the A/D conversion on the motor current sensor. The filter for these signals is a simple saturating up/down counter. If the input is '0', I count down and hold at zero. If the input is '1', I count up and hold at the high limit e.g. 7 or 15. The output is the half way crossing, which is just the high order bit if you use a power-of-2 counter.

I haven't come up with an elegant way to calculate instantaneous RPM. Instead I'm keeping the timestamp of the most recent 5 crossing events, and use the one I'm about to throw away (six samples away) to calculate RPM. This is simple enough but not great because a little noise creates twice the phase error as other techniques, and I'm not using the info in the other samples to correct for this ("non linear" or "maximal likelihood" filtering).

We'll be trying out several speed sensors in the coming weeks. Once we figure out which is easiest while still being reliable over all speeds and temperatures, I'll report back how much noise we see and how clever the code needs to be to filter it.

The speed sensors we are considering right now are white-black painted marks with a side-by-side IR LED/receiver pair, reflective tape with the same pair, a slotted disk interrupting an IR gap (using a sensor from a mechanical mouse), and a metal slotted disk interrupting a magnetic reed switch from a BMW differential.
  Reply With Quote