Question on the feasibility of this project

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015
I have designed a DC motor controller board for a treadmill application using PWM. Actually it's for a college project. So far, the hardware works okay in open loop. I mean, I can control the duty cycle with the microcontroller. The motor responds really fast to step changes, which is not so desirable in this app. The basic commands given to the treadmill are Start, Stop, Speed up and Speed down. However, I don't have a special controller for this, I need one. The idea is to have a controller which increases/decreases the speed smoothly and mantain the speed under load conditions. I'm also measuring RPM. My first question is: does a PI/PD/PID controller is critical for this?

It turns out that I have been asked to add a new feature to my project: My board should be able to identify the motor and tune the PID values that fit better for that specific motor. If a new motor is connected, I should have an option which allows me to identify the new motor and adjust the controller. In other words, an adaptive control. I have been researching about it, but all of the information I find is related to Matlab. So, I started to wonder myself if this feature is actually achievable using a microcontroller. I have a 32 bit controller from ARM.

As I'm able to measure RPM, the only thing that comes to my mind now is to see the speed step response. But I don't know what to do after that. What are your advices?


Joined Jun 19, 2012
Sure you can, it's just... complex.
A 32 bit machine should have the guts to do the job.

First write a PID controller and really learn how it works, and how to tune it.
It's actually not hard to write- it's cheating if you use a library, you won't learn much that way.
The key is thinking of the variables as signals, not just numbers, consider what happens with things saturate and overflow. Read up on MAC
Remember: The code is emulating an analog process.

Then tackle the auto tuning idea.


Joined Mar 10, 2018
One approach (uses low end ARM Cortex M0) - (a couple of short videos here)

You can also consider Cortex M3 parts, lot more capability besides just motor
control, like display, DMA, Digital Filter, more extensive analog, ......PSOC 5LP.
Actually a new member of the low end family now has DMA.

There is quite a lot of info on web for approaches to PID tuning as well, from start
to advanced topics. Attached some ref material.

Regards, Dana.


Last edited: