2

Can anyone assist me to make a power supply whose output voltage will be controlled by an Arduino, with the latest voltage setting automatically saved in non volatile memory?

I am in an OJT (On the Job Training Scheme). I was given a task to make a Arduino controlled voltage variable power supply whose outputs can be switched between several preset values using pushbutton control. It's like switching between two different outputs when a designated button is being pushed.

Here is what I have done so far. I made an LM317 based power supply with the output voltage controlled by a potentiometer. I followed this youtube tutorial. It works well but I was ask to upgrade it.

Instead of using a potentiometer to adjust the voltage, I wish to use switching buttons to choose between two or more preset voltage levels. Each switch buttons have their corresponding voltages.

This link may also be relevant.
Code is given below the circuit diagram.
ARDUINO AS A POWER SOURCE ALTERNATOR

7
  • I suggest that you make sure that your words mean what you intend. The example (via link) that you gave switches between two batteries. An "Alternator" is an "AC Generator" a rotating electromechanical machine used to turn mechanical energy into electrical energy.An Alternator regulator is a device which controls the output voltage (usually) of an alternator. If you wish to swap between two batteries alternately you want a program controlled battery selector with selected-battery stored in memory. May 5 '15 at 10:36
  • @RussellMcMahon - Yes I need a program that swaps two different power source.
    – April Cyra
    May 5 '15 at 14:18
  • @RussellMcMahon It's a simple adjustable power supply and I've made one. I followed this youtube tutorial [link] (youtube.com/watch?v=F-ahtojVl4M). It works well but I was ask to upgrade it, instead of using a potentiometer in adjusting the voltage, he suggest to have a swicthing buttons which I can swap two or more power sources automatically. Each switch buttons have their corresponding voltages. Can you help me figure out how to apply it maybe by using an arduino?
    – April Cyra
    May 5 '15 at 14:35
  • AC - I have extensively rewritten your question based on the original plus what you said in comments.I did this because the words you were using gave a wrong impression of what you say that you want to achieve. If you do not like my edits please modify them. I could easily provide an answer BUT it is useful to see what other people say. May 6 '15 at 5:22
  • @RussellMcMahon Thank you for editing the question. I appreciated what you've done. That was exactly what I am supposed to ask.
    – April Cyra
    May 6 '15 at 5:51
5

If you want to output preset voltage levels in distinct steps, rather than an 'analogue' range from X volts to Y volts, then the answer is in the datasheet for the LM317:

Figure 57. Digitally Selected Outputs

Connect each of the INPUTS through a 1k base resistor to your Arduino pins. Selecting different values for all the resistors will of course allow you to vary Vout by turning each transistor on or off, by themselves or together. You can use any standard transistor: 2N3904, 2N2222, BC548, etc., but I might elect to use a (low power) MOSFET like a BSS138 instead (and omit the base resistor). Of course you can use add more resistor/transistor lines if you want more output options. I recommend using R2 so that Vout is always limited, otherwise - if Vin is quite high - you may damage whatever Vout is powering due to some runaway voltages.

Calculating resitor values is your mathmatical challenge. If you really apply some brainpower you can change Vout in linear steps with minimal Arduino pin usage:

'Input' states            Vout
  A  B  C  D            (/volts)
  0  0  0  0              5.00  [Vmax set by R2]
  0  0  0  1              4.75
  0  0  1  0              4.50
  0  0  1  1              4.25
  0  1  0  0              4.00
   ...  ...                ..
  1  1  1  0              1.75
  1  1  1  1              1.50

This shows that with N Arduino pins you can have (N^2)-1 levels. Using R2 gives your final level whne all INPUTs are off.

If you want to be able to drop Vout down to 1.25V, add transistor/MOSFET that connects R1/ADJ straight to ground. Turning this on will drop Vout to 1.25V, irrespective of the state of the other INPUTS.

1
  • 1
    I would like to add few extra notes for this interesting approach for digitally control the voltage output. What described in the original datasheet is in fact a very "minimalistic" 4 bit, DAC circuit. For some rationale it would help to study this two docs from AnalogDevices: One and Two.
    – cybercow
    Apr 2 '18 at 22:04
2

I am wary about providing a complete answer without knowing what is expected of YOU - is this like an assignment where you are being tested on understanding and what you have learned. The following will be useful to you. You need to give some more details if you want more assistance with these circuits.

Here is an existing stack exchange question. I see that I answered it in 2011 :-).
How does this power supply circuit work? (MCU + LM317)
The circuit and my previous answer should help greatly.
In your case you apply PWM using analog.Write to R1.
You MUST understand how the circuit works and not just apply it.
The original appears to be here with circuit description, with diagram here

enter image description here


On this page from EDN magazine is a similar circuit. The pot between pins 1 & 5 would not usually be used.

enter image description here


In another stack exchange question there is a very useful caution about the opamp's load limits in a similar circuit.
Problems controlling an LM317 with an op-amp - 2013


You can get many possible ideas here - search = lm317 voltage controlled power supply - this is an immensely powerful way of finding information - IF a picture is worth a thousand words then this is priceless. Note the terms used.


Bad designs:

There are some bad designs around which can look OK but behave badly.
Despite the detailed writeup, This poor design uses "open loop control" and the output voltage varies with load and is only "sort of controlled".

I was asked why I think this circuit is "open loop". I could not find a complete circuit diagram on the page but this diagram was shown of the output stage. If this is NOT the actual circuit used it would be "good" to have the complete circuit easily accessible.

enter image description here

IF this is the actual circuit used, then:

Call the transistors Q1 Q2 Q3 Q4 in left to right order.
Call intended output voltage = Vset = Vdac x (R6 + R7)/R7.
Vdac is applied to Q1 base and amplified by Q1 & Q2 to form the desired output voltage, appearing at Q2 collector. A lesser voltage appears as Vout due to the Vbe drop in Q3 & Q4. As load current increases Vout will "droop" thereby increasing the drive to Q4. This in turn increases the load on Q3 and Q3 emitter voltage will droop increasing Q3 drive. The actual Vbe voltages will depend on the beta (current gain) of Q3 and Q4, their temperatures (which depends on heat sinking, load and ambient temperatures) and manufacturing variation. At no or very low loads Vout will be about 1 Volt below Vset. At heavy loads Vbe_Q3 will be in the 0.6-0.8V range and Vbe_Q4 will be 0.8V+. So Vout will be around 1.5+ Volts below Vset and variable with (at least) the factors mentioned above.

This is still a usable design, but Vout could 'easily enough' be made far more stable with load by feedback from Vout to the Q1-Q2 amplifier - essentially forming a comparator that compares Vset and Vout.

Update:
This [reference provided by NilsB] MAY be the actual circuit diagram or close to it. It's an earlier 2005 design which presumably is much the same as the later version.

enter image description here

It appears not to be open loop in the broad sense. The Vout is still decoupled from Vset, with the software feedback allowing him to adjust the Vset to make Vout what he wants on a "nudge it and see" basis. ie Vset is not a fixed ratio wrt Vout so he can never set it and have it "just track". So it does not automatically stabilise for load or temperature changes and there is a variable drp between k x Vset and Vout.
Software is fastish but not as fast as a closed loop in hardware which allows Vout to track Vset within mV in a time delay as short as you provide an error amp loop for.

That's a 2005 circuit diagram so an earlier version than the originally cited V3 - one assumes he has not 'gone backwards' in design concept. It's strange that he does not include the whole circuit diagram or a good discussion of the provided current and voltage feedback. He may have wanted to sell kitsets rather than give away his final design. The link to the kitset sales is now broken so he now manages neither.

I'd consider it preferable to add a simple hardware error amplifier so Vout = k x Vset and THEN measure Vout and Iout with ADCs (as he does). Vout is then essentially "set and forget" with the added ability to check that Vout is what it should be (which allows eg heavy overload to be detected.
Constant current mode operation is still "nudge and see" but 'not too bad'.
Also, Vout includes the Vdrop across the current sense resistors - about 0.5V/A. Measuring with 2 x AD C channels as he does allows this to be compensated for. If the Isense resistors were in the "high side" feed before the regulator this would remove this variation but make current sensing somewhat harder.

5
  • What makes you think that this solution: tuxgraphics.org/electronics/201005/bench-power-supply-v3.shtml is "open loop control"?
    – NilsB
    Aug 29 '18 at 12:46
  • 1
    @NilsB Please see my updated answer. I've assumed that the actual circuit is the one shown on the page. If there is a complete circuit diagram anywhere and/or if this is not the actual circuit used I'd be pleased to know. (Both those comments are genuine - I feel I MAY have overlooked some final diagram somewhere but if so I cannot find it.) As it stands I assume that what is shown is what is used and my comments apply. The developer seems to have attempted to minimise use of ICs use of a comparator in the output stage would improve the result and make the design task easier. Aug 30 '18 at 0:54
  • I guess this tuxgraphics.org/common/images2/article379/powersupply.gif is the whole circuit. And as the feedback loop is done in software IMHO it's not "open loop". What do you think?
    – NilsB
    Aug 31 '18 at 8:40
  • 1
    @NilsB If your guess is correct then it appears not to be open loop in the broad sense. The Vout is still decoupled from Vset, with the software feedback allowing him to adjust the Vset to make Vout what he wants on a "nudge ity an see" basis. ie Vset is not a fixed ratio wrt Vout so he can never set it and have it "just track". ie it does not automatically stabilise for load or temperature changes and there is a variable drp between k x Vset and Vout. ... Sep 1 '18 at 9:49
  • 1
    ... Software is fastish but not as fast as a closed loop in hardware which allows Vout to track Vset within mV in a time delay as short as you provide an error amp loop for. || That's a 2005 cct diagram so an earlier version than the originally cited V3 - one assumes he has not 'gone backwards' in design concept. It's strange that he does not include the whole circuit diagram or a good discussion of the provided current and voltage feedback. He may have wanted to sell kitsets rather than give away his final design. The link to the kitset sales is now broken so he now manages neither. Sep 1 '18 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.