In this article, we are going to learn how to make a simple voltage protector for your appliances. A small device can save lots of money, saving your appliances from voltage spike/surge/sag and unacceptable voltage range. So let’s make it!

Disclaimer: Electricity is always dangerous. Proper skill is required to work with electricity. Do work at your own risk. The author will not be responsible for any misuse or harmful act or any mistake you make. The contents of this website are unique and copyright protected. Kindly don’t do any nonsensical act copying and claiming it as yours. Most of the articles published here are kept as open-source to help you. Take the knowledge for free and use it, but if you are interested you can buy the ready resources offered here. If you need any help or guide feel free to comment below, the author will try to help you. Thanks.

What is spike/surge/sag?

Usually, your home supply voltage is either 220V or 110V depending on your region. But this voltage is not always constant. Due to various issues (like switching a large load or line faults and so on) this line voltage can carry a high or low voltage pulse for a short period of time. A voltage spike is a sudden increase in voltage that lasts for less than three nanoseconds & A sudden increase in voltage that lasts for three nanoseconds or more is called a voltage surge.

Voltage sag on the other hand is similar but a sudden voltage drop due to other loads like a heavy motor or heavy switch is turned on. This may also hamper your appliances creating a sudden voltage drop which can generate a restarting issue.

A surge can burn the internal components of your appliance if there is no protection for the spike. Especially the electronic devices are mostly affected by spike & surge. Sag can also damage your appliance but a burning case is rare. A Sag normally interrupts the operation like your PC can be restarted while you are working on an important task on your PC.

These are sudden problems but besides this, a high or low voltage also can happen.

High/Low voltage effect on appliances:

A high or low voltage can appear on your supply line and can stay for a while. That definitely will damage your appliance if it is out of tolerable range. Some appliances may have internal protection but most of them have nothing.

Low voltage also can damage your appliances especially the inductive loads like motors. Because, due to low voltage the motor can stop rotating and once the rotation is stopped, a high current flows through the coils. That kills the coil.

High voltage can also burn the appliances but inductive loads can take little high voltage for a while without problem. Electronic appliances are mainly get harmed due to high voltage.

Protections:

For surge/spike, a MOV or metal-oxide varistor can be used. But complete isolation is always better.

A fuse in first and then a MOV in parallel with the load can effectively protect the appliances from the spike.

This can be applied only for spike/surge but for sag, there is no such easy way to prevent it without using some kind of complex circuit. You can convert the AC supply into DC, store it in capacitors, step up a little bit, then again convert this DC into AC. This way sag can be prevented. But in simple, cutting off the line is possible for while.

Our solution:

To make a device to prevent voltage issues, we can use microcontrollers with some associative circuits. A display can make it user-friendly. So let’s make the circuit diagram first.

Circuit diagram:

Circuit Description:

First, you may use any pins serially for the display but here in my circuit, I used without any serial because of my PCB design. I designed keeping in mind the PCB first. Anyway, among other parts of this circuit is a capacitor power supply.

You can read my article on capacitor power supply from here.

This power supply is suitable for small loads like our project here. The benefits of this type of power supply are these are extremely cheap and durable. One can last a long period of time. One of mine is being running since 2014. Here the circuit is simply reducing the AC 220voltage into 12V DC across the D1. Then a 5V regulator makes a 5V output for our MCU. R3 is important for longer operation and R1 is important to reduce inrush current through C1. C1 should be X2 type, but you can use other types of similar ratings if its quality is good.

On the left side, VR1 is a varistor (MOV). You can keep the Fuse and MOV out of the PCB if you want. In my case, I kept it outside PCB and these are directly fit with the input and output line. Relay here is used for bypassing the input to output.

I used some resistors for sensing the line voltage directly as we are not touching the circuit while it is operating. So, we can use resistors for measurement rather than using any other isolation or transformers. The concept is pretty easy, R9 + RV1 are used to make the fine-tune job. & R8+C6 are for the R-C filter.

PCB:

As I always try to make anything like a usable product, so I design PCBs for them. Similarly here for this project, I designed my PCB and printed it from JLCPCB.com. You can follow my design or you can do it yourself.

And in real life the circuit is:

Programming:

I use mikroC pro for PIC from programming PIC MCUs. Here is the basic code of our voltage protector.

/*******************************************************************************
Program for Dual Display voltage Stabilizer v8.2
Program Written by_ Engr. Mithun K. Das; mithun060@gmail.com
Compiler: mikroC pro for PIC v7.6.0; Xtal:8Mhz; Date: 10-04-2021
*******************************************************************************/

//pin declerations
#define   a        RB5_bit
#define   b        RB7_bit
#define   c        RC5_bit
#define   d        RB0_bit
#define   e        RC7_bit
#define   f        RB6_bit
#define   g        RB4_bit
#define   dot      RC6_bit

#define   D1       RB1_bit
#define   D2       RB2_bit
#define   D3       RB3_bit

//relays
#define  Relay    RC3_bit
#define  LED      RC4_bit



void mark(int digit)
{
  switch (digit)
  {
     case   0: a=0;b=0;c=0;d=0;e=0;f=0;g=1;dot=1;break;
     case   1: a=1;b=0;c=0;d=1;e=1;f=1;g=1;dot=1;break;
     case   2: a=0;b=0;c=1;d=0;e=0;f=1;g=0;dot=1;break;
     case   3: a=0;b=0;c=0;d=0;e=1;f=1;g=0;dot=1;break;
     case   4: a=1;b=0;c=0;d=1;e=1;f=0;g=0;dot=1;break;
     case   5: a=0;b=1;c=0;d=0;e=1;f=0;g=0;dot=1;break;
     case   6: a=0;b=1;c=0;d=0;e=0;f=0;g=0;dot=1;break;
     case   7: a=0;b=0;c=0;d=1;e=1;f=1;g=1;dot=1;break;
     case   8: a=0;b=0;c=0;d=0;e=0;f=0;g=0;dot=1;break;
     case   9: a=0;b=0;c=0;d=0;e=1;f=0;g=0;dot=1;break;
     case  10: a=1;b=1;c=1;d=1;e=1;f=1;g=1;dot=1;break;
  }
}

void InitTimer0()
{
  OPTION_REG     = 0x82;
  TMR0           = 68;
  INTCON         = 0xA0;
}

int cnt=0,disp_digit[6];
unsigned int number1=0,number=0;
unsigned int display1=0,display2=0;
bit dot_en,delay_toggle;
int min=0,sec=0,loop;
unsigned int line_voltage=0,output_voltage=0;
long max_point=0,temp=0,line_voltage_raw=0,output_voltage_raw=0;
unsigned int k=0,i=0;


void convert_digit()
{
   disp_digit[0] = number/100u;
   disp_digit[1] = (number/10u%10u);
   disp_digit[2] = (number/1u%10u);

}


void Interrupt() iv 0x0004 ics ICS_AUTO
{
  if (TMR0IF_bit)
  {
      TMR0IF_bit = 0;
      TMR0  = 68;

      number = display1;


      if(cnt==1)
      {
         mark(disp_digit[0]);
         D1 = 1; D2 = 0; D3 = 0;
      }
      else  if(cnt==3)
      {
         mark(disp_digit[1]);
         D1 = 0; D2 = 1; D3 = 0;
      }
      else  if(cnt==5)
      {
         mark(disp_digit[2]);
         D1 = 0; D2 = 0; D3 = 1;
      }

      else
      {
         mark(10);
         D1 = 0; D2 = 0; D3 = 0;
      }

      if(cnt>=9)
      {
         cnt = 0;
      }
      cnt++;
  }
}



void Read_input_voltage()
{
     //read input voltage
     ADCON1 = 0x04;
     ADCON0 = 0x01; //AN0
     line_voltage_raw = 0;
     max_point=0;
     temp=0;

     for(i=0;i<10;i++)
     {
         for(k=0;k<600;k++)
         {
            if(temp=ADC_Read(0),temp>max_point)
            {
               max_point = temp;
               Delay_us(1);
            }
            asm CLRWDT;
         }
         line_voltage_raw+= (max_point*218/151);
         asm CLRWDT;
     }
     line_voltage=0;
     line_voltage=(int)line_voltage_raw/10; //get average value
     line_voltage_raw=0;
     ADCON1 = 0x07;
     ADCON0 = 0x00; //AN0
}




 

void main()
{
  TRISA = 0b00010011;
  TRISB = 0x00;
  TRISC = 0x00;//all output
  PORTC = 0x00;
  PORTB = 0xFF;


  ADCON1 = 0x04;//ADC settings
  InitTimer0();
 

  display1 = 0;
  convert_digit();
  Delay_ms(15000);//initial delay for 15s



  while(1)
  {
     


     Read_input_voltage();

     display1 = line_voltage;
     convert_digit();
     
     if(line_voltage>175 && line_voltage<245)
     {
         LED = 1;
         Relay = 1;
     }
     else
     {
        LED = 0;
        Relay = 0;
        Delay_ms(10000);//10sec       
     }


  }//while(1)
}//end of void main()


//

Once you learn this basic code, you can add other features with this product as I did in mine. But this basic code also works fine with your circuit.

There are other functions you can add like delay display, high or low voltage indication, transient trip, permanent trip, and so on.

Result:

Here is my product, I tested with added features.

If you are interested in this project, you can make one for yourself using the above resources. Besides, if you are interested to use my design files and codes, you can buy them from here too.

Conclusion:

You can make one or you can get one, it’s your choice. I gave you both options. But to make a product it needs time and money, so if you want to get one you should pay a little for that. But it’s not forced on you at least. It’s your choice. Anyway, if you read the above article, it will be easy to make your own voltage protector. Thanks, see you in the next article soon.

Loading

JLCPCB – Only $2 for PCB Prototype (Any Color)

24 Hours fast turnaround, Excellent quality & Unbeatable prices

$18 Welcome Bonus for new registrations Now!!! https://jlcpcb.com


You may read this article too: Voltage Stabilizer Circuit with 4 Relays.


Lab Projects BD

This is a personal electronics blog. The author loves to write on different topics and shares his knowledge to help others.

2 Comments

R K Hamy · October 24, 2021 at 10:57 am

Many Thanks.

Joy · October 25, 2021 at 8:27 am

Nice. Many Many Thanks.

Leave a Reply

Avatar placeholder

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