DC Motor Speed Control

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!

Yes.

Yes. Why use delay if its an undesired thing?

Unknown.

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.

...R

Idahowalker:
Yes.

Yes. Why use delay if its an undesired thing?

Unknown.
I am not using a delay. I was referring to the inherent time it takes the Uno to process the input data and output a response.

Simple, a faster processor would settle that concern, ESP32 240Mhz dual core, multi threading, multi processing.

So would I need to write all the code from scratch or is that reinventing the wheel?

You may have to.

You can try a Due. You may have a few pin changes. My code ports from a Mega were just drop, fix pin changes, and load with a Due.

Correction: I need to measure period of the tach pulse not frequency (period is quicker).

When I did a thing to generate PWM on one MCU and send the PWM off to another MCU for use.

I used PPM to convert the PWM to a frequency for transmission; Pulse Position Modulation

an internet search using some words like "arduino PWM PPM" should net you some results. Might be something you can use.

Max speed (RPM)? Pulses per Revolution?

v_mad:
So would I need to write all the code from scratch or is that reinventing the wheel?

This link has some code that should help you get started,

...R

Hi,
Welcome to t he forum.
Have you googled... arduino PID dc motor control with tacho

Thanks.. Tom.. :slight_smile:

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.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.