Continue to Site

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.

PIC as switch-mode controller

Status
Not open for further replies.

justDIY

Active Member
Has anyone experimented with using a PIC (or other mcu) as the brains behind a dc/dc converter?

Right now I'm working on a boost converter, using the pic's pwm generator to drive the switch and the a2d converter to measure current.

I just picked more or less random parts off my workbench to build the boost converter. Currently I am turning 5v into 30v, driving a string of 10 white LEDs at up to 20mA.

the problem I'm having is ripple in the output current is corrupting my A2D readings ... I measure about around 70mV peak to peak ripple. I have tried various combinations of capacitors on the input and the output. I've also found too much capacitance on the output makes the regulation unreliable, since it is slow to respond to changes in the switch duty cycle.

**broken link removed**
output ripple - this is an old picture before I started trying different capacitors

Here are some links to what I've done so far - feedback would be appericated.

Pic Based Boost Converter
Pic Based Boost Regulator
**broken link removed** #2 (different link)
 
if you look at the block diagram of what's inside a switching power supply controller, it's generally reasonably simple, such as using a triangle wave and comparator to generate the PWM signal, and then some extra stuff for current limiting and whatnot... I don't think a PIC is really suited to that - using a clocked digital system which can only respond at a rate on the order of its instruction clock speed seems to be a big limitation compared to an analog system which has no such restriction... the slower reaction time of the PIC would first of all limit the PWM frequency, and also increase ripple, since it wouldn't be able to instantly respond to a changing voltage...

*edit* I've now read your project log a bit, and seen some of your reasoning...

Well, it seems to me it would be better to use a combination of analog and digital... the analog system seems like it would respond better to ripple, but you could have it heavily integrated with the PIC for things like determining the PWM frequency. sort of like giving a microcontroller access to the inner workings of a regular switching converter controller IC, you'd get more flexibility; only you could build your own.
 
the problem I'm having is ripple in the output current is corrupting my A2D readings

What is the frequency of your PWM signal? I suggest that you synchronize the A2D conversions with the PWM frequency. This will enable you to sample the output voltage at the same part of the ripple waveform. This would eliminate the errors due to the ripple.
 
You may also be using too much feedback. If the output is just 70 mV off, you don't want to kick the duty cycle up and down a lot for this.
Synching the ADC to the PWM output is a good idea.

Make sure you have schottky or other high speed diode here.
 
Have you considered the gnd and Vcc tracks?

Switching Mode Converters have high current spikes that cause voltage drop spikes across any tracks through which the current flows. These can affect other parts of the circuit. The solution is to feed the Gnd and Vcc from one point (called "star point"), ie. a start point for Gnd and one for Vcc.

Thus the low level signals are not affected.
 
I just received my schottkys ... too worn out from work today to play with my projects - however, down-time is quickly approaching.

1) will look into syncing the a2d with the pwm ... I could setup an interrupt to fire on the rising edge of the pwm pulse, so the voltage reading would be made with the switch conducting - that should be the lowest point I do believe?

2) sure there is plenty of noise in my tracks - since this is just on a breadboard, well, two breadboards - one contains the PIC and an rs232 shifter, the other contains the converter and the led string.

3) I have two outstanding orders right now, one for some low ESR capacitors (recommened in various data sheets) and one for some better inductors (at least, inductors of known value)

I found an article on EDN written by an engineer with Microchip - he was explaining how to use the PIC mcu as the brains of a boost converter - i just need to read the article several more times for it to sink in.
 
I could setup an interrupt to fire on the rising edge of the pwm pulse, so the voltage reading would be made with the switch conducting - that should be the lowest point I do believe?

Since you are synchronized to the PWM frequency, this frequency is limited by the maximum conversion rate. This is about 25Khz (20usec conversion+ 20usec acquisition time). A 20Mhz midrange PIC with 10-bit resolution can have a PWM frequency of about 20Khz (50usec period). If you need to have a higher PWM frequency, you can add a postscaler to the timer 2 output that triggers interrupts. I.E., interrupts & A2D conversions can occur every other PWM duty cycle.

In the interrupt service routine:

1. Read the result from the previous conversion on ADRESH+ADRESL.

2. Start a new conversion.

3. Calculate the PWM duty from the previous conversion result. You have to limit the maximum duty cycle value to allow the coil to discharge.

4. Return from interrupt.

If you start an A2D conversion and wait for completion within the ISR, you will be wasting 20usec within the ISR. If this is acceptable, you would have a faster response time to controlling the current than the reversed sequence above.
 
motion's dead-on. Increase the freq, increase the postscalar.

I've toyed with PIC DC-DC converters.
Here's some notes:
1. PIC being limiting to at most 8 bits of duty cycle can be a problem. In fact with a 30v output, regulating the output within 70mV is probably impossible. One duty is too high and one too low.
2. It's a difficult to accomodate other features to control the inductor current. For example, many boost controller chips use a shunt resistor to read inductor current to avoid saturation. Saturation is very very bad. For sensing this you need an analog comparator, you can kinda use the PIC's comparator input for this but extra hardware may be required and due to the interrupt system the speed of the response may be questionable. If it's a high side shunt resistor (which is likely necessary), it could be really hard to use a PIC.
3. PWM response is relatively slow. Whereas a ramp generator and comparator can correct the period immediately, the PIC not only needs to wait for the ADC to finish but also for the current cycle to complete. PIC spec says that when the TMR2 period begins, it latches in the period value. If the ADC comes back and says the period is too long/short, you can rewrite the period register but it won't have any effect extending or shortening the current cycle. Delays in control loop always increase oscillation problems and decrease its impulse response.

On one hand, a PIC could in theory have a good transient response through the use of DSP on the readings. It could also try to detect oscillation and slow down its parameters if this occurs. But realistically these are difficult for a beginner to implement.

It can support smart current limit and thermal protection strategies... all nice stuff.
 
justDIY said:
2) sure there is plenty of noise in my tracks - since this is just on a breadboard, well, two breadboards - one contains the PIC and an rs232 shifter, the other contains the converter and the led string.
Even so, you can still connect the gnd and Vcc in star.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top