Naive approach to LM317 regulable current control from MCU - Page 1
Forum section: electronics / beginners

author: lluisball
author_rank: Newbie
timestamp: October 19, 2012, 07:48:24 am
content: Hi, I'm building a regulable power supply, as many of you do when learning electronics (I write software for a living, no electronics education).The approach I'm trying for current control seems to work, but I get the feeling that I am been too naive, since I have not seen any similar designs in the 'google-searcheable confines of the internet' and there must be a reason for this lack of similar designs.I want to have a set of fixed currents to select from and I want to toggle between them using a MCU (1, 0.5, 0.25 and 0.01 amps selections)Since a resistor between the LM317 output and adjust pins (and to the load) controls the current, I thought of having each of the 4 resistors (5W ones) I need, controlled by either MOSFETS or transistors acting like switches (the base/gate would be activated from the MCU). At any given time there would be just a single resistor active.You can see a schematic of the attempted design attached:- Can I safely do this?- Am I better of using a n channel mosfet or a simple NPN transistor?, I understand that since I just use them as an on/off switch, it won't really matter if I use properly rated transistors / mosfets.- I'm planning to feed the output, to another regulator (LT1963A) for voltage regulation, is it ok to do this with the proposed configuration?Regards

author: free_electron
author_rank: Super Contributor
timestamp: October 19, 2012, 04:09:39 pm
content: this is wrong on so many levels.first of all you would need pmos transsitors, not nmos- the way you have drawn the n-mos they are always conducting through their bulk diode- even if the bulk diode is not there you would have to drive the gate of the mosfet a t least a good 3 to 4 volt above the source , which is your regulator output , to turn them on... that means your cpu would have to be powered well above what it can handle- with the above circuit you have no voltage control...- a resistor between out and adj does NOT control current. the lm317 has no current control apart fromt he built in hard limit of 1.5 ampere.- why 5 watt reistors ? for your 10 milliampere range the maximum power dissipation in the resistor would be 12.5 milliwatts. for your 250milliampere range the dissipation would be roughly 1/3 watt. the lm317 cannot have more than 1.25 between adj and out before it starts closing the pass transsitor. this is the base principle of how it regulates. If there is 10mA running throught your 10mA 'range resistor' and 1.25 volt across it you are burning of 12.5 milliwatt. you do the math for the other ranges. even at the 1 ampere range a 1.5 watt resistor is sufficient.- this being said : this kind of regulation mechanism is crud. the lm317 is not designed to do this, yes you can get away with it but it is junk.if you are going to feed this to another regulator you will get into trouble for multiple reasons :the quiescent current of the voltage regulator will impact the current setting of this one.. do the voltage regulation first , followed by the current regulation.in short :- your understanding of mosfets is wrong- your understanding of lm317 is wronglet me guess. you have an arduino and you want to slap on a pair of lm317 to make a lab supply ? right ?wrong approach.when designing a lab power supply you FIRST design the regulation system. the cpu control is an afterthought. There is not single commercial lab grade power supply that uses 317 's. not a single one !you are far better off making the tried and tested regulation system with two opamp , a voltage reference , a current source and a big fat darlington to feed juice to the output. you then control the voltage and current settings from two D/A converters and off you go. no worries, no hassles and it will work right.

author: lluisball
author_rank: Newbie
timestamp: October 19, 2012, 05:14:10 pm
content: Thanks for the anwser!, I do my best to learn, but I am a beginner, I'm prone to do some really stupid stuff... I did have a feeling I was doing this all wrong, that's why I asked :-).>>if you are going to feed this to another regulator you will get into trouble for multiple reasons :>>the quiescent current of the voltage regulator will impact the current setting of this one.. do the voltage regulation first , followed by the current regulation.Ok, I thought that using the LM317 for current limiting would also mean a change of the output voltage fro the current limiting stage therefore the output of the voltage regulation stage would need to be placed after the current limiting stage.>>in short :>>- your understanding of mosfets is wrong>>- your understanding of lm317 is wrongYep, so it seems, I will do some more reading before attempting to use mosfets or LM317's for something like this.>>let me guess. you have an arduino and you want to slap on a pair of lm317 to make a lab supply ? right ?>>wrong approach.close enough, I was going to use an attiny2313 with an pwm output going to a low pass filter + opamp to amplify voltage to control the voltage regulation of an LT1963A and a couple of i/o pins to control the current in the manner I described in my previous post (with the lm317) .>>when designing a lab power supply you FIRST design the regulation system. the cpu control is an afterthought. There is not single commercial lab grade power supply that uses 317 's. not a single one !Seems logic to forget about the MCU until I grasp the regulation part much better, I 'm building this as a learning experience, I do not expect to build anything near commercial grade.>>you are far better off making the tried and tested regulation system with two opamp , a voltage reference , a current source and a big fat darlington to feed juice to the output. you then control the voltage and current settings from two D/A converters and off you go. no worries, no hassles and it will work right.I will have a look to this approach, I have access to opamps and DAC's.Regards

author: free_electron
author_rank: Super Contributor
timestamp: October 19, 2012, 07:33:57 pm
content: download the manual of a simple bulletproof lab power supply like an agilen E3410 and look at that schematic. everything you need is in there. and it is easily adaptable to computer control.

author: benemorius
author_rank: Regular Contributor
timestamp: October 19, 2012, 07:55:25 pm
content: E3610

author: free_electron
author_rank: Super Contributor
timestamp: October 19, 2012, 11:48:17 pm
content: oops brainfart. e3610 it is ...