linear1 forums
[part of the linear1 network]
+ [linear1 case mods]
+ [LED Center]
+ [privacy policy]
Welcome, Guest. Please login or register.
March 15, 2010, 08:29:40 PM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Login Register

linear1 forums  |  LED discussion  |  Microcontroller madness  |  Topic: PIC based buck regulator « previous next »
Pages: [1] Print
Author Topic: PIC based buck regulator  (Read 1123 times)
SteveyG
Smart like tractor
**
Offline Offline

Posts: 46



« on: January 23, 2007, 02:34:35 PM »

Hi everyone  Smiley

When I finally get my own house at some point this year I plan to run a CAN bus or RS-485 network round every room. The intention being that this will control the ambient lighting in each room which will be RGB LED based (3W, superflux, 5mm etc depending on the fixture). The 3W stars as always pose the problem of the best way to drive them. Assuming I run a 12 or 24V supply to the lights to help prevent so much voltage drop, I'd be wasting as much as 80% of the energy with a linear constant current regulator, so this weekend I quickly threw together some components and some code to test how well I could make a switching power supply.

The main factor here is cost and since most switching regulators are fairly expensive over here in the UK, I wanted to try to make use of the PIC10F series of microcontrollers since they're mega cheap (£0.20 to £0.27!). Here's my first attempt...

(Excuse the awful matrix board - I hate using them, but I couldn't be bothered to go out to the workshop to cut up some FR4 board or develop and etch it  Roll Eyes)



Unfortunately I'd somehow ran out of 5V1 zeners for the PIC supply, so that 7805 is supplying the 5V 1mA requirement of the PIC  Grin Grin

Here it is driving a 3W red LED



We get some nice waveforms like this like we were taught at university but didn't believe...  Tongue Cheesy



The switching frequency is a little low, but I only had 220uH inductors to hand. I'll increase the frequency when I get some smaller ones.

I then measured the efficiency of the unit:



80% efficiency isn't too bad for a two hours work  Smiley The bipolar transistors are holding this figure back I suspect, although 80% would be perfectly acceptable for me.

Finally all three LEDs driven by the circuit:



When I get chance next weekend I need to check that it works as expected when fed with a PWM signal, if it does then I can concentrate on the CAN bus or RS485 side of things.

Steve.
Logged

Hi everyone, my name is Steve ... and *sigh* ... I'm an LED addict.
justDIY
Microcontroller Madman
Administrator
Smart like tractor
*****
Offline Offline

Posts: 1652


UFOric


WWW
« Reply #1 on: January 23, 2007, 03:03:04 PM »

Nice work Steve, and welcome to the forums!

So one switcher as a constant current source for the primary colors, and the plan is to dim each color using pwm on the low side of the led?  Won't that cause wild load-transients for the switcher to deal with?

Hows about using a slightly beefier pic (like a 14 pin), and driving three switchers, then you can connect your rs485 directly into the pic, and have it adjust the current output - achieving linear dimming, instead of pwm dimming.

Nice work - I look forward to seeing your project develop.  Any chance you can share a schematic or some source code?

Logged

Want to contact me directly? gmail gordonthree
My Project Blog - http://projects.dimension-x.net

Favorite numbers:
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
SteveyG
Smart like tractor
**
Offline Offline

Posts: 46



« Reply #2 on: January 23, 2007, 03:09:01 PM »

No the plan will be to have one regulator per colour, driven by a PIC16F737 which has three hardware PWM channels. If I choose to go the RS-485 route, then the protocol will be DMX-512 style, so it might be difficult to implement three switching regulators on the same device without flickering - even at 10 MIPS. This is something I'll have to try when I've made some further decisions...  Smiley
Logged

Hi everyone, my name is Steve ... and *sigh* ... I'm an LED addict.
abnormal
LED Houdini
Smart like tractor
***
Offline Offline

Posts: 100

LEDz rule


« Reply #3 on: January 23, 2007, 06:54:20 PM »

Hi Steve, welcome!

I don't know how hard set you are on the PIC... the Atmel parts (no I don't work for them  Grin) may allow a flicker free light as the are true risc. I switched after being PIC for many years and am very pleased. Plus there's avrfreaks.net for help and apps.

Nice project, please let us know more as it develops.


Logged

light um up!
justDIY
Microcontroller Madman
Administrator
Smart like tractor
*****
Offline Offline

Posts: 1652


UFOric


WWW
« Reply #4 on: January 23, 2007, 07:16:26 PM »

abnormal, have you any specific examples of a PIC's instruction time being a problem?   I'm not questioning you, just curious to know what the trouble was.
Logged

Want to contact me directly? gmail gordonthree
My Project Blog - http://projects.dimension-x.net

Favorite numbers:
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
SteveyG
Smart like tractor
**
Offline Offline

Posts: 46



« Reply #5 on: January 23, 2007, 07:55:48 PM »

Hi abnormal, I'm fairly hard set on PICs because I use them a lot at work and get given free development devices and virtually unlimited components from the guys there (even the expensive ones like the ICE and new RealICE Smiley). We've found that support is also a lot better from the Microchip team so I should really support them...

In terms of the flickering, I can't see how they'd get around the problem since you have to interrupt the switching in order to service an interrupt. This is the same on any device of this level. DMA would be nice - but I don't think I'll find it on a sub 50p device Smiley
Logged

Hi everyone, my name is Steve ... and *sigh* ... I'm an LED addict.
abnormal
LED Houdini
Smart like tractor
***
Offline Offline

Posts: 100

LEDz rule


« Reply #6 on: January 23, 2007, 08:11:46 PM »

multi-reply...

Hi JUSTDIY,

Question away....  Grin

The PIC has been great don't get me wrong.  Just when it comes to embedded control, higher volume production ($)... and you’re up against the wall "t" state, power and memory space wise, having more registers (not just the "w") and no "clock divide by 4" is pretty nice.  I'm no programmer by any stretch (old hardware guy) and found the Atmel parts have greater throughput and are very easy to use. Having experience with Freescale, Zilog, Philips, Toshiba…  and just about everyone else in the 8 bit uC world they just get my vote at this time.

Hi STEVEYG,

Agree, MC support is great, but I've had issues with other stuff. Not that it would stop me from using them as I still do.
Having the tools is a big big plus, I agree. Just wanted to point out some options that may help.

 - abz

Logged

light um up!
Rob
LED guy
Administrator
Smart like tractor
*****
Offline Offline

Posts: 1970


The constant-current gardener


WWW
« Reply #7 on: January 23, 2007, 10:13:08 PM »

Welcome to the boards SteveyG. You are a bit-tech regular, right? Thanks for dropping by.
Logged

SteveyG
Smart like tractor
**
Offline Offline

Posts: 46



« Reply #8 on: January 24, 2007, 04:34:53 AM »

Thanks for the welcomes  Smiley

Abnormal: I'll look into some of the Atmel devices, but I think I would suffer the same problems in any low-end microcontroller. The PIC24's have DMA which is great - but they're a little excessive for each node. I am planning on using a PIC24 for the master controller though  Smiley

Rob: I hope to be a regular poster here too! I have lots of projects I'd like to share  Cheesy
Logged

Hi everyone, my name is Steve ... and *sigh* ... I'm an LED addict.
SteveyG
Smart like tractor
**
Offline Offline

Posts: 46



« Reply #9 on: January 27, 2007, 08:04:18 PM »

Did another few hours work today on this.

After getting the regulator working properly last week, my next task was to make sure I could actually vary the brightness of the LEDs. The best method being to alter the reference voltage that is used to maintain a constant current - so I got a few MCP4921 DACs and interfaced them with a PIC micro. This gave me a massive 12 bit resolution, but at the expense of needing more board space Undecided I thought through various other methods, but ideally wanted to keep this as small and simple as possible. Since I plan to use a PIC16F767 for most of the nodes (it has three hardware PWM outputs with 10 bit resolution at up to 19.53kHz) I decided to try a much simpler method than the DACs and just clip (at ~0.6V which is my maximum Vref for 3W LED) then filter the PWM outputs.

Below is the circuit on proto-board again  Embarrassed. Top left is the PIC16F767, top right is the MCP4921. The cream coloured multiturn variable resistor sitting near the ICSP header is connected to an ADC input for testing purposes to alter the brightness. To the right of the variable resistor is the PWM clipping/filter. Below that is the SMPSU section (PIC10F204, transistor, inductor etc.)



A pin header with a jumper allows me to switch between the DAC's output and the filtered PWM output. It turns out that I overlooked one thing when thinking about using a DAC - that the minimum output is -Vref + 1 step, which in this case was just under 1mV which is enough to keep the LED dimly lit  Angry But the filtered PWM output worked beautifully  Cheesy and eases any board space and layout issues. Yay!

And to end this weeks' update, two pictures of an LED at different brightnesses  raised eyebrow Roll Eyes





Steve.
Logged

Hi everyone, my name is Steve ... and *sigh* ... I'm an LED addict.
cadstarsucks
Smart like tractor
****
Offline Offline

Posts: 449


« Reply #10 on: March 07, 2007, 07:13:01 AM »

Thanks for the welcomes  Smiley

Abnormal: I'll look into some of the Atmel devices, but I think I would suffer the same problems in any low-end microcontroller. The PIC24's have DMA which is great - but they're a little excessive for each node. I am planning on using a PIC24 for the master controller though  Smiley

Rob: I hope to be a regular poster here too! I have lots of projects I'd like to share  Cheesy

All the advantages posted for the PIC can be had for the ARM LM3S101.  The biggest problem with it is it only comes in a SOT28 package.

A quick comparison:
                PIC           AVR               ARM
part         16F636     ATTINY2313  LM3S101
price        2.55          2.24              2.20            (US$)
FLASH      2K             2Kx8             2Kx32 (16 bit instructions)
RAM         128x8       28x8              512x32
MHZ         20            20                  20
USART      no            yes               15550
SPI           no            yes               SSI 16 byte buffers
OSC         8              8                   7.373
PLL          no            no                 yes
analog     2 comp    1 comp          2 comp
mult         no           no                 32x32->64 2-7 cycles
div           no           no                 32/32 2-8 cycles                 
timers     1x8,1x16 1x8,1x16       2x32 or 4x16 or 1x32+2x16
registers 64x8        32x8             16x32

Most hobbyist applications would not need that kind of horsepower but it is the direction the industry is moving and there are 3 different free professional development packages for it (limited by code size), web as well as local cycle accurate simulation, Assembler, compiler (C and C++), linker, RTOS, and hardware debug all free.  (if you are willing to hack up a few cables, if not there is a  $40 dev kit with all that included and a OLED display)

Dan
« Last Edit: March 07, 2007, 07:31:13 AM by cadstarsucks » Logged
thundar
Strong like bull
*
Offline Offline

Posts: 2


« Reply #11 on: April 11, 2007, 02:54:11 PM »

SteveyG,

I'm trying to build a very similar circuit using a bx-24 (atmel based) uP module.    Are you willing to show the schematic for your circuit? 
Logged
justDIY
Microcontroller Madman
Administrator
Smart like tractor
*****
Offline Offline

Posts: 1652


UFOric


WWW
« Reply #12 on: April 12, 2007, 01:18:52 AM »

hi thundar, welcome to the boards!
Logged

Want to contact me directly? gmail gordonthree
My Project Blog - http://projects.dimension-x.net

Favorite numbers:
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
Pages: [1] Print 
linear1 forums  |  LED discussion  |  Microcontroller madness  |  Topic: PIC based buck regulator « previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.286 seconds with 19 queries.