Part 2 of the adjustable linear PSU will cover:
- Voltage and current measuring + displaying to LCD
- Constant current circuit to drive indicator LED
- Maintaining the required load for regulation
- Testing
Finishing the Circuit
Current and voltage measurement
A traditional shunt was used but rejected since measuring small voltages is difficult. Here’s why!
We can connect a 0.1Ohm resistor in series with the output. A voltage drop would generate across it in accordance with Ohm’s law. For example, at 1A of current, V = IR = (0.1)(1) = 100mV
If I was to use an Arduino, it has an inbuilt 10-bit ADC. This translates to 1024 individual steps with a step size of 4.88mV (at 5V).
Let’s revisit the example. If 100mA was flowing across the output, the drop across the shunt would be 10mV. When compared to the smallest step size of the Arduino which is 4.88mV, the voltage drop is far too small to record an accurate measurement. Additionally, 4.88mV is assuming no noise, so this example is a best-case scenario.
In order to simplify this, I opted for the INA219 current sensing breakout board from Adafruit. It uses an instrumentation amplifier to … amplify small voltages which can be read by an MCU.
Display
This is fairly straightforward. Now that we have the voltage and current measurements, we need to communicate this information to the user. THIS LCD will be used. It is fairly common. It can be programmed with Arduino and the Liquid Crystal library.
Constant Current Circuit
In part 1, I introduced a LED and current-limiting resistor on the output to lightly load the LM317. This is highly problematic.
The LED brightness would vary wildly depending on the voltage output.
If the PSU was set to deliver 15V, the current-limiting resistor would need to be:
\frac{V_{\mathrm{IN}} - V_{\mathrm{OUT}}}{I_{\mathrm{forward}}}
= \frac{15V - 1.8V}{0.02A}
= 660\,\Omega
NOTE: Vout is Vforward
At 5V output, the LED would receive:
\frac{5V - 1.8V}{660\Omega} = 4.8\,\text{mA}
This causes the LED brightness to wildly fluctuate. For a user perspective, this can be irritating and not elegant.
The solution is a constant current source
Introducing the Widlar constant current source
- The base of transistor T1 is pulled high via R13, allowing current to flow into the base of T1
- T1 conducts, allowing current to flow from Vcc through the LED into the transistor T1 and through R12
- As the current increases the voltage drop across R12 increases UNTIL it surpasses V_BE of T2
- At this stage, T2 conducts
- This diverts current away from the base of T1, reducing the amount of current flowing from its collector to emitter and thus the current through the LED
- This of course results in the voltage drop across R12 being reduced stopping current flowing through T2 which once again allows current to flow through T1.
This process repeats very rapidly, resulting in a constant load
R_{12} = \frac{V_{\mathrm{BE}}(T_{1})}{I_{\mathrm{forward}}}
= \frac{0.7V}{0.02A}
= 35\,\Omega
This is a small value which can reduce power dissipation. R13 was also sized to reduce power loss. At 2.2k, the current can vary from 6.8mA – 570uA. Considering the immense variation of the gain parameter of transistors, this circuit still produces adequate amplification.
However at voltages less than 3V/2.5V, the LED will be dim due to forward voltage of LED (1.8V) and V_BE 0.7V. This was simulated.
Temperature Sensor Circuit
The LM335 will be used. It has a linear output, it’s cheap and commonly available. It can easily be interfaced to an MCU via a voltage divider.
The LM335 and R17 form a voltage divider with the LM335 changing its resistance linearly in relation to the temperature with a rate of 10mV per degree Kelvin
At room temperature (25 degrees) the LM335 will output:
25°C + 273.15 = 298.15K or 2.98V
This can easily be read by the 10-bit ADC of the Arduino.
According to the datasheet, the LM335 needs 1mA to allow accurate measurement and to minimize self-heating.
R1 was calculated considering 5V input and room temperature:
R = \frac{V_{\mathrm{CC}} - V_{\mathrm{LM335}}}{I_{\mathrm{out}}}
= \frac{5V - 2.98V}{1\,\text{mA}}
= 2020\,\Omega
\approx 2\,\text{k}\Omega
R19 is a pot that can be used to calibrate the sensor. Also, a precision thermometer will be required for calibration.
Fixed Regulators
2 IC’s will be used to provide 2 separate rails (12V and 5V).
For simplicity, no heatsinks will be used. This allows me to reduce the size of the PCB. To reduce costs, fixed linear regulators were used.
Fan Control Circuit
Once again, this is straight forward.
A digital Arduino PIN drives a fan via PWM and a FET. The FET can handle 250mA through I_D
The fan control circuit will trigger once the LM335 circuit reaches a specific temperature. R18 pulls the gate of the FET low. D7 is a flyback diode.
The Code
The code is simple thanks to the Arduino libraries for the LCD and INA219.
A few comments:
- Tweak the reference voltage. It is set to 5.02V. Typically, the Arduino voltage is not strictly 5V. This is EXTREMELY IMPORTANT as the ADC accuracy is directly tied to the ADC’s reference voltage.
- The variables minTemp, maxTemp and samples can be used to configure the fan control circuit. minTemp and maxTemp determines the temperature in degrees in which the fan triggers. samples is used to generate an average reading to keep the fan stable
- The temperature measurement is digitized using analogRead then scaling in accordance with the ADC. It is converted into degrees celsuis.
- Voltage and current reading
- The INA219 libraries simplify voltage and current measurement
- The current is converted into A.
- The temperature, voltage and current measurements are pushed to the LCD using lcd.clear(), lcd.print() and lcd.setCursor().
- For the fan control circuit, the temp variable is mapped to a PWM value from 0 – 255. This drives the gate of the FET.
The Schematic and PCB!
The combination of all the previous circuits is displayed below:
The high current traces were adjusted to have a trace width of 50mil (1.27mm). If 1.5A travels through them, the PCB will increase in temperature by 1.1 degrees Celsius. The trace resistance is 74mOhms and 167mW will be dissipated.
NOTE: Digikey’s PCB Trace Width calculator was used
The main build uses 100mil traces are used ****to reduce resistance of the traces and thus reduce power loss
NOTE: In the PCB industry, mills are used. 1mil is 1 thousandth of an inch which equates to 0.0254mm
A ground copper pour was used. This makes hand soldering more difficult. Thermal reliefs were used to mitigate this.
NOTE: Thermal reliefs connect vias to a copper pour via thin traces. This allows less heat to be drawn away from the pad when a soldering iron heats up a pad.
Additionally, Multiple vias + via-stitching was used for high-current traces AND to enhance the grounding.
The trace width was adjusted depending on the current draw. See the image below:
Since, vias are high resistance, blind vias were used reduce resistance.
The component values are not stated on the silkscreen
Comments on the physical build:
- An off-the-shelf enclosure can be used
- The IC’s are mounted directly to the heatsink with thermal compound to aid heat transfer
- The switch comprises a significant amount of space due to its high rating.
- Standard component mounting is used with fasteners, using insulated washers to prevent unintended shorts
Testing
Testing was performed with a lab bench PSU
- The 1.5A max current wasn’t able to be reached. 1.3A would be attained before the LM317 entering thermal shutdown
- The measured output voltage is 11.62V. This is similar to the rated 12V
- The main plus of a linear PSU is its superior output noise. At 1A, the ripple was 3.13mV-p-p. NOTE: The ground spring of the scope probe was used.
- The PSU had a superior load regulation. At 1A, the PSU continued to supply 12V
Temperature
I was curious to see the effectiveness of the fan in heat dissipation, considering this is a linear PSU. Using two K-type thermocouples and a multimeter, the temperature was measured across the full output range:
Measurement Accuracy of the INA219
The accuracy of the INA219 breakout board was verified. Both current and voltage measurements fit within the tolerance of 0.5%
To check voltage accuracy, we applied a 500 mA load to the circuit and used the voltage adjustment potentiometer to set outputs of 3.3 V, 5 V, 9 V, and 12 V, verifying each with a multimeter.
For current accuracy, the supply was fixed at 12 V, and the load was varied until the supply indicated 100 mA, 250 mA, 500 mA, and 1 A.
Maximum input voltage
Minimum input voltage must be 19V in order to supply 12V on the output. The 2 LM317’s form a 6V dropout voltage.
The maximum input voltage shouldn’t exceed 25V otherwise the dropout voltage will result in significant power loss.
The 12V regulator controls the fan can draw 80 – 100mA. This means at 24V input the 12V regulator without heatsinking will need to dissipate around 1.2W of energy. Whereas at Vin = 35V, the power dissipation would be 2.3W.
The 5V regulator on the other hand only draws around 35mA which at 24V input will dissipate around 665mW and at Vin=35V, it will dissipate around 1W.
The absolute maximum power the LM317 can dissipate is 2.3W before requiring a heatsink, according to the datasheet. However, my calculations did not include a higher ambient temperature (which is possible given the Australian climate) and the limited space inside the enclosure which increases the temperature.
All of these factors limit the maximum input voltage.
AC Input
An 18Vrms AC input produces 4Vp-p on the output. This can be reduced with larger output capacitance.
Future Improvements
- A linear regulator with a smaller dropout voltage can be used such as the LM1117. It has a dropout voltage of 1.2V
- Fixing the lower than expected current output of the LM317
The datasheet claims the IC can each 1.5A. However, I was unable to reach this before it reached thermal shutdown. I suspect this is a hypothetical maximum.
However, without some magnificent cooling, it will be difficult to achieve since The LM317 has to drop around 3.6V across it to work with a current draw of 1.5A. It will have to dissipate P=VI = 3.6*1.5 = 5.4W











