3A Variable Bench PSU With Digital Readout on Colour Display Using ATMEGA8




Introduction: 3A Variable Bench PSU With Digital Readout on Colour Display Using ATMEGA8

About: I'm a senior telcom engineer by profession.My hobby is designing circuits and successfully implement them.Microcontroller coding is the main area of interest.Analog electronics is another hot favourite. I thin…

I am playing with electronics since i was a child and made numerous circuits.But still now,i didn't made any power supply unit for general purpose use.So tired of making PSU for each circuit,I decided to make a stable Bench PSU for general purpose use with some enhanced features.I decided to made the core power supply analog controlled and extra features digitally controlled.

So that's why i choose LM350 linear regulator chip as the heart because 3A is sufficient for day to day use.

For the digital part,the functionalities i choose are listed below:

1.Digital readout of Voltage.

2.Digital readout of current.

3.Digital readout of LM350 temperature.

4.Smart Fan controlled cooling for LM350.

All the mentioned criterias were fullfilled by ATMEGA8 so it was finalized for this circuit.

The ADC i choose is ADS1115 which is 16 bit ADC.I will discuss about it later.

Now for current measuring,i used ACS714/5A breakout board which does it job pretty good.

LM35 is used as the conventional temperature sensor and it also does it job perfectly.Atmega8 senses temp and controls the fan according to it.

Now last but not the lease...the Display!!!Generally we see 16x2/20x4/128x64 monochrome type of display in this type of power supply.But i thought something different and used really cheap 128x64 SPI colour display.It generally uses ili9341 as it's controller and is pretty popular as display driver.It is SPI controlled.But you need 5v to 3.3v level shifter to run this type of display which are available at the market and are pretty cheap.

Now comes the software part.Coding the software took me a lot of time.I put enough comments at the end of each line by which anyone cans easily understand the functions.I modularized the code so debugging is very easy.I used winavr and C to write the code.

So now it's time to get into the next step to see what are need to run this circuit.

Step 1: Parts Required

Parts are listed below and i have mentioned the sites to get the difficult parts online.

1) ATMEGA8 x 1

2) ADS1115 breakout board x 1(You can find it here.Or you can also see at official Adafruit website here).

3) ACS714 breakout board x 1(You can find it here.Or you can find it at Polulu official website here).

4) ILI9341 SPI 2.2" colour display x 1(You can find it here.Or you can find it at official Adafruit's website here).

5) 5v to 3.3v level shifter x 2(You can find it here or at here).

6) LM350 x 1

7) 5k 10 turn pot x 1(to get precise voltage division at output)/Normal 5k pot

8) 7805 x 2.

9) 7812 x 1

10) LM1117(5v to 3.3v supply IC). x 1

11) IRF540 x 1

12) IRLB8748 / IRL540 logic level mosfet/Last option,if you couldn't found them,try with IRFZ44(this should also work but i didn't tried that myself) x 1

13) 18V zener diode(1/2w preferable). x 1


120 Ohm,10k x 3,18k,5k preset.

15) Capacitors:

100NF/104PF x 7

102PF x 1

22PF x 2

10uF/63v x 5

22uF/25v x 1

4700uF/63v x 1

220uF/35v x 1

16) 8 Mhz xtal x 1

17) Diode:

1N4148 x 1

1N4007 x 2

6A4 / 6 amp diode x 4/Bridge rectifier-KBL04.

18) *12-0-12/4 amp CT type transformer(I used this transformer from scrap without using center tap.You can use any other transformer.But keep one thing in mind that the Max input/ouput differential of LM350 is 35v to 37v)

in mind that the Max voltage differential between).

19)*Heat sink(For LM350 , IRF540 , 7805)

20) *12v Cooling Fan(see the heat dissipation part)

21) *CPU SMPS cabinet.(I used a faulty SMPS cabinet.You can use whatever you want).

22) Banana Jack+Socket - 1 pair(BLACK+RED).

Step 2: The Circuit Diagram & Explaination

Now Take a look at the circuit.

First the transformer is stepping down the mains AC coltage to 12v.Here one thing is noticeable that i haven't used the center tap.Because of this,i am getting double voltage.After that,the ac is being rectified by the rectifier.Here i've chosen a compact bridge module KBL-04( which is capable of handling upto 4Amps of current )instead of using 4 nos of diode to save the pcb space. Afeter that there is a 4700uF filter cap with a 100nF decoupling cap.After the smoothing,i am getting approx 37V of DC.at the input of the LM350.Also this 37V is powering up the Volt/Ammteter/Smart fan circuit.

The LM350 is configured as per the datasheet with 2 protection diodes.(They are really necessary,believe me as i have killed a dozen of LM350s when playing with more than 25v DC at the output.).Then again i am filtering with a 220uF cap.Then the output is connect to the Banana female socket via the ACS714 breakout board. The last 10uF+104pf+102 pf caps are soldered directly to the output banana female jack to suppress EMI/EMF signals(Generated from the sources like DC motors)which may freeze the CPU as well as the TWI / I2C bus.

Now after that there comes our main part of the circuit.The volt/ampmeter/smart fan circuit is being powered from a Mosfet.I've chosen IRF540 for this purpose as the parameters are really good from the datasheet.This mosfet is getting 37v at it's Drain.The gate is tied to 18v with a 18v Zener and a typical 10k biasing resistor.The source now becomes (18v-Vgs typical)=(18v-3v)=15v.This 15v is being fed to the Inputs of the 7805 and 7812 regulators as 37v is too high for their input.The mosfet is working as a pre regulator.The Mosfet is dissipating a lot of heat and we have to take it into consideration.I will next discuss it at the heat dissipation part.

The Atmega 8 is the heart of the metering circuit.It is communicating with the 16 bit ADC(ADS1115) via TWI / I2c bus.you can find the datasheet of ADS1115 here.It is generally a 16 bit ADC when used in Differential mode.Here i've used it in single ended input mode.i.e we will have 4 inputs(A0/A1/A2/A3) wrt ground.First input A0 is connected to a simple 10:1 voltage divider as you can see.I have added the 5k preset instead of a fixed resister to get adjustable optimum reading accuracy of voltage.Later i will talk about it.The second input(A1 is connected to the ACS714 breakout board output pin.ACS714 is a IC from allegro microsystems which is a hall effect based linear current sensor IC.Please notice that the Output from LM350 is connected to the ACS714 IP+ pin.The the IP- is giving the output to the load.The other pins of the board -VCC/OUT/GND are isolated from the Inputs.Next i will show,how to measure the current reading.

The 3rd input A2 is connected to the LM35 temperature sensor which is a 3 terminal IC from National semiconductor.Basically it has a 10mv/°C Scale Factor i.e simply if the room temperature is 30 °C,then it will give 300mV at it's output.We have to simply read the voltage and display it upto two characters i.e say if we read 350mv,then we will show 35 °C as the temperature.i have installed the LM35 on the heat sink of the LM350 to read the temp.As the temp of LM350 rises above 50°C,the ATMEGA gives output high at pin 5 which drives the Logic level mosfet(IRLB8748.Although i have made the circuit diagram with IRFZ44) and it turns the fan on.After the temp reduced to below 40 °C,the fan stops.

And one thing to keep in mind that as we are using the ADC in single ended conversion mode,we will get 15 bit of resolution(i.e from 0 to 32768) as it is going to be needed for the calculations in the upcoming part.

Then comes the Display part.The ili9341 based SPI display works on 3.3v.That's why we need a 5v to3.3v converter.The level converter boards serve the purpose.These boards has two sides i.e-High side and low side.They take 5v signal on the high side and gives out 3.3v signal on the low side.In order to make them work,they should be fed 5v supply on the high side and 3.3v supply on the low side.The 3.3v is generated using a LM1117-3.3 IC.It is basically a SMD ic.I have created a very small pcb with the two filters caps on the board(C13,C14) and the board looks like and works like a fixed voltage regulator IC.I will update the picture in the later part.

One thing is noticeable here that i have powered the ADS1115,ACS714 and LM35 from one 7805 and rest of the part from other 7805.There is a reason behind it.As the circuit runs,the 7805 gets warm(As the display consumes nearly 170ma alone) and voltage deflection occurs at the output. i.e we can't get stable 5v.The ACS714 gives 2.5v output at the o/p pin when there is no current flow at stable 5v supply.The total current measuring formula is based on this fact.If the output deflection occurs,the the current measurement reading will also shows error.(I have faced the fact during experiment).That's why,the measuring devices are powered from a separate 7805 to get accurate reading as much as possible.


Step 3: Beat the Heat...Heat Dissipation Facts

Three main parts in the circuit will generate a lot of heat.

1) The LM350

2) The IRF540 (Q1)

3) 7805(U8).

So in order to dissipate the heat,what will be the required size of the heat sink that is the main question.So to choose the heat sink,we need to know a few things as i will not go into deep in this discussion.

Terms to remember:-

Tj - max is the maximum junction temp the device can withstand.It's value can be found on datasheet.Different devices has different values.We must maintain our functional temperature below this temperature.

Tj - Functional junction temp is the temp the transistor/IC will be at during the operation.

Rth j-c -Thermal resistance of the device from junction to case.The unit of this is °C/W.

Rth c-hs - Thermal resistance of the insulator used(Generally Mica/silica pads)

Rth hs-a -Thermal resistance of the heat sink(This will be our main subject of interest). Different heat sinks has different values.This heat sink has a value of 3 which i'm using.

Ta-Ambient temp.

The calculation can be done in two different ways.Either by calculating the Tj with known Rth hs-a of a heat sink and have to find that if Tj is lower than Tj-max or by finding out the Rth hs-a and find a heat sink with a value below it.Just watch below the calculations carefully and you will understand easily.The heat sinks i used for LM350/IRF540/7805 can be seen from the picture.

LM350 calculation:

The formula is

Tj = P * (Rth j-c + Rth c-hs + Rth hs-a) + Ta.

Here we will find the Tj and will check it if it is less than Tj-max as all the other parameters are known.

P=25w(If the differential between Vi and Vo is kept below 15v ).

Rth j-c=2.3(As i'm using LM350 from ON semi).

Rth c-hs-1.0(Mica washer with both side heat sink compound used).If the heatsink is attached directly to the heat sink,then this value will be 0.

Rth hs-a=3

Ta=30(a slight higher than room temp as there will be other heat sources inside the cabinet like the transformer.)

So Tj=25*(2.3+1+3)+30=187.5 which is greater than Tj-max(150°C).So thats why i,ve installed the smart fan cooling system for forced air cooling).

IRF540 calculation:

As the Q1 is used as pre regulator,it will also generate a lot of heat.Say the input voltage will be near 37v.The zener is of 18v.So at the Gate,the voltage will be near about 18v(wrt ground).The Vgs is typically 2.7v-3v.So the final output at source will be 18-3=15v.When the fan is off,the circuit consumes nearly 170ma and with the fan on,the circuit draws 300ma.So power dissipation by the mosfet with fan on will be (37-15) * 0.3=6.6w which is also a high value.

So with a heat sink with Rth,hs-a=8.3,Rth j-c=1(from datasheet) and no mica washer,the Tj will be-

Tj=6.6* (1+8.3) + 30=91.38

which is far more less the Tj-max (which is 150°C from IRF540 datasheet).So we can use this heat sink with thermal resistance of 8.3.

7805 calculation(U8):

The 7805 which is giving power to the atmega8 and the display,will also heat up.The Display circuit + atmega8 consumes nearly 150ma.It is getting 15v at its input(The final output of IRF540).so the power dissipation of the 7805 is (15-5) * 0.150 = 1.5w.So a small heat sink is required. I'm using a heat sink with a thermal resistance value of 17.4

So Tj=1.5 * (4+17.4)+30=62.1(Rth j-c=4 from datasheet)

Tj is much less than Tj max.So we can easily use this heat sink for this application.

The 7812 will also get hot,but it will be no issue to run the IC without heat sink.

Step 4: The Reading & Calculation............

Voltage measurement calculation:

The voltage range,that i set to measure is 40v.So in order to measure 40v with a internal vref of 4.096(different value can be set using software),i used 10:1 voltage divider i.e if the divider has a max input voltage of 40v,then the output from the divider will be 4.0v.I used 18kand 2k voltage divider.But practically,i replaced the 2k resistor with a 5kpot to get more adjustable reading accuracy. So with a 15 bit ADC,the voltage measurement is as follows

Measured voltage=(adc read)*(ref volt=4.096)*(Division factor=10 with 18k & 2k resistor divider)/(Max adcvalue=32768)

suppose we get a adc reading of 8192 that means the measured voltage is-


Current measurement calculation:

The ACS714 gives 2.5v at it's output pin when there is no current flowing from IP+ towards IP- or to the arrowed direction as shown in the pic .If current flows,the output increases gradually like 0.185v/A over 2.5v i.e if say 2A current is flowing,the the o/p of the ACS714 will be 2.5+(0.185 x 2)=2.87v.

So by the following formula,current measurement is as follows:

Measured current=(((adc read)*(4.096)/32768)-2.5)/0.185.

say the ADC reads a reading of 22960.For this value,the measured current will be-


Temperature measurement:

As discussed previously,the LM35 will give output voltage in linear with the temp in the mV range.Say for 30 degree,it will give 300mV.

Now as per the below mentioned formula,the micro will read 300mV.I have shown it upto two characters from left so it will be 30 degree as temperature.

(adc read)*(ref volt)/32768

Step 5: The Software

I have coded the whole program in Winavr using c.I have modularized the whole code i.e i have written library for each module like ADS1115,TWI,ili9341 etc.I have written enough comments at the end of each line by which anyone can easily understand the code.

The twi library contains all the basic twi functions needed by the micro to communicate with the ads1115.Note that no code is written for error handling.Only basic commands are written.

The ads1115 library contains all the necessary commands and readout through twi bus.For more details,please check the datasheet.

The ili9341 library is written inspired by the adafruit ili9341 library written for arduino.I added some extra functions with the existing ones.The basic ili9341 library contains all the initial setup to run the display.The ili9341gfx library contains all the graphic/text and some other extra functions like cursor backup etc etc.

In the main,Please define the supply voltage by measuring it with multimeter as exact value of supply voltage is needed to measure the Amp/current as the formula mentioned previously.

Please note one thing that i've define R2=2 .for 10:1 voltage divider.This part will be explained in the calibration part.

You can bypass all the software headche mentioned above and simply burn my hex file to the atmega8.Just follow the Calibration part later to run all the things smoothly.

I have uploaded each and every file as it's original format except the Makefile as it was previously creating problem to open.I have uploaded it second time in .txt format.Just copy the content and paste it into a new Makefile.

Step 6: Combining All the Things.......The Final Product

Various pics during my total buildup and till before calibration.

The pics are generally arranged step by step from starting to finish.I have added notes for all the pics.

Step 7: Calibration..

To get very accurate reading,calibration is very much necessary.Calibration can be done in two steps.

Volt measuring calibration:

Volt measuring calibration is done totally in the hardware.First set the output voltage to 5v by measuring it with a good multimeter.Now check the display,what it is showing and match the reading with the multimeter reading by turning the RV2.

Ampere reading calibration:

The ACS714 gives Vcc/2 at it's output pin when no current is flowing.Now measure supply voltage for the ACS714 with the multimeter at the Vcc pin wrt ground.Now define it as the supply voltage in the "main".Thats all.Other thing will be taken care of by the software.

Step 8: Turning It on After Calibration......The Final Step

Now i have come to an end and before to say goodbye just want to say a few words.This power sipply is100% tested and working.No problem detected still now during long run.Be sure to attach the filter caps C4,C5 and C15 directly to the Banana connector female socket to prevent the effect of emf/emi caused by big sized motor/relay which will hang up the mcu itself or the twi bus or the spi bus.Feel free for any queries and please let me know about the project.Soon i will update a video regarding the operation of the supply.For now, i'm adding the pics when turned on.Please take a look & read the note.

Goddbye and take care....


Be the First to Share


    • For the Home Contest

      For the Home Contest
    • Make It Bridge

      Make It Bridge
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge



    6 years ago

    Can you make a video. This build is awesome but am not so good am starting to build things but still a green hand. Love the display. Hard to follow what you mean on most things here


    Reply 6 years ago

    This circuit is recommended only if you are familiar with microcontroller programming.If you want to build the same,first i would recommend you to do some readings about Atmega series microcontroller family/programming/LM350 typical circuit/ADC functionality etc etc.Otherwise it would be difficult.

    The steps/circuit/programming/calculations are very much well explained.Please read them carefully.

    Contact me if you have any doubts/query after that.


    7 years ago

    nice job! Can you tell me what software package you used to draw your circuit diagram? It's really nicely done.


    Simon Carter


    7 years ago

    Nice. One question though. I thought that a rule of thumb of the capacitor before the LM350 is normally 2000 uF per Ampere so you should at least have something around 6000 uF (6400 uF is then the closest) instead of 4700 uF.


    Reply 7 years ago

    4700uF is working fine for me...i didn't do any math for this as.... :-p


    7 years ago

    This can be modified to add a fuse correct? I have had many problems with over currenting


    Reply 7 years ago

    Obviously you can add what you need.But be sure to put it in a right place.


    Reply 7 years ago

    Yes...i made the board myself by etch method.....


    7 years ago

    Could I propose an idea for v2? I saw an instructable on a touch screen RPI.... I will let you figure out the rest


    Reply 7 years ago

    obviously u can propose.By d way....i'm currently designing a fully programmable 12 bit power supply with keypad entry.You can check the incomplete video here below..



    7 years ago

    Excellent write up. Gonna build slightly upgraded version, using 3.3V micro instead of 5 and also using center tap of the transformer as a GND to get Dual Power supply. +-12V.


    7 years ago

    Hi Sharan,

    Very nice instructable, hoping you will share some other projects too.

    Great detail and very easy for a newbie to follow


    Reply 7 years ago

    Soon i will update a Fully programmable power supply with constant voltage and constant current mode.It will have a keyboard through which you can enter the desired voltege to get or to set the desired current for constant current mode.You can check the video of the unfinished version in the link below



    7 years ago

    Nice project !! Could you please correct the link for MakeFile ?

    Could you please share also PCB design ?




    Reply 7 years ago


    I have uploaded a new Makefile with .txt extension as the
    previous was being blocked as u told.Just copy the content of the
    Makefile.txt and Paste it into a newly opened Makefile of Winavr and
    you are ready to go.


    7 years ago

    The Makefile will not copy I am recieving a Failed-Forbidden error


    Reply 7 years ago


    I have uploaded a new Makefile with .txt extension as the previous was being blocked as u told.Just copy the content of the Makefile.txt and Paste it into a newly opened Makefile of Winavr and you are ready to go.


    7 years ago

    Good project !!

    Just a suggestion though .I was reading about your calculations for the IRF540 heat generation . It , and R2, and D2 could be eliminated by connecting to the center-tap of the transformer to feed the 78xx regulators , maybe use a 1000 uF, or so( just guessing off the top of my head, I haven't done all of the math ) , capacitor as a filter .Two of the diodes in the bridge connected to " ground " would make the center-tap a positive voltage source , at half the voltage of the of what the full bridge will deliver ! You were looking for something like18 volts or so to feed the 78xx's this should be close enough !

    Cheers , take care , and have a good day!!