picaxe controlled variable power supply

wapo54001

Senior Member
Hippy, you've got the pause time in the wrong place -- it should be between adjust up/down and tristate. But I still don't think you will need/want that when the circuit works properly. There is no problem with this circuit adjusting slowly. My own proven circuit is very responsive, it just doesn't handle higher-than-+5 (yet).

I've just completed a schematic and circuit card modifications that should give me what I want for testing purposes. But software is also important -- like telling it to respect the 1.25 minimum voltage of the lm317 because otherwise the correction code will go into a permanent loop trying to correct to a voltage below 1.25 which is unreachable.

You could force a return to main program after a fixed period of time, say two seconds, to help avoid this but that would create new problems. Best to set the range in software so that it matches the range permitted by the hardware.

How the system handles the high end is, I think, dependent on the resistor ratio because the high end should be set by the feedback reaching 5.0 volts, because that is as high as the pot will go unless modified in software.
 

Dippy

Moderator
Surely your pot 0-5V just 'represents' 1.2 to 15V doesn't it?
Or you could have up-down buttons if you have spare legs?
 

wapo54001

Senior Member
Surely your pot 0-5V just 'represents' 1.2 to 15V doesn't it?
Or you could have up-down buttons if you have spare legs?
Yes, you have to create a straight line formula that translates the input of 0v~5V into an output of 1.25V~5V

This translates into

w1 = w1 * 29/86 + w1 - 345

This will give excellent precision.
 

Mycroft2152

Senior Member
Since this thread is reaching Nesbit levels, how about a posting of exactly where it is, including circuit and software?

Perhaps with that info, someone might run this through VSM.

Myc

PS: Yes Dippy the pot is superfluous, since you are only reading the pot and converting the value to PWM. Buttons would work.
 
Last edited:

BCJKiwi

Senior Member
Further test - sensing Vout

Moved to a larger breadboard and a 7805 regulated 5V supply.

Added line
w1 = w1 min 255
else code as used in last test;
Code:
#picaxe 08M
setfreq m8
main:
readadc10 4,w1 ;read sensor input voltage (Vin)
w1 = w1 min 255
adjust:
readadc10 1,w2 ;read output voltage (Vout)
if w1=w2 then main ;skip if no adjustment required
if w1>w2 then increase
decrease:
high 2 ;set pin2 high to decrease Vout
input 2 ;tri-state pin2 and hold Vout
goto adjust
increase:
low 2 ;set pin2 low to increase Vout
input 2 ;tri-state pin2 and hold Vout
goto adjust
Added line resolves runaway at bottom end Min Vout is 1.263V
Response has improved to around 2 secs for a large step change. Tried reducing Cap from 0.5 to 0.33uF with no noticeable change in response.
Regulation is good under light load but sags when load applied.
No load - Vin 5.06 Vout 2.50V
19.4R - 2.44V
14.7R - 2.42V
10R - Vin 4.96V - Vout 2.39V - i.e nominal 0.5A off a 1A regulator

The Vout sag is 0.11V and the Vin sag is 0.1V so the sag is coming from the supply side but would have expected the Vout to be raised to compensate. I guess the good old ReadADC reference voltage is coming into play (as the 08M is fed from the same supply in this test).

Adding a pause 5 (2.5ms @8mHz or pause1 @4mHz) improved response time to a satisfactory rate and has much more effect than changing the Cap from 0.5 to 0.33uF.
Min 250 is the lowest setting value that prevents runaway and Vout is 1.24V, also added Max 900 to stop runaway at the high end.

Code:
'08M voltage regulator
'Wapo and others
'
'                      +-+---- V+
'           +-----+    | |
'08M Leg3 --+ 10k +--->| | 10k Pot
' (ADC4)    +-----+    | |
'                      +-+---- V0
'
'
'           +-----+
'08M Leg6 --+ 10k +---------------------------+
' (ADC1)    +-----+                           |
'                       Leg3+---------+Leg2   |
'               Vin---------+ LM317T  +-------+--+ Vout
'                           +----+----+       |  |
'                            Leg1|            |  |       
'                            Adj |  +------+  |  |
'                                +--+ 240R +--+  |
'                                |  +------+
'                                |               LOAD
'                     +--0.47uF--+
'                     |          |               |
'                     |          |Drain          |
'           +------+  |  Gate+---+----+          |
'08M Leg5 --| 470K |--+------+ IRL520 |          |
'           +------+         +---+----+          |
'                                |Source         |
'                                |               |
'                                |               |
'                                0V              0V
'
Code:
#picaxe 08M
setfreq m8
main:
readadc10 4,w1 ;read sensor input voltage (Vin)
w1 = w1 min 250 max 900 ' Min gives 2.24Vout , Max gives 4.45Vout
adjust:
readadc10 1,w2 ;read output voltage (Vout)
if w1=w2 then main ;skip if no adjustment required
if w1>w2 then increase
decrease:
high 2 ;set pin2 high to decrease Vout
Pause 5 '2.5ms @ 8mHz
input 2 ;tri-state pin2 and hold Vout
goto adjust
increase:
low 2 ;set pin2 low to increase Vout
pause 5 '2.5ms @ 8mHz
input 2 ;tri-state pin2 and hold Vout
goto adjust
 
Last edited:

hippy

Technical Support
Staff member
@ BCJKiwi : Excellent. That at least proves (1) and (2) and goes someway towards (3) albeit at 5V.

I wouldn't be particularly worried about a 0.1V sag at this point. That's ~100mA drawn so it would be interesting to see how bad the sag is at 1A ( or more, not sure of the LM317/LM318 limites ). I also wouldn't be too worried about ripple or tracking speeds, that can all be tightened up once we've moved up to a higher Vin and Vout.

My next move if I were doing this would be to jack Vin up to around 15V..20V.

A thought on the circuit ( bearing in mind I don't understand exactly how the LMxxx operates to set it's Vout ) - would/could things improve with the cap between Gate and Vin ?
 

BCJKiwi

Senior Member
Just tried the circuit modified to sense in the Adj pin (still all at 5V)

Code:
'
'                      +-+---- V+
'           +-----+    | |
'08M Leg3 --+ 10k +--->| | 10k Pot
' (ADC4)    +-----+    | |
'                      +-+---- V0
'
'
'                       Leg3+---------+Leg2
'               Vin---------+ LM317T  +-------+--+ Vout
'                           +----+----+       |  |
'                            Leg1|            |  |       
'           +-----+          Adj |  +------+  |  |
'08M Leg6 --+ 10k +--------------+--+ 240R +--+  |
' (ADC1)    +-----+              |  +------+
'                                |              LOAD
'                     +--0.47uF--+
'                     |          |               |
'                     |          |Drain          |
'           +------+  |  Gate+---+----+          |
'08M Leg5 --|  1M  |--+------+ IRL520 |          |
'           +------+         +---+----+          |
'                                |Source         |
'                                |               |
'                                |               |
'                                0V              0V
'
Code:
#picaxe 08M
setfreq m8
main:
readadc10 4,w1 ;read sensor input voltage (Vin)
'w1 = w1 min 250 max 900
w1 = w1 max 900
adjust:
readadc10 1,w2 ;read output voltage (Vout)
if w1=w2 then main ;skip if no adjustment required
if w1>w2 then increase
decrease:
high 2 ;set pin2 high to decrease Vout
pause 1 '0.5ms @8mHz
input 2 ;tri-state pin2 and hold Vout
goto adjust
increase:
low 2 ;set pin2 low to increase Vout
pause 1 '0.5ms @8mHz
input 2 ;tri-state pin2 and hold Vout
goto adjust
Found the Min 250 had to be removed to get the Voltage down to the lower limit (of 1.237V. There is no loss of control at the low end!

No Load
control and stability form 1.235V to 4.45V.

1.2mA load (LED with 330R)
Voltage maxes out at 3.4V and control is lost.

0.5A Load
At any setting above around 2.5V a ripple develops with a period of about 10ms with the drop lasting around 2ms. As the voltage is adjusted higher the base of this drop moves down to 2.3V while the flat top maxes out at 3.0V. DMM reads around 2.8V. Control is lost aat the top end.

As the LM317T has a current rating of 1.5A and the frequency is way too low the issue would appear not to be in the LM317T.

Moved the CRO to the adjust pin and then to Leg5 with the DMM on the output.
The CRO reads a change (while adjusting) from 0V to Vout (as might be expected since there is no real current flow along this path as the ADC port has high impedence. The CRO sees the same ripple effects as it does when connetected direct to Vout.
So it seems that the MOSFET is unable to do its job with this circuit.

I don't have an answer for this at present and am not sure where to look. Have tried at 4 and 8mHz, have tried longer and shorter pauses. Have tried increasing the Cap to 1uF and have tried reducing the 1M to 470K and the 10k down as low as 2k2 but none of these changes seem to make any difference to this behaviour.

At this stage I would have to assume the issue is around the timing/switching characteristics of the MOSFET and an interaction of the ADC circuit with the MOSFET circuit.

So it would appear there is more promise in sensing Vout than trying to sense changes in the adjust voltage as this ADC circuit is independent of the Adj control circuit.
 
Last edited:

Mycroft2152

Senior Member
Hmm, just a thought.

If you look at Wilf's original circuit, the 0-5volt output is taken (referenced) after a 300 ohm pullup to 5 volt source. In effect, the FET is the bottom half of a voltage divider. In your latest circuit, you are referencing to a variable voltage source. So you have a voltage divider that ultimtely effects the "top" reference voltatge of itself. A type of a Mobius loop.

Bring it back a notch, Have you tried Wilf's circuit without the feedback of sensing the output on the LM317, just to see if you can just control the output voltage with the PICAXE. Does it work with 5 volts? 15 volts?


Myc
 

BCJKiwi

Senior Member
@ Mycroft,
I have not been able to locate Wilf's original circuit unless it is the one posted by Wapo in this thread.

However that circuit does not use a Regulator chip so is not directly applicable as far as I can see. The MOSFET is already in a divider circuit with the 240R

Have moved back to testing sensing Vout.

Have tried a 10k/10k divider from Vout to 0V with the centre point taken to ADC1 with a further 10k in line.

No Load
This works well and is entirely stable up to 10V (with 11V feed to the LM317T)
This does raise the issue of how to limit the voltage to the ADC port when using a higher supply to the LM317T as control and output range depends on the max Vout possible, the divider selected and values chosen in the program for ADC. With 12V on Vin, and a 10k/10k divider, it would be possible to oversupply the ADC port.

With 0.5A load at 5Vout, the regulation is good as long as Vin is high (11.5V) If Vin is 8V and Vout say 5V, then Vout drops to 4.6V when 0.5A load applied.

Code:
'
'                      +-+---- V+
'           +-----+    | |
'08M Leg3 --+ 10k +--->| | 10k Pot
' (ADC4)    +-----+    | |
'                      +-+---- V0
'
'
'           +-----+
'08M Leg6 --+ 10k +---------------+
' (ADC1)    +-----+               |
'                                 |
'                        +-----+  |  +-----+
'               0V  -----+ 10k +--+--+ 10k +--+
'                        +-----+     +-----+  |
'                                             |
'                                             |
'                       Leg3+---------+Leg2   |
'               Vin---------+ LM317T  +-------+--+ Vout
'                           +----+----+       |  |
'                            Leg1|            |  |       
'                            Adj |  +------+  |  |
'                                +--+ 240R +--+  |
'                                |  +------+
'                                |               LOAD
'                     +--0.47uF--+
'                     |          |               |
'                     |          |Drain          |
'           +------+  |  Gate+---+----+          |
'08M Leg5 --|  1M  |--+------+ IRL520 |          |
'           +------+         +---+----+          |
'                                |Source         |
'                                |               |
'                                |               |
'                                0V              0V
'
Code:
#picaxe 08M
'setfreq m8
main:
readadc10 4,w1 ;read sensor input voltage (Vin)
'w1 = w1 min 250 max 900
w1 = w1 min 125
adjust:
readadc10 1,w2 ;read output voltage (Vout)
if w1=w2 then main ;skip if no adjustment required
if w1>w2 then increase
decrease:
high 2 ;set pin2 high to decrease Vout
pause 1 '1ms @ 4mHz 'pause 5 '2.5ms @8mHz
input 2 ;tri-state pin2 and hold Vout
goto adjust
increase:
low 2 ;set pin2 low to increase Vout
pause 1 '1ms @ 4mHz 'pause 5 '2.5ms @8mHz
input 2 ;tri-state pin2 and hold Vout
goto adjust
 

hippy

Technical Support
Staff member
@ Mycroft,
I have not been able to locate Wilf's original circuit unless it is the one posted by Wapo in this thread.
From the earlier discussion I believe it is the same.

This works well and is entirely stable up to 10V (with 11V feed to the LM317T). This does raise the issue of how to limit the voltage to the ADC port when using a higher supply to the LM317T as control and output range depends on the max Vout possible, the divider selected and values chosen in the program for ADC. With 12V on Vin, and a 10k/10k divider, it would be possible to oversupply the ADC port.
That over-voltage may not be a problem, it is current limited by the 10K to READADC and 10K in the top of the voltage divider. The worst which should happen is that the READADC will max out but no damage done - That's my guess, not fact.

Maybe I've misunderstood but is there a reason the divider has to be 10K/10K ? That would limit output control to 10V.

One thing to bear in mind for later, is if powered say from 20V giving 0V to 15V output, when used for 3V3 or 5V output that's a lot of voltage dropped by the LM317 and at higher current an awful lot of heat. A heatsink is absolutely necessary, but better is a dual tap supply ( the more taps the better ). These taps can be relay switched and diode mixed so the lowest Vin is chosen to suit what Vout would be.
 

Dippy

Moderator
Hey, good stuff, sounds like you're nearly there.

Couple of questions:

1. "With 12V on Vin, and a 10k/10k divider, it would be possible to oversupply the ADC port."
- The 'feedback' 10K/10K pot-div. That is connected to Vout ---pot/div---Gnd, yes? What's it got to do with the Input V? You are measuring Vout aren't you? You will specify an output voltage e.g. "BCJ's 15V variable regulator" so you just use resistors to suit 15V. e.g. 10K-4K7 and do some simple calcs in code.

(Obviously you will have to supply , in this example, 15V + Vregdropout + a bit for luck + if its a transformer some calcs for bridge rectifiers and transformer load regulation.)

2. You say it drooped on-load when Vsupply was 8V. Was that a droopy supply? You didn't say how much the 8V drooped with the 500mA load. If it drooped a lot then o/p droop could be affected by the regulator's dropout which could be a couple of volts on load.
 

wapo54001

Senior Member
Mycroft:

The 300 ohm pullup in the original circuit is part of the circuit I was trying to control, not part of the 08M control circuit. I needed a means to control voltage on an input that consisted of a 300 ohm pullup to 5V.

Later, to control other circuits that did not include the 300 ohm pullup, I replaced it with a 10K pullup to +5 and it worked equally well.

It's certainly true that you need a voltage for the mosfet to work against, but it can be a very small current as far as the mosfet control is concerned.

BCJ:

The first circuit I posted is Wilf's original circuit.

I've also been playing with this circuit, but having less luck than you have had in making it work, but I jumped directly to 24V in. I am going to replace the fixed 24V supply with a variable supply and go back and start at 5V and work my way up as you have done.

Some thoughts:

The 1meg resistor is not writ in stone, wonder if the circuit would be more responsive with a 100K or even a 10K there? This would in effect increase the voltage change per loop of the adjust code because the capacitor would charge/discharge faster. I think the size of the capacitor does not matter much within reason, but the larger the capacitor, the longer you can wait between adjust cycles, so you reduce the longevity of the gate voltage by reducing the size of the capacitor. Is there a down side to reducing the 1meg value?

I know virtually nothing about mosfets, so did some reading and found that mosfets are designed differently for different purposes -- to switch efficiently or to maximize the linear range (as in audio applications). The 2N7000 is definitely a switch, as is the IRL520. I wonder if better performance could be achieved with a mosfet that is designed primarily as a variable resistor -- ie an audio mosfet? I think we're looking for a mosfet with "lateral structure" instead of "vertical structure" and right now we're using "vertical structure" mosfets in this circuit.

My memory of the 317 application notes is that the R1/R2 resistor values are important not for setting the voltage, but because if the proper current flow does not happen, then regulation suffers. The 240 ohms is selected to insure proper current flow, but I've seen at least one circuit where R1 was 120 ohms. I am wondering if the value of R1 should not be changed for this circuit, since regulation is somehow suffering. Not sure what that would look like, but something to consider.
 

Mycroft2152

Senior Member
Take a look the remote sensing circuit form the LM317 datasheet to see how an op amp is used for feedback to adjust the regulated voltage.

Note the resistors used.

Myc
 

Attachments

BCJKiwi

Senior Member
Try to answer some of the Qs above since my last post;
@Hippy
1. The over voltage concern is that if there is say 18V Vin for a 15V supply , then if at any time (including switch-on) Vout rises above 15V and there is a 2:1 divider limiting ADC1 input to 5V, then ADC1 will see in excess of 5V.
A 5.1 Zener should fix this.
2. 10k/10k is me just taking baby steps. Bench supply at 13+ V, and careful adjustment of setting to ensure ADC1 did not exceed 5V.
Can see no reason why this cannot be scaled to wherever you like.
3. Been thinking about the classic bench supply where you can switch between ranges. There are a few things to consider;
a. when the range changes, the divider values need to change to match.
b. Also the offset at the bottom of ADC4 needs to change as well. e.g. for a 5V range, the 1.25V minimum Vout represents 250 on readadc10. for 10V out, the ADC1 is divided by 2 so the 1.25V minimum Vout appears as 0.625V on the setting side (ADC4) so the minimum ReadADC10 4 value has to be adjusted down to 125.
c. the use of MIN is not a good way to do this as it creates a dead zone on the bottom end of the pot. Adding 125 (or whatever suits the voltage range) works better but then the top level needs to be scaled back to a max of 1023 ~ formula used now (for a 1:1 divider Max Vout10V) is w1 = w1 * 50 / 8 * 7 / 50 + 127 - see code below.
3. Yes there is plenty of heat. Things were getting pretty warm (read hot) on the LM317T at 5Vout and 0.5 load (TO-220 no heat sink). The data sheet graph shows things should be stable and current delivered OK provided Vin - Vout < 12.5V. Minimum current rating is 1.5V but this reduces once Vin - Vout exceeds 15V to a low of 300mA at Vin - Vout = 40V (TO-220 with heatsink).

@Dippy
1. see 1. above
2. No not a droopy supply (bench supply). It seems to have a lot to do with sensing Vout and how the control circuit behaves when there is insufficient voltage. One of the reasons I stepped back to a 10V range was that nothing seemed to be working on a 15V range - all to do with the setting vs the feedback and the control circuit.

@Wapo,
1. Agree on the 1M and 0.47uF. Figure they could be revised down as I figure this is where the lack of response comes from - just takes too long to charge/discharge the gate voltage. Have not fiddled with this too much yet - want to keep things stable until the bigger points are resolved - the old philosophy of only change one thing at a time! Had previously tried 0.33uF and 470K without any significant change in response.
1/1023 represents 0.015V on a 0 - 15V Vout. With an 8mHz clock a relatively short persistent setting is not a big issue as it could theoretically be tweaked up/down by 0.015 every cycle of the program if necessary. Experimentation required to find the optimum trade off between adjustment response and stability.
2. Don't see need to change R1. Regulation only seems to be an issue if Vin does not have enough capacity (V or A).

@Myc,
Don't have that circuit on the National LM117/317 data sheet. It seems that is a significantly different circuit relying primarily on sensing the 300mV drop across the low value resistor in the Vout line. Not sure how applicable that would be to the present circuit.


Where to from here?
A.
It would appear (if the data sheets are correctly interpreted), that;
Vin - Vout should be =< 12.5V to avoid heat increase and current reduction issues.
1.2 to 1.25V is the minimum Vout.
To be certain of good regulation Vin should be => Vout +3V. Dropout is not specifically stated in the datasheet but all tables and examples show Vin 3V higher than Vout.
So,
1.2 + 12.5 = 13.7V
13.7 -3 = 10.7V
This means a Vin of 13.7 could provide a stable 1.25 thru 10.7Vout supply at full current capacity and stability without need for taps/switches etc.

B. Refine input ADC4 formula
C. Refine Gate circuit for response and stability
D. Provide protection for ADC1 (Zener?)
E. Verify if there are any transients at power up and mitigate (e.g. there is a slow turn on circuit in the LM317 datasheet)
F. If > 10Vout is required, develop a dual supply Vin (and Vout) system with ranges from, say,
Vin 13.5V. Vout 1.25 to 10.5
Vin 23.0V. Vout 10.5 to 20.0
To get some overlap,
3 steps(ranges), increase Vin and suffer some current capacity reduction/heat increase, or, accept a lower max than 20V.

On point E.
Vin 13V, Vout set at 5.0V
If the 08M is turned on first and LM317T turned on second, Gate & Vout rise from 0 to the set point at the response rate of the gate circuit.
If the 08M is turned off, and LM317T is left on, ADC1 drops to 1.25V, and Vout rises from 5V to an indeterminate voltage (different values on different tests gave 7 thru 9V) then floats around this level seemingly indefinitely.
With LM317T left on and 08M turned back on, ADC1 rises to the divider value of the current Vout (7 to 9V) i.e. in the test circuit with a 10k/10k divider to 3.5 ~ 4.5V at turn on and then drops along with Vout to set point at the gate circuit rate.

So there seems to be no 08M damaging effects but there is an issue with Vout rising. Presumably this occurs as there is effectively no path to 0V for the Adj circuit as the MOSFET goes to Max R with 0 Gate V.

Present Circuit / Program;
Code:
'                      +-+---- V+
'           +-----+    | |
'08M Leg3 --+ 10k +--->| | 10k Pot
' (ADC4)    +-----+    | |
'                      +-+---- V0
'
'
'           +-----+
'08M Leg6 --+ 10k +---------------+
' (ADC1)    +-----+        _      |
'                     5.1|\ |     |
'               0V  -----+ >|-----+
'                        |/ |_    |
'                                 |
'                        +-----+  |  +-----+
'               0V  -----+ 10k +--+--+ 10k +--+
'                        +-----+     +-----+  |
'                                             |
'                                             |
'                       Leg3+---------+Leg2   |
'               Vin---------+ LM317T  +-------+--+ Vout
'                           +----+----+       |  |
'                            Leg1|            |  |       
'                            Adj |  +------+  |  |
'                                +--+ 240R +--+  |
'                                |  +------+
'                                |               LOAD
'                     +--0.47uF--+
'                     |          |               |
'                     |          |Drain          |
'           +------+  |  Gate+---+----+          |
'08M Leg5 --|  1M  |--+------+ IRL520 |          |
'           +------+         +---+----+          |
'                                |Source         |
'                                |               |
'                                |               |
'                                0V              0V
'
Code:
#picaxe 08M
'setfreq m8
main:
readadc10 4,w1        'read sensor input voltage (Vin)
w1 = w1 * 50 / 8 * 7 / 50 + 127
'with Vout=10V, ADC4 input adjusted between range of 1.25V/2 to 10V/2
'*50 & /50 improve integer math accuracy (1023/8*7+127=1016 ~ 1023*50/8*7/50+127=1022)  
 
adjust:
readadc10 1,w2 ;read output voltage (Vout)
if w1=w2 then main ;skip if no adjustment required
if w1>w2 then increase
decrease:
high 2 ;set pin2 high to decrease Vout
pause 1 '1ms @ 4mHz 'pause 5 '2.5ms @8mHz
input 2 ;tri-state pin2 and hold Vout
goto adjust
increase:
low 2 ;set pin2 low to increase Vout
pause 1 '1ms @ 4mHz 'pause 5 '2.5ms @8mHz
input 2 ;tri-state pin2 and hold Vout
goto adjust
 
Last edited:

hippy

Technical Support
Staff member
3. Been thinking about the classic bench supply where you can switch between ranges. There are a few things to consider;
a. when the range changes, the divider values need to change to match.
b. Also the offset at the bottom of ADC4 needs to change as well. e.g. for a 5V range, the 1.25V minimum Vout represents 250 on readadc10. for 10V out, the ADC1 is divided by 2 so the 1.25V minimum Vout appears as 0.625V on the setting side (ADC4) so the minimum ReadADC10 4 value has to be adjusted down to 125.
a) You should be able to get away with a fixed divider. 10V over 1024 steps is ~0.01V per step which should still be good enough right down at the low end. Even at 20V it's still 0.02V.

b) ADC4 the pot should be equally as good as is, especially if it's 'being clever' and a min-max range is set in software. Even if min-max is set 0-20V then that's still 0.02V per ADC step. While currently dividing, it should be possible to minimise loss of resolution by multiplying everything up first.

The real beauty of the PSU design is its simplicity. The base model should be simple dividers ( no switching ), minimal component count, any complexity being in the software. So I'd go with slightly clunky control to start with, get the hardware working then optimise the software later.

One thing to get more accurate tracking resolution of Vout would be a divider which can handle 15V another which can handle 6V and then select which to use in an auto-ranging way. As long as current limiting protects the ADC hardware from damage it will be work.

PS : I'd put any zener across the ADC pin not anywhere else. That will reduce any adverse effects of clamping. I'd still go with not even fitting the zeners because the over-voltage is current limiting.
 
Last edited:

BCJKiwi

Senior Member
Agree simple is best.
To keep the LM317T in a good operating region, if the output is above 10.7V, then Vin needs to be switched to a higher voltage.
Without switching to a higher Vin, current capacity, regulator efficiency and regulation all suffer progressively.
There is a spare input in3 at Leg4 which could be used to detect the changeover and apply the new formula. Presumably switching could be done by multi-pole relay or whatever to switch transformer taps to get new Vin supply, switch divider resitors into circuit and provide a high to in3 to change formula.

Provided PICAXE supply is derived from Vin (via a 7805 or similar regulator), then PICAXE and LM317T turn on/off together. This eliminates the floating High Vout ~ tested this and there appears to be no spikes at turn-on.
 

Mycroft2152

Senior Member
@Myc,
Don't have that circuit on the National LM117/317 data sheet. It seems that is a significantly different circuit relying primarily on sensing the 300mV drop across the low value resistor in the Vout line. Not sure how applicable that would be to the present circuit.[/code]
The diagram is from Linear's version of the LM117/317. see attached.

The diagram shows a successful method to inject a voltage into the sensing leg to adjust the output voltage.

What you have on the other side of the op amp is arbitrary.

Sounds like the basis of a working adjustable power suply to me.

Myc
 

Attachments

Last edited:

Mycroft2152

Senior Member
I understand the theory of tusing an FET as a resistor.

The question is, "Have you done the calculations to define the "effective" resistance values needed, AND have you found an FET that will match?"

As mentioned previously, the 2N7000 is a switching FET and has a sharp curve.

Myc

Definitely, NESBIT proportions, this is post #100
 

Dippy

Moderator
Darn! I wanted #100! No doubt it'll get to 200.

I wasn't aiming the link at you Myc. I know you know. It was for others.

And yes I agree, the designer should get a handful of different FETs and Data Sheets for this project for good reasons.
 

BCJKiwi

Senior Member
Not sure that the characteristics of the MOSFET are all that critical - provided of course it is a logic level device. The beauty of this circuit is that the program adjusts (and holds) the gate voltage where it needs to be and does this in a continuous fast loop. Maintaining the appropriate resistance is all that is required.

Quicker response would come from a steeper resistance rise but more stability and precision would come from a shallower rise.

When it is considered that these logic level MOSFETs go from sub 2R to 10s of Mohm (using off leakage current as a guide to off resistance) with a gate change of 1 to 2V then how significant would the difference between different logic level MOSFET be?

As I did not have, and could not readily source a 2N7000, I just used what was to hand - a power MOSFET IRL520.
Comparing the MOSFETs;

2N7000 low power Switching MOSFET - for low power application in the original design
RdsOn = 1.2 ~ 1.9 depending on load and temp
zero gate voltage drain current 1uA == Megohms R
Gate threshold ~ 2.1V
Turn on time 10~20nS, turn off time 10~20nS

IRLZ14 Power MOSFET (Wilf's alternative to the 2N7000) - for high power application in the original design
RdsOn = 0.2 ~ 0.8 depending on load and temp
zero gate voltage drain current 25 ~ 250uA == Megohms R
Gate threshold 1 ~ 2V
Turn on delay 20nS / rise time 110nS, turn off delay 17nS / fall time 20ns

IRL520 Power MOSFET (as tested in above circuit)
RdsOn = 0.23~0.27
zero gate voltage drain current 250uA == Megohms R
Gate threshold ~ 2.9V (absolute Max 4V)
Turn on delay 10nS / rise time 50nS, turn off delay 20nS / fall time 26ns

These are significantly different devices and the IRL520 would at first sight seem to be a bad choice but works OK, if a bit sluggish.
Wilf's original circuit suggested a 2N7000 or an IRLZ14. The IRLZ14 is a power mosfet but has control characteristics closer to the 2N7000.

It should also be remembered here that in the original design, the load was supplied directly through the MOSFET and as such the MOSFET characterisitcs were much more important as the load was being passed through a partially on MOSFET.

The designs in this thread use the MOSFET to control the ADJ current of the regulator which is in the order of 50uA at the output Voltage level. Accordingly the smallest MOSFET should be up to the task.
 
Last edited:

boriz

Senior Member
The LM317/338 is redundant.

Using the tristate system indicated and ADC feedback, you can generate a stable and digitally adjustable DC voltage. Put a power transistor on the output and you have a complete digitally regulated PSU. Add an OP-AMP and you can have any output voltage range you want.

I think the oscillation problem may have been caused by the two regulator systems fighting each other.
 

Mycroft2152

Senior Member
Careful Boriz, some people cannot see the forest through the trees.

The original project was to simply use a FET as a microprcessor controled resistor.

myc
 
Last edited:

BCJKiwi

Senior Member
@Boriz,
correct but with the M317T (or any other similar regulator) you get
1. the bonus of a chip designed for the regulation task including features such as "Included on the chip are current limit, thermal overload
protection and safe area protection. All overload protection circuitry remains fully functional even if the adjustment terminal is disconnected."

2. Load is not being passed through a partly turned on MOSFET which would presumably heat rapidly if the load was high.

Same old story - alternative designs, user's choice to suit the application!
Anyway, its been a useful learning experience.
 
Last edited:

boriz

Senior Member
All linear regulators regulate the output current with a partially turned on transistor. They get exactly as hot as any BJT or FET or resistor would get with the same current and voltage drop. P=VI.

Two regulators are not only unnecessary but counter productive. One will continually ‘upset’ the other. The problem is the addition of feedback to the AXE. Without it, it’s just a ‘provider of a digitally adjustable reference current’. Which is exactly what is required here I think. Note: The adjust pin does not require a voltage, but a current.

FETs are frequently used as adjustable resistors in stabilisation, modulation and AGC roles. But it’s not an easy design problem. Bit of a dark art if you ask me. For this reason and others, I favour the PWM LDR solution. (Though I really do like that nifty tristate code. One for the archive.)
 

BCJKiwi

Senior Member
@Boriz,
Well I'm confused - yeah I know it's easy to do.
From my recent post (2 before this one);
"The designs in this thread use the MOSFET to control the ADJ current of the regulator which is in the order of 50uA at the output Voltage level. Accordingly the smallest MOSFET should be up to the task."

There have been two approaches to controlling a regulator in this thread, one trying to sense the adj voltage (which seems to have died), and the other, sensing the regulator Vout which seems to work. In both cases the MOSFET is controlling the Adj currrent as per the original request from Haxby. The tests I did used an LM317T but would be applicable to the higher rated LM338 that Haxby has. The MOSFET does not "upset" the LM317T - it simply acts as the adjustment pot does in all the standard application circuits.

As to the option of just doing it all with the MOSFET - this has not been tested. The sample circuit (originally from Wilf and discussesd/modified by Wapo), has a 300R in the load line as this was the requirement.

What would you propose as a circuit for the target 0 to 15V 3Amp PICAXE adjustable regulator that was the original request from Haxby in this thread? Have you tested and used such a circuit?
 
Last edited:

Dippy

Moderator
Whilst Boriz's suggestion is perfectly valid, I think we're nearly broaching two different subjects.

Of course a design like this could be used with a BJT, but in THIS design the PICAXE/MOSFET combo is simply doing the 'overall' voltage control and the LM317 regulator is doing the nitty-gritty load-related regulating.

A PICAXE/MOSFET/BJT would NOT be fast enough to perform the complete regulating task. It would be far too slow to regulate for significant transients. So, in the circuit discussed so far the 'fast' job is done by the regulator and the 'bulk' changes are done by the PICAXE/MOSFET i.e. the 'slow' output voltage adjustments and MOSFET drift.
I'm impressed its as good as it is so far.

PS. The LED/LDR combo worked fairly well on a thing I made some time ago using a Simple Switcher and it worked a treat. Though the LDR did show tempco drift and constantly needed compensating for though thats no big deal. Anyway I merely mentioned that as it is an option to replace the MOSFET with a pwmed LED/LDR optocoupler as I mentioned about 300 posts ago.
 

hippy

Technical Support
Staff member
Just echoing what BCJKiwi and Dippy say - Most PSU's include 'some logic', a 'high power drive' which delivers the output and a 'low power drive' which controls the high power drive. In this instance the PICAXE is the logic, the LM317 is the high-power drive and the MOSFET just the means to tell the LM317 what to put out.

This could be used in a non-feedback manner quite successfully if calibrated.

Adding the feedback loop simply removes the need for calibration and allows adjustments to be made on the fly. I don't see this and the LM317 fighting each other it's more like moving from a system where a teacher tells a learner driver to go at a certain speed and hoping they do to actually looking at the speedo and telling them they need to go a little faster or a little slower.

There's a potential for such a system to go into oscillation but in this case it's the teacher's foot on the accelerator so they're really doing all the work. The feedback loop is to watch the speedo and adjust the pedal when they hit a hill, going up or down an incline.
 

Dippy

Moderator
Haha. Thats a nice analogy.
Though a feedback loop is handy if its a hot day and the Learner starts losing concentration and slowly drifts over the speed limit.
I'm sure the tempco of Learner Drivers varies but it still exists.

(You should be a teacher hippy. And if you grew a beard and had a tweed jacket with leather elbow patches you could do the Geography lessons too :) . As for me, I'll just stick to selling ice-creams.)
 

BCJKiwi

Senior Member
@Dippy,
This tempco thing:- Since we have a feedback loop that is able to continually adjust Vout far more quickly than any temp change would effect Vout (presuming of course the LM317T component is working within normal limits), isn't that effect taken care of?

Anyway I thought you had come to that conclusion back in post #80 - so looong ago!
"Yes, good points and I just realised this method intrinsically compensates for temp drift anyway. So unless Rds goes out of bounds it looks like a winner."
 
Last edited:

Dippy

Moderator
BCJ: "Tempco thing":-
Yes I know. I was just re-iterating..ting...ting because hippy said "This could be used in a non-feedback manner quite successfully if calibrated."

All soooo long ago..... as you say. Job done yet?
 

BCJKiwi

Senior Member
Job done yet?
Well I have a bench supply and no immediate application for this circuit so since I figured I had proven the concept and tested it under load, monitored it with a CRO on the ADC1 and Vout, checked for undesirables on switch on/off, with PICAXE supply on/off ,with Vin on/off, with PICAXE and Vin on/off together, and all seems safe, that I had done my bit.

Stripped everything off the breadboard this afternoon.

If nothing else earth shattering arises, I guess the last working post could be tidied up a bit and copied over to the sample projects.
 
Last edited:

Dippy

Moderator
I know what you mean.

A "I have no use for it but I'm darn well going to prove the idea" project.

I wonder if Haxby ever tried it or has fallen asleep...?

I wish I could 'seed' the Forum for a design and sit back and watch :) (Just kidding).
 

wapo54001

Senior Member
BCJ,

I hadn't realized that you had a fully functional circuit going? I thought there were limits, that it only worked in the middle of the range? I have tried to modify one of my cards that uses the original circuit and have had no luck. Something I'm not noticing, but it doesn't work as modified.

I've been wondering about the difference between the "new" circuit and the original. The one component that my original 5v circuit has and this does not is the (take your pick) 300 or 10K pullup resistor. I was wondering, as a trial, about connecting a 10K between input and adjust pins on the 317 to work as the pullup does in the original circuit for the2N7000. If it does in fact help, I guess ultimately you would have to switch to a nice regulated supply for that 10K to work with.

Do you think the 10K there would help the mosfet do its job? The thing is, with the original circuit, it just worked perfectly with no muss or fuss. Your modified circuit seems a bit picky re resistor values, etc.

Aside from that, would it be worthwhile to use an 'analog' grade mosfet manufactured with the lateral region instead of the vertical region like a switch mosfet?

PS What is/are NESBIT???
 
Last edited:

hippy

Technical Support
Staff member
So, in conclusion ... we have a circuit designed with an LM317 which if fed from say 20V can be controlled by a pot connected to a PICAXE which can variably deliver anything from to 1.25V to near 20V when turned from fully anti-clockwise to fully clockwise ?

This is proven proof-of-concept so obviously the control program can be improved upon and have functionality added but this workable bare-bones which does the job ?

It would be nice to put that circuit and the basic control program which does it in the Finished Project section.
 

hippy

Technical Support
Staff member
PS What is/are NESBIT???

Nesbit is a rabbit, upon whose grave stone will be written, "Here lies Nesbit. RIP". Next to the grave will be a bunch of flowers, a Rabbit Locating Device, and a ream of paper covering a debate on how to build a Rabbit Locating Device :)
 
Top