Hello Guys,
I am a newbie to Piccolo and i am currently designing a switching converter for an university project, i have the following adc routine running at 50KSps. I am trying to implement a simple PI controller inside the ADC routine (i am not sure this is correct but based on reading online materials i think is somewhat done).
My problem is my integrator output saturates and doesnt increment over period of time (actual output of Integrator is sum of past errors) until i declare the variables to be "static". But when i declare the variables to be static my loop samples is reduced to 10KSps. The following is the ADC routine in i have to declare variables in_A and k_5 as static but significantly loosing the loop performance.
Is there any way to design a simple PI controller using F28027 or any example i can refer ? Please kindly help thanks a lot in advance...
interrupt void adc_isr(void)
{ float err_5, A_5,B_5,v_5,Vpi_5=0.0; static float in_A=0, k_5=0.0;
GPIO_toggle(myGpio, GPIO_Number_1);
//discard ADCRESULT0 as part of the workaround to the 1st sample errata for rev0
Voltage1[ConversionCount] =ADC_readResult(myAdc, ADC_ResultNumber_1);
err_5=1.25-3.3*(Voltage1[ConversionCount])/4096;
//if(ConversionCount>1)
A_5 = err_5 * 0.4; //proportional error
/* integrator
B_5 = err_5 * 727.27;
v_5 = k_5 + 0.5/50000 * (B_5 + in_A); //in_A and k_5 has to be declared static
k_5 = v_5;
in_A = B_5;
*/
Vpi_5=v_5+A_5;