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 2030 / 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 slowstart 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!
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 2030 / 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 slowstart 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

3.6 KB Views: 0