• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Closed Loop Algorithm (PID) and Overload Duty Reversal

Status
Not open for further replies.

ACharnley

Member
Hi,

I have three buck/boost circuits which until recently were running a very simplistic +/- 1 duty increment based on a voltage feedback loop. Under normal circumstances they were working well.

A condition represented itself on the boost circuit whereby the available power wasn't sufficient enough to reach the nominal output. Under this condition the duty would continue to increase making the situation worse until the duty would hit the max buffer. Thinking about it logically, if a positive duty increment begins to have a negative outcome, and if a historical pattern of this exists, then reversing the duty would have a positive outcome and equilibrium would ensue.

This sounds like PID, so I did some research and based on other bits of code derived a calculator function which I've also modelled in Excel (it uses ints not floats).

When I replaced the simple duty implementation with this PID I hit current restrictions there to protect the circuit. Looking at the Excel data, when the switch mode starts there is a very big error delta which causes a very large duty cycle. Under light load the switch mode in question only needs 20-30 / 1023 duty (~ 2%) to sustain the output voltage.

Also, when the voltage higher than the norm the PID really doesn't back off fast enough.

My questions are;

1. is PID history able to cater for the condition I described in the second paragraph?

2. is my PID implementation correct? it doesn't look like it to me!

3. is PID suitable for slow-start or should the error delta be increased gradually on startup?

4. Anything else that can expand on my learning here, tips and tricks, pointers, anything you have!

Code:
uint16_t PID (int16_t currentError, int16_t *previousError, int16_t *integral, uint8_t pGain, uint8_t iGain, uint8_t dGain) {

// proportional
int24_t output = pGain * currentError;



// integral
output += iGain * *integral;



// differential
output += dGain * (currentError - *previousError);

// adjust for int gains
output = output / 100;

// add midpoint
output += 512;

// no negatives
if (output < 0) {
output = 0;
}

// limit to 10 bit
output &= 1023;

// saves
*integral += currentError;
*previousError = currentError;

return (uint16_t) output;
}
 

Attachments

gophert

Well-Known Member
Most Helpful Member
PID is pretty "dumb" if Your system is operating in a regime where the output cannot comply with the input request for "more power", "more turn", "more what ever".

Your system needs some type of fuzzy logic that says, essentially, if more power is demanded by the input sensors but the output does not yield a response of increasing more power, then decrease power until demand wanes.
 
Last edited:

crutschow

Well-Known Member
Most Helpful Member
PID is an analog, linear type of compensation, and depends upon the system having a linear response for proper operation.
It was designed a century ago when the only form of feedback control available was analog.
Although PID it now also run on a digital computer, the computer is just simulating the PID analog response.

In this case the response is non-linear, so I would also recommend some form of fizzy logic control, since it is designed to run on a digital computer, and can readily handle most non-linear system responses.
It basically uses a series of If-Then-Else statements to perform the logic.
Here's a good introduction to fuzzy logic, if you are not familiar with it.
 
Last edited:

summitville

Member
Max Duty Cycle ...
For some Boost Converters there is a Max Duty Cycle, which is much less than 99%, per the the selected components.
And if you exceed this Max Duty Cycle, the Voltage Gain will actually start DECREASING.
Have you tested your Boost Converter, with the low Input voltage to see if the Output Voltage keeps increasing with increasing Duty Cycle all the way, up to 1023?
You should never operate the Boost Converter above the Max Duty Cycle.
Many Boost Converters must operate below 90% Duty Cycle.
 
Last edited:

summitville

Member
PID ...
You need to "tune" your software PID for your Boost Converter.
How did you select optimum values for pGain, iGain and dGain?
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top