Maker Pro
Maker Pro

PI Controller DC-DC Buck Converter with PIC16F877A

Hi. How can i add PI controller on this circuit? btw this circuit works on Proteus but doesn't work in real life i don't know why, could you help me please?
thank you.

Proteus https://imgur.com/n1MAmAf


[Mod edit: changed to CODE]
Code:
void main()
{
   set_tris_a(0xFF); 
   set_tris_c(0x01);   
 
   setup_timer_2(T2_DIV_BY_1,255,1);
   setup_CCP1(CCP_PWM);
 
   int buton_1,buton_2,buton_3,buton_4;
   int16 Duty=0;
   float YuzdeDuty;
   set_pwm1_duty(Duty);
 
   while(TRUE)
   {
 
     buton_1=input(pin_A0);
     buton_2=input(pin_A1);
     buton_3=input(pin_A2);
     buton_4=input(pin_A3);

     if(buton_1 == 1 && buton_2 == 0 && buton_3 == 0 && buton_4 == 0)
     {
     delay_ms(20);
     Duty=250;
  //   YuzdeDuty=25;
     set_pwm1_duty(Duty);
    // output_d(YuzdeDuty);
     }
    
     else if(buton_2 == 1 && buton_1 == 0 && buton_3 == 0 && buton_4 == 0)
     {
     delay_ms(20);
     Duty=400;
    // YuzdeDuty=50;
     set_pwm1_duty(Duty);
     //output_d(YuzdeDuty);
     }
    
     else if(buton_3 == 1 && buton_1 == 0 && buton_2 == 0 && buton_4 == 0)
     {
     delay_ms(20);
     Duty=600;
     //YuzdeDuty=75;
     set_pwm1_duty(Duty);
     //output_d(YuzdeDuty);
     }
    
     else if(buton_4 == 1 && buton_1 == 0 && buton_2 == 0 && buton_3 == 0)
     {
     delay_ms(20);
     Duty=850;
     //YuzdeDuty=100;
     set_pwm1_duty(Duty);
     //output_d(YuzdeDuty);
     }
   }

}
 
Last edited by a moderator:
What is it supposed to do? What is the difference in real life to the expected behavior?
there is no output signal on osilascope but i will change the PIC and i will test again (tomorrow)
PI controller for controlling which parameter?
In hardware or in software?
For example there is an input voltage of 24 volts and I want to lower it to 18 volts and i provide it with buttons then i change the value of the load resistor but the output voltage is remain the same
 

Harald Kapp

Moderator
Moderator
For example there is an input voltage of 24 volts and I want to lower it to 18 volts and i provide it with buttons then i change the value of the load resistor but the output voltage is remain the same
Your circuit is not suitable for this purpose. It can only turn the full power to the load resistor on or off. This results in a square waveform of the voltage across the resistor, not a linearly regulated DC voltage.
Google "pic controlled voltage regulator" for circuits that can create a linear regulated voltage controlled by a pic processor or google "pic controlled switch mode regulator" for circuits that use a switch mode regulator controlled by a pic.
 
Top