Simple SMPS using 8 pin PIC microcontroller. - diyAudio
Go Back   Home > Forums > Amplifiers > Power Supplies

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 26th October 2010, 12:18 AM   #1
diyAudio Member
 
nigelwright7557's Avatar
 
Join Date: Apr 2008
Location: Carlisle, England
Default Simple SMPS using 8 pin PIC microcontroller.

Just started on a design for a simple PIC micro SMPS.
This one converts 30 to 55 volts to 12 volts.
PIC SMPS

Last edited by nigelwright7557; 26th October 2010 at 12:26 AM.
  Reply With Quote
Old 26th October 2010, 12:31 AM   #2
diyAudio Member
 
nigelwright7557's Avatar
 
Join Date: Apr 2008
Location: Carlisle, England
Here is the simple PIC12f508 code.

;INTERNAL OSC, INTERNAL MCLR, POWER UP TIMER ON

LIST R=DEC
LIST P=PIC12F508
;INCLUDE REGISTER DEFINITIONS
INCLUDE P12F508.INC



;_MCLRE_ON EQU H'0FFF'
;_MCLRE_OFF EQU H'0FEF'

;_CP_ON EQU H'0FF7'
;_CP_OFF EQU H'0FFF'

;_WDT_ON EQU H'0FFF'
;_WDT_OFF EQU H'0FFB'

;_LP_OSC EQU H'0FFC'
;_XT_OSC EQU H'0FFD'
;_IntRC_OSC EQU H'0FFE'
;_ExtRC_OSC EQU H'0FFF'



__CONFIG _MCLRE_OFF & _WDT_ON & _CP_OFF & _IntRC_OSC

INCLUDE MACRO.ASM

;ACCESSES REGISTER BANK BIT
#DEFINE RB0 STATUS,5
;

#DEFINE FEEDBACK GPIO,0 ;12 VOLT FEEDBACL
#DEFINE MOSFET GPIO,1 ;MOSFET 1=ON


STATEA EQU 1

FIRSTA EQU 0
FIRSTB EQU 0

;***********************
FIRSTRAM EQU 7 ;JUST POINTER TO FIRST RAM LOCATION
DEL1 EQU 7
DEL2 EQU 8
DEL3 EQU 9
COUNTL EQU 10
COUNTH EQU 11
TEMP EQU 12


LASTRAM EQU 1FH
;;;;;;;;;;;;;;;;;;;;;
ORG 0
;SETUP PICI/O AND OPTIONS
MOVLW FIRSTA
MOVWF GPIO

CLRWDT

MOVLW STATEA
TRIS GPIO

MOVLW 0C0H ;WEAK PULL UPS OFF & WAKE UP ON PIN CHANGE OFF
OPTION
;;;;;;;;;;;



;POWER UP DELAY
CALL WAIT1MS

MLOOP CLRWDT
BTFSC FEEDBACK
GOTO MLOOP ;DO NOWT OF OVER 12 VOLTS.

BSF MOSFET ;MOSFET ON
MOVLW 33 ;WAIT 100US
MOVWF TEMP
TIME CLRWDT
DECFSZ TEMP,F
GOTO TIME
BCF MOSFET ;MOSFET OFF

;MUST HAVE MOSFET OFF TIME FOR INDUCTOR TO RECOVER.
MOVLW 33
MOVWF TEMP
TIME2 CLRWDT
DECFSZ TEMP,F
GOTO TIME2

GOTO MLOOP



;********************
WAIT1MS MOVLW 1
GOTO MSS
MS250 MOVLW 250
MSS MOVWF DEL1
MS MOVLW 249
MOVWF DEL2
DD CLRWDT
DECFSZ DEL2,F
GOTO DD
DECFSZ DEL1,F
GOTO MS
RETLW 0
;***********************
  Reply With Quote
Old 26th October 2010, 01:00 AM   #3
tomchr is offline tomchr  United States
diyAudio Member
 
tomchr's Avatar
 
Join Date: Feb 2009
Location: Greater Seattle Area
Any reason not to use a switchmode IC such as UC3843 or similar?

I recommend running faster than 20 kHz. Otherwise, you'll hear your magnetic components whine quite clearly. I also recommend using a buck or buck/boost topology. It looks like you're running very high peak currents through the mosfet and zener diode. I don't think that's good for the reliability of those components.

Or better yet... Leave the design effort to the pros and go with one of National Semiconductors' SimpleSwitchers. On some ICs all you need is a resistor network and a couple of caps. On others, you have to supply an inductor and a diode as well. It's not rocket science, but it is slightly more cumbersome than the average linear regulator design.

If you don't need a high output power, something like the cheapo flyback supply described by Dwaine Reid in Electronic Design April 8, 2010. "Build Your Own Ultra-Low-Cost Isolated DC-DC Converter" would work. You should be able to get to the article through a google search (or go to Electronic Design directly).

~Tom
  Reply With Quote
Old 26th October 2010, 01:10 AM   #4
diyAudio Member
 
nigelwright7557's Avatar
 
Join Date: Apr 2008
Location: Carlisle, England
Quote:
Originally Posted by tomchr View Post
Any reason not to use a switchmode IC such as UC3843 or similar?

~Tom
The main problem seems to be the amount of extra components needed.

I can use an 8 pin PIC that is around 60p.
The zener is just a fast diode, used wrong part from library.
The inductor is 70p.
The P channel MOSFET can be a cheap part.

The circuit relies on a PIC input threshold of 2 volts, so all I have to do is scale the feedback voltage for the PIC.

I have used the watchdog on the PIC in case of failure sending 35 volts to the 12 volt supply.
  Reply With Quote
Old 26th October 2010, 01:14 AM   #5
Banned
 
Join Date: Jan 2008
Blog Entries: 2
It's a bit hard to read the schematic. I've redrawn it to make it a bit more comprehensible. Is this what you've got?

PIC_switcher.jpg

w
  Reply With Quote
Old 26th October 2010, 03:44 AM   #6
diyAudio Member
 
Sch3mat1c's Avatar
 
Join Date: Jan 2003
Location: Milwaukee, WI
Send a message via ICQ to Sch3mat1c Send a message via AIM to Sch3mat1c
So wait, it's all software loops? And fixed? :barf:
__________________
Seven Transistor Labs
Projects and Resources
  Reply With Quote
Old 26th October 2010, 04:56 AM   #7
benb is offline benb  United States
diyAudio Member
 
Join Date: Apr 2010
Both this and the Electronic Design article are dead simple. but I can see "possibilities" where such a low-cost design could have a lit more features.

But yeah, two loops to make a fixed width rectangular wave is awfully basic - the PIC might as well be a 555 timer chip.

First off, I'd go to C rather than assembly - embedded C compilers are pretty darn good thesedays, and they're available for every microcontoller, usually from at least three sources - the manufacturer, third parties such as IAR, and freeware/GCC versions. Even "pay" versions have free eval code-limited versions with the limitation way above the code needed for this. If you don't know C, it's worth learning.

Dunno what 60p is in USD, but TI has microcontrollers starting at USD $0.25:
MSP430 Value Line - TI.com
and projecting from the 1k cost, one with a 10-bit A/D is less than twice that. That's what I'd use to read the output voltage for feedback.

I've wondered why switching regulator chips seem to be relatively expensive (several US dollars each) when the parts for something like this are so cheap, but I recall using a LT1072 many years ago, and such chips have features that would take a good deal of design, coding and fine-tuning time to build into a microcontroller-controlled SMPS.

OTOH, there does seem to be a bit of info out there:
microcontroller SMPS - Google Search
  Reply With Quote
Old 26th October 2010, 06:27 AM   #8
luka is offline luka  Slovenia
diyAudio Member
 
luka's Avatar
 
Join Date: Sep 2005
Location: in Slovenia :)
Send a message via Skype™ to luka
Cool project, had plan to do one myself with PIC
you made the code?
But I have to say I DO NOT like assembler
__________________
home page @ http://www.classdaudio.tk/ @ 24/7 all year long
I FEEL SLOVENIA
  Reply With Quote
Old 26th October 2010, 11:04 AM   #9
diyAudio Member
 
nigelwright7557's Avatar
 
Join Date: Apr 2008
Location: Carlisle, England
Quote:
Originally Posted by wakibaki View Post
It's a bit hard to read the schematic. I've redrawn it to make it a bit more comprehensible. Is this what you've got?

Attachment 193762

w
That looks correct.
It is just a first fraft.
  Reply With Quote
Old 26th October 2010, 11:48 AM   #10
diyAudio Member
 
Join Date: Jul 2005
Location: Montréal QC
I used to use a PWM controller in my previous job :

Microchip dsPIC33FJ12MC201

IT's a motor control PIC with several PWM channels and ADC/DACs...It does what you want - and only $1.80, IIRC! You can write to it in C, and the free IDEs are great. MPLAB!
__________________
http://blog.liammartin.com
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Controlling a relay with a PIC microcontroller rtarbell Parts 9 12th October 2006 09:29 PM
PIC Microcontroller starter kit?? Zero Cool Everything Else 15 25th July 2006 01:24 PM
wiring config..of 4 pin multi (pic) jonz Everything Else 0 1st October 2004 10:55 PM


New To Site? Need Help?

All times are GMT. The time now is 12:00 PM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright ©1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2