LM317 PWM using BC547 - Page 1
Forum section: electronics / beginners

author: Griffin
author_rank: Unknown
timestamp: April 16, 2012, 06:20:50 pm
content: Hi EveryoneI have been experimenting with a LM317 the last few days trying to control its output using PWM to make a rough uC controlled power supply using the parts I have. I know the best thing to use is an OP-Amp but I was wondering if you guys could have a look at this schematic I have been having some success with. It basically uses the BC547 as a pass transistor for the base and I feed the PWM signal to the 547 trough a RC filter.What do you guys think about this as a solution and also what will the ideal PWM frequency be for something like this.PS: I currently have it working in rough 100mV steps from 1.5v to 24v with a dead spot near 9v-11v but thats my RC filter acting up.

author: free_electron
author_rank: Super Contributor
timestamp: April 16, 2012, 08:24:10 pm
content: that don't work right ....put the r/c after the transistorresistor between out and adj : 120 ohmresistor from ADJ to ground : 20Kcapacitor from ADJ to ground : 22uFcollector transistor to ADJ pinemiitor transistor to ground.now start pulsing the base ...you basically discarge the capacitor.Keep in mind that whatever ripple you have there will be amplified at the output.Your whole premise is wrong. why do you want to be stuck with the LM317 ?integrate your PWM signal with an R/C , follow with an opamp and feedback node and drive a NPN with the opamp.pwm - R - +- C - Gndthe RC node goes to + input opamp.output opamp to NPN power transistor base.NPN emittor is outputfrom output a resistive divide to ground. centerpoint of divider to - input opamp.

author: Griffin
author_rank: Unknown
timestamp: April 16, 2012, 09:43:36 pm
content: Basically I know the op-amp would be the best solution but I do not have one and I will not be able to get one for a while. So what you see in my schematic is basically what I am stuck with...I am building a base for a VERRY simple uC controlled power supply 0 – 24v. The output of the LM317 will go to a 2N3055 to increase my output current. I have attached the modified version of the schematic.What will you say would be a good frequency to for the PWM in this type of setup?

author: free_electron
author_rank: Super Contributor
timestamp: April 16, 2012, 10:36:35 pm
content: Quote from: Griffin on April 16, 2012, 09:43:36 pmso, it needs ot be computer controlled , but an opamp is too complicated ... opposite world.... 1 million transistors to turn on a lightbulb but a fuse is too expensive .. riiiiiight ....anyway. your schematic is now correct.as for pwm frequency : as high as possible. you want to keep the ripple low. the lm317 has a a certain bandwidth on its adj pin. if your pwm carrier runs above that it will not see your switching pulses and go by the average of the voltage across the capacitor.

author: amspire
author_rank: Super Contributor
timestamp: April 16, 2012, 11:05:04 pm
content: Adding a base emitter resistor will give you a better chance of this working. It turns the NPN transistor into a constant current sink when it turns on. PWM frequency? as high as possible.Richard

author: Griffin
author_rank: Unknown
timestamp: April 16, 2012, 11:18:38 pm
content: QuoteI understand what you are saying but I live in a very remote area in a 3rd world country and basically I had to pre-ordered a bunch of parts (Almost every resistor, capacitor, bunch of micros and so on). I am at work now so will try to test the circuits you mentioned later but the original one I posted actually worked to an extent to begin with.I know the op-amp is the way to go but I just do not have access to one now so I have to do the best with what I have. So getting the circuit down with a RC filter is what I need to do.As a side note, what op-amp would work in this situation so I can order it (6weeks waiting time).Thanks

author: SeanB
author_rank: Super Contributor
timestamp: April 17, 2012, 04:45:08 am
content: Exactly where? Most common opamps ( 741 and it's buddies) are easy to ship, and SAPO will do a next day delivery to most cities, or a 3 day for others. I live in Durban BTW.

author: Griffin
author_rank: Unknown
timestamp: April 18, 2012, 04:25:25 am
content: QuoteWow what are the odd's. I'm working for a mining contractor on site near Van Zyl's (NC). We have a 6 week on 2off rotation... thats why it's so difficult to get stuff.

author: Griffin
author_rank: Unknown
timestamp: May 05, 2012, 04:31:13 pm
content: Hi EveryoneAfter allot of effort I finally got my PSU up and running using the RC filter and PWM. But I need help with just one more thing. I attached my schematic of the MCU board that controls the PSU. I've removed the Max232 and all its components for now because it was not working. After allot of efferot I cannot get my ADC working. If there is anyone familiar with AVR's that could have a look at my schematic, board and code just to check where my problem could be.The ADC keeps returning 1023 no matter what changes I make to the code or the hardware. PS swapped atmega8's as wellCode:#include <avr/io.h>#define PORT_ON(port,pin) port |= (1<<pin)#define PORT_OFF(port,pin) port &= ~(1<<pin)int main(void){unsigned int adc_value;// Variable to hold ADC resultDDRB = 0b00000111;PORTB = 0b11111000;ADCSRA = (1<<ADEN) | (1<<ADPS2) | (1<<ADPS0);// Set ADCSRA Register with division factor 32ADMUX=0x01;//Binary equivalent of 0101while (1)//Forever since it is in single conversion mode{ADCSRA |= (1<<ADSC);// Start conversionwhile (ADCSRA & (1<<ADSC));// wait until conversion completes; ADSC=0 means Completeadc_value = ADCW;//Store ADC resultif (adc_value < 512){PORT_OFF (PORTB,2);// Set 7th bit}else{PORT_ON (PORTB,2);// Clear 7th bit}}}

author: Zero999
author_rank: Super Contributor
timestamp: May 05, 2012, 09:11:30 pm
content: Quote from: Griffin on April 16, 2012, 09:43:36 pmSorry to wait until you've built it but that circuit won't do what you want. It has a minimum output voltage of 5V. You need a negative power supply in order to set the output to 0V.

author: Griffin
author_rank: Unknown
timestamp: May 05, 2012, 09:55:33 pm
content: Found the problem I connected both AVCC and Vref. After setting the registers to use AVcc instead of ARef all worked fime. From the output of the LM317 there are 3 diodes that run to to the base of the 3055 transistor im using so I actually do get quite close to 0v output. No good for op amps I know but usefull regardless.Just wanted to let everyone also know I just ompleted building and testing with base firmware and I have averry nice variable power supply. Its down and dirty but its the best to be done in the absense of an op-amp.