I am using an 18F4520 in a PI control loop and am having problems with the integrator code that I suspect may have been more elegantly dealt with by others. I'd love to see examples or suggestions from those with more experience.
Currently I am able to generate the error signal and was previously using an external analog integrator. To move the integration into the PIC I have to overcome several things - mainly that the integrator doesn't just sum, it subtracts when the new value is below zero (in this case my signals going into the PIC are between 00 and FF, with 7F corresponding to zero in the analog portions). There must also be checks so that values below 00 or above FF saturate, not roll over.
I cannot imagine that I am the only person to do this in this way, and there must be a simpler way to approach it rather than to use a separate PIC to integrate - or use a series of nested IF/THEN statements that slows things dramatically.
Bookmarks