logo elektroda
logo elektroda
X
logo elektroda

Another workshop power supply project with Arduino Pro Mini and LM317

andreyatakum 1932 15
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • After designing two power supplies - the first of which was not entirely successful and the second of which proved to be of little use - I decided to design a third. This is because, as it turned out, in my practice there is no need for current limitation, especially as in the previous variants it did not work fast enough to effectively protect the connected devices. Instead, it was much more important to constantly monitor the power consumed.

    Metal case with LCD display showing voltage, current, and power readings


    The new variant of the power supply has a more classic design and is based on the popular LM317 stabiliser, allowing voltage adjustment via a potentiometer from 1.5 to 15 V. The output voltage is measured by the Arduino microcontroller on the analogue A2 pin. As the upper voltage limit (15 V) significantly exceeds the maximum voltage allowed on the Arduino analogue inputs, a suitable voltage divider was used.

    Workshop power supply schematic with LCD display and Arduino Mini controller


    Current monitoring is implemented using an Arduino Pro Mini microcontroller and a 1602 LCD display. The monitoring scheme incorporates an operational amplifier type LM358, which magnifies the voltage across resistor R8 with a resistance of 0.22 ohms, resulting in current flowing through it when a load is connected.
    The use of an operational amplifier is necessary because the voltage drop across the 0.22 ohm resistor at a current of about 1 A is only about 0.22 V, according to the relation U=I⋅R.

    Such a value is too low to be accurately measured by the analogue input of the Arduino microcontroller.

    The LM358 amplifier was configured as a non-inverting amplifier. Using resistors R10 = 21 kΩ and R9 = 1 kΩ, a voltage gain close to 20 was achieved. At a current of 1 A, the amplifier's output therefore shows a voltage of around 4.2 V, which can be safely measured via the Arduino's analogue input (pin A1 in my case). The measured values are then presented on the LCD display.
    Based on the measured output voltage of the power supply and the rolling current, the power consumed can be easily calculated. The microcontroller software takes this function into account
    I needed this power supply quite urgently, so I did not order a dedicated PCB, but made the schematic on a mock-up board with 30x50 mm measurements. On the board I placed rectifiers, rectifier capacitors, stabilisers, a high-power (5 W) resistor, an operational amplifier and a voltage divider. I placed the Arduino Pro Mini board on the display. For the power supply of the measurement system, I used a separate rectifier and a popular 7805-type voltage stabiliser. For the regulated stabiliser, I added a cooler (coming from an Akai VCR, previously used together with a transformer).

    Metal enclosure with holes and rectangular cutout on a wooden workbench


    This time I did not use a makeshift housing made of sewer pipes. I made the enclosure out of sheet steel approximately 0.7 mm thick. Making the rectangular hole for the display and bending the sheet metal can be a potential problem, but these elements can be outsourced to factories specialising in sheet metal work. The dimensions of the housing are 90 × 100 × 150 mm. The front panel contains the display, the potentiometer knob and the connector for the receivers. The structure came out quite solid.

    Inside of an electronic device with transformer and circuit boards.


    The Arduino sketch code is included below and can be freely modified to suit individual needs. It would be worth considering adding an audible indication when preset power or current thresholds are exceeded.

    Cool? Ranking DIY
    About Author
    andreyatakum
    Level 14  
    Offline 
    andreyatakum wrote 668 posts with rating 949. Live in city Antalya. Been with us since 2021 year.
  • ADVERTISEMENT
  • #2 21803165
    Urgon
    Level 38  
    AVE...

    Technically you have a mistake in the title, it should be "Workshop power supply on LM317 with voltage and current measurement on Arduino". The second mistake is leaving a free operational amplifier "in the air", generally this should not be done. Consider choosing a different operational amplifier, a single one, or using the free half of the LM358 as a buffer between the LM317 and the Arduino. In general, a power supply without current limitation is moderately useful in the workshop, and as a 'universal' power supply is unnecessarily complicated - such power supplies need neither voltage nor current measurement.

    Plus for good workmanship, especially the display assembly, and for a good example of a 'starter' power supply....
  • #3 21803481
    sq3evp
    Level 38  
    Urgon wrote:
    AVE...

    Technically you have an error in the title, it should be "Workshop power supply on LM317 with voltage and current measurement on Arduino".

    The title suggested that the Arduino controls the process.
    Nevertheless, an interesting project. Maybe there will be an extension and it will be possible to control with an Arduino.
  • ADVERTISEMENT
  • #4 21803489
    Urgon
    Level 38  
    AVE...

    To control the power supply from the Arduino, the circuit would have to be significantly modified, starting with knocking out the LM317. And if the feedback is to go through the microcontroller instead of the analogue option, the Arduino has to be abandoned as well....
  • #5 21803540
    sq3evp
    Level 38  
    And some kind of voltage source for the ADJ control leg (in this case the voltage taken from the voltage divider on the potentiometer and resistors)?
    I think I saw somewhere such a project implemented on an Aduino.
  • #6 21803566
    Urgon
    Level 38  
    AVE...

    This can be done, but there are two limitations associated with it:
    1. Maximum output current.
    2. The maximum operating voltage.
    By building a more correct executive circuit on a transistor or power transistors these limitations disappear. All you need to do is ensure adequate loss power dissipation and stay within the SOA of the actuators....
  • #7 21803605
    acctr
    Level 39  
    sq3evp wrote:
    some sort of voltage source for the ADJ control leg

    The LM317 works by keeping a stable 1.25 V between OUT and ADJ and adding a stable resistance between ADJ and ground increases the voltage on OUT.
    By applying some external voltage Uz to the ADJ we give up its internal Uref, because Uout = Uz+1.25 V.
    You can also attach resistors to the ADJ via low-ohm MOSFETs, e.g. 5 such sections connected in parallel give 32 combinations. Then the LM works in the circuit it was designed for. The problem is to find the optimum values from the selected series to evenly cover the voltage range.
    Urgon wrote:
    Building a more correct executive circuit on a transistor or power transistors these limitations disappear.

    LM limitations have, transistors do not :D where do you get this from?
    The LM317 is used because it is convenient, cheap, proven and has thermal and overcurrent protection.
    Helpful post? Buy me a coffee.
  • #8 21803650
    sq3evp
    Level 38  
    acctr wrote:

    LM317 is used because it is convenient, cheap, tested and has thermal and overcurrent protection.

    I have such a 13.8V 1.5A power supply - it works, tested time after time.
    Up to 1.45A it holds voltage, potme the trafo sits down and the heatsink heats up. A friend had an identical one on a small heatsink from a CPU (probably some i486) and it held 1.5A quite well. The voltage downstream of the bridge was sufficient, there was no ripple, so it's likely that the structure in the IC has quite an effect on the output performance.
  • ADVERTISEMENT
  • #9 21803665
    acctr
    Level 39  
    Because the LM requires certain conditions to work such as a minimum voltage drop between out and in. There are full of simple schematics of power supplies on the LM317 everywhere, but I don't think I've ever come across a design with a fair description of its operation, which is probably best demonstrated by the characteristics below from its datasheet:

    Voltage differential vs output current graph for LM317 regulator at various temperatures

    A seemingly trivial layout on a few elements, copied mindlessly in millions of places, but approaching the subject in depth reveals many non-obvious facts.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #10 21803683
    Urgon
    Level 38  
    AVE...

    I'm not denying the merits of the LM317, but this is a circuit for building regulated power supplies usually for non-standard voltages that the LM78xx series does not cover. A workshop power supply should have adjustable current limit, not just short circuit protection. Current regulation can be stepped, but it should be and that's it....
  • #11 21803688
    andreyatakum
    Level 14  
    Urgon wrote:
    The second mistake is leaving the operational amplifier free "in the air", generally this should not be done

    Right! I had forgotten about that! Maybe that's why the display has been time warping since....
  • #12 21804252
    acctr
    Level 39  
    Urgon wrote:
    The workshop power supply should have an adjustable current limit,

    The LM317 is so clever that you can also make a current regulator on it.
    Helpful post? Buy me a coffee.
  • #14 21804291
    Urgon
    Level 38  
    AVE...

    You could go either way, but as far as I'm concerned it's multiplying entities unnecessarily. Leave the LM317 for regulated power supplies, and design the workshop power supply either on a dedicated circuit, as used to be done, or on transistors and op-amps.

    Or a completely crazy idea: a buck converter, a capacitance multiplier behind it, a divider behind the multiplier to measure the output voltage for the converter. You could use an LM358, one op-amp compares the output voltage with the one set from the Arduino or microcontroller, the other measures the current and compares it with the set current, and if this is exceeded, it takes the voltage from the output of the first amplifier to regulate the inverter. The time constant of the multiplier does not need to be large, just to match the clock frequency of the inverter. The multiplier will multiply it by the beta anyway, which will improve the ripple level. Another option is to bypass the capacitor in the multiplier with a transistor, which will be controlled by an amplifier from the current control. Then the voltage measurement is given before the multiplier, but with a diode in series to have the drop by as much as it will be on the transistor. Simple, right?
  • #15 21804293
    krzbor
    Level 28  
    Here is the layout from the catalogue note:
    Schematic of LM317 regulator with 2N2219 transistor and RC components for shutdown
    A voltage can be applied to the input marked input, which will turn off the LM or limit the current. We have one free operational amplifier - this can be used as a comparator, which takes the voltage from the output of the first operational amplifier and compares it with the voltage set by the potentiometer. The result through a resistor is fed to the base of the 'input' transistor. This results in the adjustment of the maximum current. Interestingly - we can connect the output of this potentiometer to another ADC and display. We have the ideal solution - an analogue (fast) current limiter and a digital display of the limiter value.
  • #16 21812952
    Strumien swiadomosci swia
    Level 43  
    There is an English-speaking impulse power project group on fb. Unsurprisingly mainly Asian.
📢 Listen (AI):
ADVERTISEMENT