Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Reading A-D for Buck Converter

Status
Not open for further replies.
In a Bit of a dilemma here on how to read the PIC a-d on Vout of a Buck Converter. There is about 800mv of ripple total, on an approximate 16V input (5% a little too high?).

Tried to buffer eight readings in a row, then average them too little effect. The period of the Converter output is in the range of 160Hz. The PWM is running at 95khz to the switcher PFET. So triggering an a-d to resemble some sort of average is eluding me. Can't tie up the processor to get a really large sample.

The PIC at the moment is a 16F887, could be a 18F later. Would rather not go with 16 bit, Any ideas?
 

Mr RB

Well-Known Member
Use a large low pass filter on the ADC pin, if that does not get it reliable enough then take a number of readings over the same time period as 1 switching cycle, so at 95kHz (10.5uS) you take 4 equally spaced readings over 10.5uS and average them.

Since your PIC is probably too slow to take a reading every 2.6uS you can use a beat frequency to evenly space the readings, using;
Code:
adc_period = (pwm_period * x) + (pwm_period / n)
 (where n=number of evenly spaced samples and x can be any number)

so for your pwm period of 10.5uS you could use;

adc_period = (10.5 * 3) + (10.5 / 4)
adc_period = 34.125uS

That should be easy enough on a 20MHz PIC and then the 4 samples will be evenly spaced and will average the cap ripple out.
 

Pommie

Well-Known Member
Most Helpful Member
If you do use the beat frequency approach, you can set timer2 postscaler to 4 and it will set the TMR2IF (and interrupt if enabled) every 4 pwm cycles.

Mike.
 
Thank you RB, the low pass looks like it's going to do it. Not used to putting such a fat cap on. Had a 1.5uf tantalum in the bin, along with a 1k resistor, and the results seem to have tightened up considerably. Still getting an occaisonal glitch that blows it up. Also have jumped the samples up to 32. May try a smaller resistor.

The beat frequency method looks very interesting, and will give it a go when I have some more time.

Pommie, did not know that, thanks. Definetely worth looking at.

This is going to take some tinkering. Will report back.
 
Thanks you guys, am now getting very close correlation between a-d reading and DVM on output voltage. Down to just a couple bit range of 10 bit reading, nice!

1)Increased C of low pass filter to 2.2uf, decreased R to 470ohm.
2)Put on a 20Mhz crystal for faster operations.
3)Implemented the beat frequency in interrupt routine, big help!

Interrrupt routine in GCBasic:

Code:
sub VoutA2D
'interrupt every 4th PWM period overflow
'set by TMR2 postscale

TMR2IF = 0	'clear overflow flag
count2 += 1
If count2 = 1 Then
	Vout = ReadAD10(AN2)
end if
If count2 = 2 Then
	nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop
	Vout1 = ReadAD10(AN2)
end if
If count2 = 3 Then
	nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop
	nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop

	Vout2 = ReadAD10(AN2)
end if
If count2 = 4 Then
	nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop
	nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop
	nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop:nop
	Vout3 = ReadAD10(AN2)
	Vavg = Vout
	Vavg = Vavg+Vout1
	Vavg = Vavg+Vout2
	Vavg = Vavg+Vout3
	count2 = 0
end if
end sub
 

blueroomelectronics

Well-Known Member
Take a look at AN874 on the microchip site. It's a 1W LED buck converter built around a 12F675 and contains a well written how it works.

PS PICs with a gated CCPx timer and comparators would be my approach, I would avoid the A/D solution. I recall there are a couple of PICs designed for switchmode supply operation.
 
Last edited:
Take a look at AN874 on the microchip site. It's a 1W LED buck converter built around a 12F675 and contains a well written how it works.
Took a look, and that is a relevant appnote. This post is a little out of context, as the main thread is in the renewable forum here.

PS PICs with a gated CCPx timer and comparators would be my approach, I would avoid the A/D solution. I recall there are a couple of PICs designed for switchmode supply operation.
This is exactly what I have implemented here. Currently the voltage output divider is supplying the comparator -input, PWM to the +input, and the output to a mcp tc4426 mosfet driver to Pfet switching transistor.

Still need to find the battery voltage (in my case), and the a-d to find the output voltage is problematic, due to the ac waveform on the smps output. Even in the AN874, the a-d conversion is not straight forward.

Yes, have a 30F2010 in the pile, which is supposed to do synchronous smps, but don't see going down that road for some time.
 

Mr RB

Well-Known Member
Ahh I see! You wanted to get the PIC to measure the buck output voltage from ITS OWN PWM??

If you had said that I would have suggested using the PIC comparator to control the buck duty in analog, then just generating a reference voltage with the PIC.

What's the response time with the ADC->PWM control loop you are using, and what will happen if you get bit transients?? Sounds a bit scary.
 
Well this is truly a learning experience for me. Need to hit the net for more info and education. It's clearly not 1's and 0's anymore since adding the inductor, diode and cap. Should learn LT Spice and try simulating rather than acting out on a proto board. My approach thus far seems flawed.

Will post schematic of what I have (tomorrow I hope), and go from there.
 
Well there has got to be an easier way to get from Diptrace schematic to jpeg, or gif or something that will show up in attachments. Printed to pdf which comes out decent. Tried converting to jpeg, and it was terrible looking! Tired of messing with schematic stuff.

Anyway, here is the basic setup on the buck converter. The input will soon be a solar panel rated at 17V, 4.4A, and the output load a 12V RV battery. Using a power supply and car tail light for the time being.

The circuit seems comfortable at 34khz, as higher frequencies reduce the desired output voltage. That's the weird part, as I wouldn't think frequency would have anything to do with Vout. My impression was that the duty cycle would drive the Vout, not frequency. Any suggestions for improvements or things to try? Kind of stuck with the inductor at the moment, but will be ordering more parts soon if given direction.

EDIT:found the preview/save as/jpg for diptrace, still bad
EDIT2: ok finally got a half decent picture by upping scale factor
deleted crummy jpegs.
 

Attachments

  • smps.pdf
    11.3 KB · Views: 116
  • smps_schem2.jpg
    smps_schem2.jpg
    49.7 KB · Views: 373
Last edited:

Mr RB

Well-Known Member
To get the image from Diptrace (or whatever program) just press printscreen, then open up any image editor program and paste->new image. It captures whatever image is on screen, then you can crop it neat and save as a .PNG or .GIF etc.

Your circuit looks ok, to drive lamps. But driving a large 12v RV battery from a buck converter is a very different situation. You can't just regulate output voltage like in your schematic!
 

smanches

New Member
The way I stabilize my feedback readings is to time the sampling of the ADC to the PWM output. This way you are reading the same position in the inductor ripple every time. Best would be to do the sampling just before the PWM fires again so you're not reading the middle of the inductor ringing.
 
Last edited:
Status
Not open for further replies.

EE World Online Articles

Loading
Top