Variable Power Supply using Arduino

Variable Power Supply using Arduino

  • 2016-10-07
  • 1247

Batteries are generally used to power up the Electronic Circuit and Projects, as they are easily available and can be connected easily. But they drained off quickly and then we need new batteries, also these batteries cannot provide high current to drive a powerful motor. So to solve these problems, today we are designing our own Variable Power Supply which will provide Regulated DC voltage ranging from 0 to 24v with a maximum current up to 3 Amps.

For most of our Sensors and Motors we use voltage levels like 3.3V, 5V or 12V. But while the sensors requires current in milliamps, motors like servo motors or PMDC motors, which run on 12V or more, require a high current. So we are building here the Regulated Power Supply of 3A current with the Variable voltage between 0 to 24v. However in practical we got up to 22.2v of output.

Here the voltage level is controlled with help of a Potentiometer and voltage value is displayed on Liquid Crystal Display (LCD) which will be driven by an Arduino Nano. Also check out our previous Power supply circuits:

Materials Required:

  • Transformer - 24V 3A
  • Dot board
  • LM338K High Current Voltage Regulator
  • Diode Bridge 10A
  • Arduino Nano
  • LCD 16*2
  • Resistor 1k  and 220 ohms
  • Capacitor 0.1uF and 0.001uF
  • 7812 Voltage Regulator
  • 5K variable Pot (Radio Pot)
  • Berg stick (Female)
  • Terminal Block

How it works:

A Regulated Power Supply (RPS) is one which converts your AC mains into DC and regulates it to our required voltage level. Our RPS uses a 24V 3A step down transformer which is rectified into DC using a diode bridge. This DC voltage is regulated to our required level by using LM338K and controlled by using a Potentiometer. The Arduino and LCD are powered by a low current rating Voltage regulator IC like 7812. I will explain the circuit step by step as we go through our project.

0-24v-3A-variable-power-supply-using-LM338K

Connecting LCD with Arduino to Display Voltage Level:

Let’s start with the LCD display. If you are familiar with LCD interfacing with Arduino, you can skip this part and directly jump to next section and if you are new to Arduino and LCD, it won’t be a problem as I will guide you with codes and connections. Arduino is an ATMEL powered microcontroller kit which will help you in building projects easily. There are lots of variants available but we are using Arduino Nano since it is compact and easy to use on a dot board

Many people have faced issues in interfacing a LCD with Arduino, thats why we try this first so that it does not ruin our project in last minute. I have used the following to start with:

components-for-LCD-with-Arduino-nano

This Dot board will be used for our entire circuitry, it is recommended to use a female berg stick to fix the Arduino Nano so that it could be reused later. You can also verify the working using a breadboard (Recommended for beginners) before we proceed with our Dot board. There is a nice guide by AdaFruit for LCD, you can check it. The schematics for Arduino and LCD is given below. Arduino UNO is used here for schematics, but not to worry the Arduino NANO and UNO have the same pinouts and work the same.

LCD-with-arduino

Once the connection the done you can upload below code directly to check the LCD working. The header file for LCD is given by Arduino by default, do not use any explicit headers as they tend to give errors.

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); 

int a =5;
void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(a);
}

This should get your LCD to work, but if you still face issues try the following:

  1. Check you pins definition in the program.

  2. Directly ground the 3rd pin (VEE) and 5th pin (RW) of your LCD.

  3. Make sure you LCD pins are placed in the right order, some LCD’s have their pins is another direction.

Once the program works it should look something like this. If you have any problems let us know by comments. I have used the mini USB cable to power the Arduino for now, but later we will power it using a voltage regulator. I soldered them to the dot board like this

LCD-with-Arduino-nano-on-dot-boardLCD-with-Arduino-nano-on-dot-board-back-side

Our aim is to make this RPS easy to use and also keep the cost as low as possible, hence I have assembled it on a dot board, but if you can offered a Printed circuit board (PCB) it will be great since we are dealing with high currents.

Building 0-24v 3A Variable Power Supply Circuit:

Now that our Display is ready let us start with the other circuits. From now it is advisable to proceed with extra caution since we are dealing directly with AC mains and high current. Check for continuity using a multimeter every time before you power you circuit.

The transformer we use is a 24V 3A transformer, this will step down our voltage (220V in India) to 24V, and we directly give this to our bridge rectifier. The bridge rectifier should will give you (root 2 times the input voltage) 33.9V, but don’t be surprised if you get around 27 - 30 Volts. This is because of the Voltage drop across each diode in our bridge rectifier. Once we reach this stage we will solder it to our dot board and verify our output and use a terminal block so that we use it as a non regulated constant source if required.

Now let us control the output voltage by using a high current regulator like LM338K, this will be mostly available in metal body package, since it has to source high current. The schematics for variable voltage regulator are shown below.

LM338-circuit

The value of R1 and R2 has to be calculated using the above formulae to determine the output voltage. In our case we get R1 to be 110 ohms and R2 as 5K (POT).

Once our Regulated output is ready we just have to power up Arduino, to do this we will use a 7812 IC since the Arduino will only consume less current. The input Voltage of 7812 is our rectified 24v DC output from rectifier.  The output of regulated 12V DC is given to the Vin pin of Arduino Nano. Do not use 7805 since the maximum input voltage of 7805 is only 24V whereas 7812 can withstand upto 24V. Also a heat sink is required for 7812 since the differential voltage is very high.

The complete circuit of this Variable Power Supply is shown below,

enter image description here

Follow the Schematics and solder you components accordingly. As shown in schematics the variable voltage of 1.5 to 24V is mapped to 0-4.5V by using potential divider circuit, since our Arduino can only read voltages from 0-5. This variable voltage is connected to pin A0 using which the output voltage of the RPS is measured. The final Code for the Arduino Nano is given below in Code Section. Also check the Demonstration Video at the end.

Once the soldering work is done and the code is uploaded to Arduino, our Regulated Power Supply is ready to use. We can use any load which works from 1.5 to 22V with a current rating of maximum 3A.

0-24v-3A-variable-power-supply-using-LM338K-with-display 0-24v-3A-variable-power-supply-using-LM338K-back-side

Point to be kept in mind:

  1. Be careful while soldering the connections any mismatch or carelessness will easily fry your components.

  2. Ordinary solders might not be able to withstand 3A, this will lead eventually melt your solder and cause short circuit. Use thick copper wires or use more lead while connecting the high current tracks as shown in the picture.

  3. Any short circuit or weak soldering will easily burn your transformer windings; hence check for continuity before powering up the circuit. For additional safety a MCB or fuse on Input side can be used.

  4. High current voltage regulators mostly come in metal can packages, while using them on dot board do not place components close to them as their body acts as the output of the rectified Voltage, further will result in ripples.

LM338K-High-Current-Voltage-Regulator

Also do not solder the wire to the metal can, instead use a small screw as shown in the picture given below. Solders don’t stick to its body, and heating results in damaging the Regulator permanently.

  1. Do not skip any filter capacitors from the schematics, this will damage you Arduino.

  2. Do not overload the transformer more than 3A, stop when you hear a hissing noise from the transformer. It is good to operate between the ranges of 0 - 2.5A.

  3. Verify the output of your 7812 before you connect it to your Arduino, check for overheating during first trial. If heating occurs it means your Arduino is consuming more current, reduce the backlight of the LCD to solve this.

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); 

void setup() 
{
  Serial.begin(9600);
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.setCursor(0, 0);
  lcd.print("RPS");
  lcd.setCursor(0, 1);
  lcd.print("-Circuit Digest");
  delay(2000);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Voltage = ");
}

int voltage; 

void loop() 
{
  int A1 = analogRead(A0);
  voltage = map(A1,0,1024,0,22);
  Serial.println(voltage);
  lcd.setCursor(10,0);
  lcd.print(voltage);
  delay(1000);        
}

**Video: **

Suggest

Arduino Fun: Make a high-tech remote controlled car

The Player Control with Playstation and Arduino - VR

Arduino Step by Step: Your complete guide

Crazy about Arduino: Your End-to-End Workshop - Level 1

Learn PCB Design By Designing an Arduino Nano in Altium