Electronics > Projects, Designs, and Technical Stuff

Adaptive PID controller Microcontroller-based

(1/2) > >>

XaviPacheco:
I would like to build an adaptive PID controller for DC motor speed control. This controller should adjust the PWM duty cycle. The idea is that the program identifies the DC motor transfer function and adjust the PID parameters automatically for that motor. I've seen this using MATLAB, i.e, some data is recorded and given to MATLAB so it does all the job. But this time, let's say, I don't want to use MATLAB everytime I have to do PID tuning. I mean, let's say I have different DC motors, it means the transfer function changes, so PID parameter should change for that specific motor. Now, I have couple of doubts:

1- I'm measuring speed and current of the motor. Is this information enough?
2- The motor nameplate usually indicates the voltage, amps, and RPM. Can I extract useful information from it for the controller?
3- Is this achievable with a 32-bit ARM microcontroller?

Basically, I'm asking for help to write and understand the C algorithm, and implementation. I have been researching in Google about this, but I don't find much. if you have any document, book, or papers references which explain how to implement the C code, I will appreciate it.

IanB:
Your controller has a measured variable (the motor speed) and a manipulated variable (the PWM signal or motor voltage).

Your "process" has an input (the PWM value or voltage) and an "output" the motor speed.

What you need to do is to identify a model of your process (e.g. second order transfer function) by changing the process input in some way (maybe a step change) and recording the process response. Once you have this model of your process you can calculate by regression, or otherwise, an optimal set of PID parameters. Your PID tuning may depend on whether you need regulatory control (keeping the speed the same), or servo control (changing the speed on demand).

This is the most basic approach. Other more sophisticated approaches are possible, but they require more theory to understand.

There is not enough space in a forum post to explain how to do all of this in detail. There are quite a few things to learn along the way.

SiliconWizard:
Not sure why you'd need an adaptive PID. A simple PID should do the trick.

I have implemented rotation speed control through PWM on a DC motor years ago and didn't even implement a full PID. It was on an 8-bit PIC with very limited processing power. It was essentially just a PD controller (no integral term) and that worked fairly well with no need to extensively tweak the parameters. Rotation speed sensing was done with a slotted disc mounted on the axis of the reduction gearbox (4 slots, so 4 pulses per turn) and an optical sensor. It was additionally counting the number of turns and stopping exactly after a programmable number of turns (formed the basis of some kind of coil winder in which you could program the rotation speed, with a progressive start and stop to avoid wire breakage, and the number of turns). The 4 pulses per turn helped getting a more accurate speed rotation speed estimation (and a more accurate number of turns so I'd get better than a 1/2 turn error max.)

Using the measured current is not essential but could be an interesting plus as it would allow you to detect any failure or excessive mechanical resistance and maybe help getting a smoother movement if you use it wisely.

You may find some ideas in this: https://docplayer.net/48427382-Design-of-controllers-pd-pi-pid-for-speed-control-of-dc-motor-using-igbt-based-chopper.html

XaviPacheco:

--- Quote from: SiliconWizard on October 20, 2018, 11:04:38 pm ---Not sure why you'd need an adaptive PID. A simple PID should do the trick.

--- End quote ---

Well, this is the true:

For a college project, I'm designing a DC motor controller, and it works fine in hardware. I have some previous posts about it. I'm now dealing with the software where I have the control over the PWM. So far, the system is open-loop. With the speed readings, I'm going to close the loop and design a PID. What I plan to do is take some speed measurements, and process these values in MATLAB to get my motor transfer function and PID values. Then, I'm going to use these values to set the discrete PID in the microcontroller.

I plan to use different DC motors, so I think every motor has different characteristics. The board supports DC motors up to 4 HP. My professor told me that if the motor is replaced by another one, my microcontroller should be able to identify the new motor and calculate itself the system transfer function and PID parameters without having connection with MATLAB. I think he's demanding more than what I can do.

I can design a discrete PID controller, but I would need Kp, Ki, Kd previously calculated by another software. Normally, you find the motor transfer function and PID values using MATLAB.

 

IconicPCB:
Forget PID... include Feed forward and only then think of PID .

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod