Connect with us

PI Controller DC-DC Buck Converter with PIC16F877A

Discussion in 'Power Electronics' started by emrebay, May 5, 2019.

  1. emrebay

    emrebay

    16
    0
    Dec 27, 2018
    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: May 5, 2019
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    9,307
    1,888
    Nov 17, 2011
    PI controller for controlling which parameter?
    In hardware or in software?
    What is it supposed to do? What is the difference in real life to the expected behavior?
     
  3. emrebay

    emrebay

    16
    0
    Dec 27, 2018
    there is no output signal on osilascope but i will change the PIC and i will test again (tomorrow)
    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
     
  4. Harald Kapp

    Harald Kapp Moderator Moderator

    9,307
    1,888
    Nov 17, 2011
    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.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-