Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Closed loop voltage control of a buck converter using pic 16F876A

Status
Not open for further replies.

biswaIITH

Full Member level 4
Joined
Aug 23, 2014
Messages
204
Helped
27
Reputation
54
Reaction score
28
Trophy points
1,308
Location
Hyderabad
Activity points
2,907
hello folks i am controlling the output voltage of a buck converter using PIC16F876A. but i am not getting the desired output.

i am using a 11.05 mhz crystal oscillator..
input voltage of the buck converter is 20v
desired output voltage is 16v.
and switching frequency is 20khz

below is the code which is a simple pi controller implemented in pic16f876A


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
float adc;
float set_ref=3;
float err_val=0,I_err=0;
float current_duty_2=50;
float Kp=1,Ki=2;
float P_term=0,I_term=0;
float Sum_err=0;
void main() {
ADCON1=0x80;
TRISA=0xFF;
TRISC.F1=0;
PWM2_Init(20000);
PWM2_Start();
PWM2_Set_Duty(current_duty_2);
while(1)
{
adc=ADC_Read(1);
err_val=set_ref-adc;
P_term=Kp*err_val;
I_err=I_err+err_val;
if(I_err>30)
I_err=30;
else if(I_err<-30)
I_err=-30;
I_term=Ki*I_err;
Sum_err=(P_term+I_term);
if(Sum_err>255)
Sum_err=255;
else if(Sum_err<0)
Sum_err=0;
current_duty_2=Sum_err;
PWM2_Set_Duty(current_duty_2);
}
}

 
Last edited by a moderator:

What is the expected behaviour and what is the behaviour that is actually happening?
 

my doubt is whether this code is right or wrong .Any improvement if required or necessary is what i am expecting...
 

The code seems to be correct as per the syntax.I recommend you to program the code in the microcontroller and start observing the output behaviour.
 

do u think it would be better if i write my own adc code instead of using simply adc_read(1) command
 

I do not think it will have any big advantage over the adc_read function,which you are currently using in your program.I think you should test your code,by running it on a system.That way,you can know whether you should keep the code as it is or change it.
 

Well i have tested the above code in a buck converter.Below are my observations over approximately 10 trials

observation-1

1) i am getting 15 v output as against 16 v which is desired but i am not getting any pulses from the mikro or the oscilloscope is nt showing.

observation-2

1) when i am opening the loop i.e. the input voltage to the buck converter is switched off, i should get pulses as set in the code before the while loop.But, i am getting a pulses which is completely different than the one set in the code

observation-3

1)no output and no pulses in closed loop

i am confused .
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top