Home / Home made Projects / Microcontroller Projects / Microcontroller based automatic voltage stabilizer

Microcontroller based automatic voltage stabilizer

This project explains the design and construction of microcontroller based automatic voltage stabilizer. Explanation of voltage stabilizer circuit and program in microcontroller is explained. Lastly automatic voltage stabilizer is simulated in ISIS Proteus and results are displayed.

Introduction to controller based voltage regulator 

Voltage stabilizer is very useful device which keeps the voltage in acceptable range. It regulates the voltage so that electrical devices are not damaged. Voltage stabilizer is present since decades however with the advancement of technology, the size as well as rating is improved. Large classical voltage stabilizers are now replaced by small and automatic electronic voltage stabilizers.
Nowadays due to advancement in controller’s technology and reduction in controller’s prices, a number of appli
ances are converted to controllers based devices. It is because controllers provide more ease in control and it reduces the outer circuitry thus increasing simplicity.

Therefore in this project we are introducing microcontroller based automatic voltage stabilizer, its control circuit and program.

Components

Following components are required for the project automatic voltage stabilizer

  • PIC Microcontroller 18F4220
  • Relay Driver ULN 2003A
  • 12V operated, 300V power relays
  • Power Transformer with multiple tapings (preferably autotransformer)
  • Small signal transformer 220V/5V
  • LCD 16×2 (optional)
  • Diode
  • Capacitor 6V, 50uF
  • Power Supply (5V, 12V)

Automatic voltage regulator Circuit Diagram

Following figure shows the circuit diagram of microcontroller based automatic voltage regulator.

Microcontroller based automatic voltage stabilizer circuit diagram

We will start from the input main source. It is 220V/ 50Hz supply. To construct voltage stabilizer for high power, most important component is power transformer. For stabilizer or voltage regulator, power transformer must have multiple tapings. The recommended transformer here is auto transformer because it does not have core therefore occupies less space.

The transformer is designed such that

Tapping Voltage range For Example If input = 220V
First tapping Input + 40V 220 + 40 = 260V
Second tapping Input + 20V 220 + 20 = 240V
Third tapping Input + 0V 220 + 0 = 220V
Fourth tapping Input – 20V 220 – 20 = 200V

These ranges are totally based on requirements. Tapping can be more than four and their voltage ranges can vary depending upon requirements.

In the above circuit diagram, resistors of required value are connected to make virtual transformer tapings of mentioned range. It is because; Proteus does not have with multiple tapings transformer.

Relays connects/disconnect load from transformer. These relays are controlled by microcontroller via relay driver. Since microcontroller issues output signal of 5V with very small current (few mA) while relay require 12V and higher currents therefore Relay driver is employed between microcontroller and relays.

As microcontroller is the main control device therefore it must sense the input voltage to connect turn on/off appropriate relay. For this purpose main supply voltage is brought down to 5V level and converted into DC. A small signal transformer is used for this purpose. The voltage is then converted into DC via half wave rectifier which consists of diode and capacitor.

Working of Microcontroller based automatic voltage stabilizer

Main supply voltage is given to the load via power transformer with multiple tapings. Relays are connected at each tapping to energize load. At a time, only one relay will be closed to energize load. It means at single moment, only one tapping of transformer will supply power to load. The choice of transformer tapping to supply load depends upon the input voltage.
This input voltage level is sensed by microcontroller. Main supply voltage brought down by signal transformer and converted into DC by half wave rectifier is given to analogue Pin of microcontroller. Based on main supply voltage, microcontroller turns on the respective relay via relay driver.

If the main voltage is between 200 to 220V, third tapping energies load by turning on its relay. If voltage level is 180V to 200V, load is energized by second tapping. If voltage is further reduced to 160 to 180V, first tapping is connected to load.

If voltage level increases to 221 to 240V, fourth tapping is connected to load. If the voltage is either below 160V or above 240V, the stabilizer disconnects the load from the main supply.  To make the microcontroller based automatic voltage stabilizer user friendly, messages are displayed on the LCD screen.

Simulation results

Initially voltage is kept between 180 and 200V as shown.

auotmatic-voltage-regulator-3

when voltage is 184 (between 180 and 200V), tapping 2 is turned on and voltage at load is kept 202V

Now when voltage is increased to 261 V, result is shown.

automatic-voltage-stabilizer-using-microcontroller

Since voltage is above 240V, all relays are turned off and load is disconnected from supply.

Code for automatic voltage stabilizer using microcontroller

The code for microcontroller is written in C language and compiled in MIKRO C compiler.

float inputread, inputmeasured, actualvoltage;
// Lcd module connections start
sbit LCD_RS at LATC3_bit;
sbit LCD_EN at LATC2_bit;
sbit LCD_D4 at LATC4_bit;
sbit LCD_D5 at LATC5_bit;
sbit LCD_D6 at LATC6_bit;
sbit LCD_D7 at LATC7_bit;
sbit LCD_RS_Direction at TRISC3_bit;
sbit LCD_EN_Direction at TRISC2_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;
// Lcd module connections ends
// copy above statments into your code for every project involving LCD
char txt[4]; // declare a char array
void main(){
  TRISA=0XFF; // PORTA is input
  TRISC=0X00; // PORTC is Output
  TRISD=0X00; // PORTD is Output
  ADC_Init(); // Initialize ADC module with default settings
  Lcd_Init(); // Initialize Lcd
  Lcd_Cmd(_LCD_CLEAR); // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
  Lcd_Out(1,1,”Welcome to”); // dsiaplay the welcome logo on the LCD screen at position ROW=1 COLUMN=1
  Lcd_Out(2,1,”help2educate”);
  delay_ms(5000); // keep displaying logo for 5s
  while(1){
  Lcd_Cmd(_LCD_CLEAR); // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
  inputread = ADC_Read(0); // Read analog value from channel 0
  delay_ms(2000);
  inputmeasured=(inputread*4.88)/1000; // converting to value
  actualvoltage = (inputmeasured/0.019); // retreiving actual input voltage by multiplying wiht turn ratio. Actual turn ratio is 0.020 however
// multiplying with 0.019 because 0.001 accounts for losses in the resistors and rectifier.
  floatToStr(actualvoltage , txt); //convert float variable value to characters to be displayed on the LCD
  delay_ms(5);
  lcd_out(1,1,txt); // dsiaplay the input voltage value stored in character text on the LCD screen at position ROW=1 COLUMN=1
  Lcd_Out(1,8,” V Input”); // dsiaplay the character input volts on the LCD screen at position ROW=1 COLUMN=5
  delay_ms(1000); // wait 2s before taking second value
  if(actualvoltage<160) // if voltage below 160V
  {
  PORTD.F0 =0; // disconnect tapping 1
  PORTD.F1 =0; // disconnect tapping 2
  PORTD.F1 =0; // disconnect tapping 3
  PORTD.F3 =0; // disconnect tapping 4
  Lcd_Out(1,1,”Volts below 160″); // dsiaplay the message on the LCD screen at position ROW=1 COLUMN=1
  Lcd_Out(2,1,”load disconnected”); // dsiaplay the the message on the LCD screen at position ROW=2 COLUMN=1
  }
   if(actualvoltage>160 && actualvoltage<=180) // if voltage between 160 & 180V
  {
  PORTD.F0 =1; // connect tapping 1
  PORTD.F1 =0; // disconnect tapping 2
  PORTD.F2 =0; // disconnect tapping 3
  PORTD.F3 =0; // disconnect tapping 4
  }
  if(actualvoltage>180 && actualvoltage<=200) // if voltage between 180 & 200V
  {
  PORTD.F0 =0; // disconnect tapping 1
  PORTD.F1 =1; // connect tapping 2
  PORTD.F2 =0; // disconnect tapping 3
  PORTD.F3 =0; // disconnect tapping 4
  }
  if(actualvoltage>200 && actualvoltage<=220) // if voltage between 200 & 220V
  {
  PORTD.F0 =0; // disconnect tapping 1
  PORTD.F1 =0; // disconnect tapping 2
  PORTD.F2 =1; // connect tapping 3
  PORTD.F3 =0; // disconnect tapping 4
  }
if(actualvoltage>220 && actualvoltage<=240) // if voltage between 200 & 220V
  {
  PORTD.F0 =0; // disconnect tapping 1
  PORTD.F1 =0; // disconnect tapping 2
  PORTD.F2 =0; // disconnect tapping 3
  PORTD.F3 =1; // connect tapping 4
  }
  if(actualvoltage>240) // if voltage above 240
  {
  PORTD.F0 =0; // disconnect tapping 1
  PORTD.F1 =0; // disconnect tapping 2
  PORTD.F2 =0; // disconnect tapping 3
  PORTD.F3 =0; // disconnect tapping 4
  Lcd_Out(1,1,”Volts above 240″); // dsiaplay the message on the LCD screen at position ROW=1 COLUMN=1
  Lcd_Out(2,1,”load disconnected”); // dsiaplay the the message on the LCD screen at position ROW=2 COLUMN=1
  }
  delay_ms(4000);
}}

Check Also

Digital Frequency meter for sine waves

This article describes the design and construction of microcontroller based digital frequency meter. The circuit …

4 comments

  1. Hi, can you pls send me the hex file for the program pls,

  2. Please send me a HEX FILE for the code, my is not running please,

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

*