I want to use an UNO to control a PM DC motor speed accurately using digital *negative feedback.
There will be 6 different preset speeds input by a rotary switch so can be 3 digital inputs.
I obviously dont need a readout of the speed.
So my plan is to feed the tacho pulses to a digital input and use (library) code to measure the frequency, compare it with the preset, then subtract them. The resulting number will be an "error signal" which is then converted to PWM to drive the motor via a transistor switch.
*The negative feedback loop will probably use a PID control algorithm to give optimum stability (I know how to do this bit).
So my questions:
Can all this be done with an UNO?
Is it realistic in terms of response time or will the loop delay be too slow?
Can I use standard libraries eg F Counter?
If it seems feasible I would love to give it a go!
An Uno will be well able to do what you want. I had a program that used PID to control the speed of a small DC motor over a wide range of speeds up to 16,000 RPM. The program could also receive wireless messages with the desired motor speed and direction.
Interesting project. I also agree this should be no problem for an UNO. If you're getting 1 pulse per revolution for the tach signal, then you're good for up to 60,000 rpm with the FreqMeasure library.
*The negative feedback loop will probably use a PID control algorithm to give optimum stability (I know how to do this bit).
I've done some mods to a fork of the Arduino PID Library (QuickPID) you might find interesting. You could probably just scale the tach reading to 0-1023 range and use it directly as the PID Input signal. The complete PID cycle (read-compute-write PWM outout) takes just less than the time for just one regular analogRead (96µs). It has a built-in AutoTune command that can automatically determine and set the PID parameters, but I've only tested it with an RC filter circuit.