## Monday, February 17, 2014

### Automatic voltage stabilizer (AC-AC) with PIC16F873A - circuit, explanation, PCB, source code, videos and loads of pictures!

PCB images:

Schematic (2 parts):

Parts list:

Youtube videos of the automatic voltage stabilizer (in Bangla and in English):

1. nice post sir plz do a project on z source ac to ac boost voltage regulator (transformer less stabilizer)

2. Great effort as usual thanks for the knowledge shared. please can you give a circuit of the input Voltage sensing especially the resistors. I guess u finally used the 47k resistors in series which gives 282k (47kx6) and in parallel with 3k3 resistor. Am i rite?

Doing a little calculation:

230v Ac = 325v Dc (after rectification and filtering.)

using voltage divider rule

vout = vin x r2/(r1+r2)

r1 = 282k, r2 = 3k3, vin = 325vDC

then vout will be ~ 3 to 3.5v Dc.

1. is this how you come about the input voltage conversion and sensing? and please what re the power rating of the resistors.

2. the filtering cap after the rectifier, is it polarised or non-polarised

3. what is voltage rating of the capacitor after the rectifier.

thanks

1. Yes, that's how I got there. Except, for the AC to DC, I didn't use 1.4142 but 1.3836.

The bulk filtering capacitor is polarised. The one on the voltage sense section (high voltage section) - C1 - is to be rated for at least 450V.

Regards,
Tahmid.

2. Hello Tahmid,
The code is not working. First I compile with MikroC Pro, it compile with errors. I've corrected the errors it compile but no reactions at all. No display, no blinking or even a spark.

3. Hi again, I was going through the code and i must say you ve really done a very good job in creating a good algorithm within a short time.
But i just want to be clear about the something in the code.

You said 6 X 47k ohms resistor in series and 3k3 ohm were your final selection for the voltage divider. but this portion of the code says otherwise.

//Voltage_FLOAT = Voltage_FLOAT + 1.5;
/* Use 100k and 1k resistors for voltage division
* Divide by 1.3836 to convert from DC voltage to AC
*/

2. please can you throw more light on this (Voltage_FLOAT = (float)((float)ADC_Get_Sample(Vin_CHANNEL) * 5.0 * 101.0 * Kc) / (1.3836 * 1023.0);)

3. how did you get the value of 1.3836

thanks

1. 1) Sorry for the confusion. The code should be updated. I initially used 100k and 1k for the voltage divider. That is almost the same as using 6x 47k resistors and a 3.3k resistor (in series). Using 6x 47k and a 3.3k resistor instead helps reduce the power consumption. You'll get more information about this in the article I wrote.

2) and 3) ADC_Get_Sample gets the ADC digital output (10-bit: 0 to 1023). The *5.0 and / 1023.0 scale the ADC result to a 0.0 to a 5.0 (a little less actually) level that represents the actual voltage present at the ADC input pin. 101 is the multiplication factor to get to the actual DC voltage level. Kc is the scaling factor (as saved previously in the EEPROM as the calibration value). 1.3836 is my measured AC to DC conversion ratio. I noticed (upon measurement) that my DC voltage was 1.3836 times the AC RMS value and not 1.414. So I just used that.

Hope that helps.
Tahmid.

2. thanks for your candid explanation, i am very grateful.

but please can you explain this too.

//Voltage_FLOAT = Voltage_FLOAT + 1.5;

thanks

3. That was just for my testing - to test for an "offset". You can ignore that - that's why I commented it out.

Regards,
Tahmid.

4. Have you built the circuit and tested it?

5. To be candid i might not really make this circuit, but i am going to use a lot from the code and part of the circuit in making my next inverter. Particularly the calibration part of the code, the AC measuremaent for feedback (i ve been having issues with these for a long time). Now i know how to measure the AC voltage and display a correct value using your code and following your explanation. Well maybe i cud include tapping on the xformer and make the inverter also behave like a regulator. But truly i m going to copy a lot from the code.

I am a very huge fan of proton basic. I have to convert all your code to basic so it takes a while due to syntax differences. But I am learning Mikro C already so i might migrate fully to using C to develop my code.

ABM

4. Thanks for sharing the knowledge.
1) Kindly tell where the calibration pot is located ? Is it a part of voltage sense section ? or it is separately connected to the micro-controller.
2) whats the value of calibration pot?
3) whats the value of capacitor connected at the output of voltage sense section (that was referred in the article as being parallel to the adc input capacitance)

1. 1. According to the article and the code writeup, the calibration pot is on one of the ADC pin of the micro
(const unsigned char CalibratePot_CHANNEL = 1;) which means AN1 of the micro check the datasheet of the micro search for the pin that has AN1 then u wil get the pin number

2. He mentioned 5k if i am correct

3. he said between 10uf to 33uf but he said he chose 22uf.

hope it helps

2. According to the article "To ensure that the ADC measured the low-voltage DC level properly, a capacitor was placed at the output of the voltage divider section such that this would act as a parallel capacitance to the internal one (of the ADC)." I am referring to this capacitor value. I think the 22uf capacitor is used as a high voltage (450dc) filter capacitor (to convert AC to DC) in the voltage sense section. Moreover, the article does not mention the value of calibration pot. I am confused whether this 5k pot is part of sense resistors or it is separate. The schematics can clearly show this.
hope u understand my point
Thanks

3. The parallel capacitance is 0.1uF (100nF).

The calibration pot is a 5k pot.

Regards,
Tahmid.

5. i my possible we can show input voltage value , output voltage value , output current in amp & output power in watt or kwatt ?

1. Yes it is, but then modifications need to be made since the PIC does not have enough pins left.

Additionally, it may be better to switch to an LCD screen if all those parameters are to be shown.

Regards,
Tahmid.

2. its PIC16F873A Pin Configuration

*
* O = Output
* I = Input
*
* ________
* MCLR | 1 28 | RB7 --> (O) == DIGIT1 CC H CA
* ADC1(I) --> AN0 | 2 27 | RB6 --> (O) == G CA
* ADC2(I) --> AN1 | 3 26 | RB5 --> (O) == F CA
* DIGIT2 CC == (O) <-- RA2 | 4 25 | RB4 --> (O) == E CA
* ADC3(I) --> AN3 | 5 24 | RB3 --> (O) == D CA
* Delay_SW (I) --> RA4 | 6 23 | RB2 --> (O) == C CA
* DIGIT3 CC == (O) <-- RA5 | 7 22 | RB1 --> (O) == B CA
* Vss | 8 21 | RB0 --> (O) == A CA
* OSC1 | 9 20 | Vdd
* OSC2 |10 19 | Vss
* RL4 == (O) <-- RC0 |11 18 | RC7 --> (O) == LED_HILO
* RL3 == (O) <-- RC1 |12 17 | RC6 --> (O) == LED_NORMAL
* RL2 == (O) <-- RC2 |13 16 | RC5 --> (0) == LED_DELAY
* RL1 == (O) <-- RC3 |14 15 | RC4 --> (0) ==
* ---------

I'm right ?

6. where its Schematic diagram ?

1. I haven't yet completed drawing the schematic on the computer. I have it drawn by hand. I'll upload it soon when I finish drawing it.

Regards,
Tahmid.

2. how can open PCB_v9.LYT ?

7. u can use ExpressSCH for draw Schematic diagram .it is very easy for Schematic diagram

8. This comment has been removed by the author.

9. pl tell me
how can open PCB_v9.LYT ?
or give the link its PDF ver.

10. pl up load drawn by hand Schematic diagram .

1. hi Mr.. Tahmid.pl post or mail me its sch diagram .
shivendrakumarsahu@gmail.com

11. Hello Thamid. I have a question about a PWM Full Bridge Primary Current waveform. I read a lot about it. Nobody could give me an answer. Please, where can I find you? Thks! ALU

12. hi tahmid

for commercial affairs.

if you wish, please don't hesitate to contact me

rafaelholguin@yahoo.com

13. hi tahmid

for commercial affairs.

if you wish, please don't hesitate to contact me

rafaelholguin0288@yahoo.com

14. pls give me parts list

15. Tahmid Sir, thanks for creativity, I love Technology, Your post & video is most useful & helpful for Bangladeshi electronics hobbyist, now you will publish circuit diagram for complete lesson

16. Mr Tahmid, please make tutorial dc-dc converter.

17. Hi,TAHMID
I compile your given .c file and got hex.
And check with proteus all is fine except,adc module become inactive during start up delay.
Either delay is 2000ms or 3 minutes.
Adc module did not work and relays are off during delay time.
I hope you will think about it

18. Hi sir I will need your help in the same product which you had made...Automatic Voltage Stabilizer...
Previously I have one of the kit..Please see
http://www.solarindianproducts.com/automatic-voltage-stabilizer-kit.html#automatic-voltage-stabilizer-kit
I want to make prototype of this kit but not able to program the IC because I am not able to get correct algorithm..I will send you more Visible pictures..can you help me regarding this means programming the IC...yours...Lucky

19. WHERE IS PART LIST AND SCHEMATIC?

1. Will be available within the next week.

2. Thank you soo much for the fast answer !!! :)

20. how we design automatic voltage stabilizer for any range of input and tell us formula for calculation, please help me,

21. Thank you very much, greetings from Serbia

22. please post Fuse bit ...

1. Oscillator = HS
Watchdog timer = Off
Power up timer = On
Brown out detect = On
Low voltage program = Disabled
Background debug = Disabled

Code protect is up to you.

23. Hi boss, Which software can I use to open lyt file?

1. Proteus ARES. I've added image versions of the file so if you don't have Proteus you can use the image version.

24. dear tahmid sir
i am aneesh, i like your tutorial, i gained too much knowledge from you

i have 1 doubt sir,i am making 700va high frequency inverter using sg3525, in that circuit (CT-3.3nf,,,RT-6.8k and RD-47E)are used, then what will be the frequency,,if 66khz HF transformer frequency will be half of that, please help me sir,
which core better ETD 55 or EE55 please replay me

thanks@regards

25. Hi bhai, ami apnar c file dia hex compile korar chesta korsi kintu ekhane error dekhasse. Ami mikroc pro use korsi. Apni ki kindly hex kore dite paren. hex file ti dite parle upokar hoto. Thanks

26. Hi boss, can you post pcb and parts list without led display?

1. The 7 segment display is used to calibrate the unit. So, it should be added. However, if you feel like skipping it, you can just omit it once calibration is done.

27. Hi bhai, ami 16f873a id ta dhaka er market a passi na. Ami akhon ai ic er alternate kon ic use korte pari kindly janaben.

1. You should be able to find the 16F873A easily. Did you look for it at Patuatoly?

28. Hi boss, Make another voltage stabilizer using pic without display. I think this is very hard to make it for me.

29. hi, sir i am rajeev from patna, i am making 90v-280v ,16f676 based,relay voltage stabiliser kit,with lo,hi,cut,&timer,with 7 segment voltage display,extra facility- lo cut on off switch,quick start switch with LT supply.

thanks

30. hi, dear brother that u done is great,,,but i need some help about programing that ic i also need its programing data ( Hex ) & how can i program in ic,,,& thanks a lot....

31. do u have a skype to talk my skype marcony641

32. Hi Mr. Tahmid can I have ur email

34. Ok..the link doesnt work for hex file. Copying the text and pasting in a new browser window gives the hex fle. Correct it if possible.

35. hello sir, i am a new student of microcontroller.... i want to use PIC16F877A & proton Ide coading. will u help me?? and i want your ready-mate pcb board.....please sent me your instruction....this is my email: arifmishba@gmail.com & contuct number is: 01824294744

1. I have not used Proton and will likely not be able to help you in that.

If you have any general PIC questions, feel free to email me at inferno (hyphen) rage (at) hotmail (dot) com

36. dear Tahmid , its work very nice .have some problem in code .
when mcu intered in delay mode adc not work , its then , when mcu exit form delay mode .
pl guide us .
it possible Automatic voltage stabilizer (AC-AC) with with out relay ,we can use IGBT for AC-AC regulation ?
if yes pl do something .i konw u complet this task before telling me .
if u cont post here due to commersicail rigion ,pl mail me those source cost.

37. Hello Tahmid I need 10 volt step not 25 volt and also 12 and 24 volt battery charging feature in it if possible then plz help me thanks

1. If you want to reduce the voltage step, you will have to increase the number of tappings on the transformer.

I am no longer developing voltage stabilizers and so will not further implement battery charging.

38. Always test your health with better ways ,contact us :- The Pcb test San Diego will try to gauge just what quantity of the contaminant has gotten into the soil. PCB soil contamination can be stalled if enough effort is given in the identification of the sources. It goes without saying that the pcb lawsuit California can be initiated if some company or business or enterprise is found to be responsible. Free pcb test will allow the people to know which are the problematic zones.

39. Hello sir,
Thank u

1. It is running a standard refrigerator.

40. Give me current rating of the transformer.
thank you

1. That depends on how much load you want to drive. What type of load are you driving?

41. have you tested it the generator? I had made one servo controlled stabilizer, it worked well with line voltage but when generator is on it does not work well. Output voltage increases 10V. I think there is some problem with the sensing circuit. Do let me know if you face this problem

1. Interesting.

I have not. If the generator generates 220V (standard rated) 50Hz sinusoidal AC, I don't see why there should be an issue. What type of generator was it? Do you have a model no.?

42. Hi Tahmid it's me Derrick from Uganda am trying to build your automatic stabiliser based on the PIC 16F873A.I have finished the PCB but I have one question and it's on the 3 digit 7 segment display.1-i want to know what is its inches? 2-Is it a common Anode or a common cathode 3 digit 7 segment display? Thanks for your help and work you do to help us learn electronics you are a teacher to many.

43. Hi Tahmid am trying to build your automatic stabiliser based on the PIC 16F873A.I have finished the PCB but I have one question and it's on the 3 digit 7 segment display.1-i want to know what is its inches? 2-Is it a common Anode or a common cathode 3 digit 7 segment display? Thanks for your help and work you do to help us learn electronics you are a teacher to many.

44. Hi Tahmid, Can u through some light on the following lines of code. I am unable to understand the logic behind the calculation of Kc

Kc = (float)(CPot * 2.0)/1023.0;
Thanks

45. Hi i designed the same circuit with atmega8 the mcu checks the input for every 22ms.......i'm using lcd instead of 7 seg..the delay bet enable pin of lcd is 600us i cant reduce it as it's not displaying properly if i reduced it............. is this normal to measure 20ms (50Hz) sine wave at every 22ms and change o/p depending on it.......will it cause damage to load within this time period.......i increased the crystal frequency but i noticed that only time consuming element is lcd..and got 16ms sampling rate

46. I built this circuit but when i switch on the power, transistor Q8 (2N2222) immediately burns up and smoke is seen coming out of it even if i replace with a brand new one same thing happens please help.

1. Is the 7 segment display used is common anode or common cathode type?

2. Is the 7 segment display used is common anode or common cathode type?

47. I have done this project and burnt the HEX code you provided but the circuit does not do anything at-all and when i short the calibration switch then the delay led goes on but without doing that the circuit just sits there doing nothing.Pliz help what do you think is the problem i have checked the circuit many times and i dont see any problem i think its in the code which i cant check.

48. my mail refatct@hotmail.com.... pls send ur cell no. it's 911

49. This comment has been removed by the author.

50. AsalaamOAliakum
Tahmid plz tell me wht is the pcb size in inch Y and X .
Thankyou.Mine email yasiralikhi2@gmail.com

51. hi tahmid brother can give me proteous simulation files or any other software filw that you used for simulation i saw you use proteous please share these file. i have on objection in your schematic part a in microcontroller circuit vrelay that is connected to diodes and vdd are act as input but on relay circuit in part b vrelat is a power source

52. AsalaamOAliakum
Tahmid plz send me display actual size pcb.Thankyou
Email yasiralikhi2@gmail.com

53. great job, but still don't understand about auto transfmormator make me confuse. it's the common transformator step down type (0,110,220 for primary winding, and 0, 12.5,25,....,165,195,etc),or anything type, i'm waited for the answer, tx

54. This is fantastic brother .... speechless ... m hobbyist and i'll make this as my 2nd semester project m using jwm programmer ... u didnt shared proteus isis file , if u do i'll be too much thankful... may God give u more success in serving people , www.creativeeagle.blogspot.com

55. vfdghdfghcc

56. sir
i am new student in microcontroller.i want to make a voltage stabilizer.how to sense input voltage in micro c.to switch output relay.

57. would you tell me about the primary voltage range and turn ratio and amperes. because i want to run 2000 watt load.. please tell me as soon as possible.. and you designed a nice circuit. My email is "allahhooooo@gmail.com".

1. please tell me whole specification about transformer. from primary to secondary...

58. is it necessary to use an auto transformer with a particular tap voltage ratio or any kind of auto transformer of 120v-270v will work?

59. Online ups system - Find here online ups system manufacturers, suppliers in delhi, India. We provide online ups system manufacturers in delhi, India. VIEW MORE :-Online UPS System in India

60. good job. i have used the code and as well redesigned it to suit my needs. welcome

1. good job, Did you made the proteus schematic to work?

61. Dear Tahmid, thank you very much for a well designed circuit ! I am beginning to learn little bit of electronics from you blog.
Here we have power supply problems, anything between 100v to 290v ! Would you be kind enough to modify your Stablizer circuit and program to address this issue? I plan to use a 2KvA Transformer to feed my house wiring as per output voltage(s)designed from your end(if possible). Thank you very much in advance.
With kind regards
Imsa Naga
imsayuba@gmail.com

62. Can I further request you to modify your code/circuit to use 16x2 LCD in place of 7 segment display ? I am new to PIC programming but can transfer codes to PIC!
Thanks again.
Imsa Naga

63. hi sir,
Please give your mail id and contact no. my mail id vasuvit@gmail.com 8838899551.

64. http://acecct.blogspot.com.ng/2015/11/microcontroller-based-avr.html?m=1

65. can u upload c code for avr chip?

66. Thanks for this interesting project. Please I want to know the type of 7segment display you used. Is it common anode or common cathode.

67. bai plz u give patrs velu

68. An auto transformer is the one that shares single winding and sometimes recognized as the Auto step down transformer. Their single windings perform the task for both the windings and give you the exact benefits like an ordinary device. They are economical in nature and occupy only limited space. There are a number of applications where an Auto Transformer is used especially in induction heater applications.

Transformer Manufacturers In India | Auto Transformer Manufacturers

I need one stabilizer and transformer.

70. Please I did the circuit pcb and all works but when I power after calibration it shows the High/low led and nothing happens. The calibration seems working well and have been set properly. I need help urgently.

71. Very nice and informative blog. I like reading your blog regularly. Keep sharing such amazing information.

72. hello bro,

I open the source code in MPlab IDE. but it show compile error. can you tel me the IDE you used please....

Regards
Partho

73. Informative blog! Thanks for sharing useful information with us. We are leading manufacturer of Servo Voltage Stabilizer .

74. The issue is that as a student Automatic Driving Lessons Walsall in the beginning times a great many people think that its hard to work these controls easily while directing and planning for street intersections or different circumstances that emerge when driving, this can frequently prompt slowing down the auto because of issues while switching gear or ceasing by neglecting to utilize the grasp pedal.

75. Hello Syed Tahmid Mahbub.
I open the source code in MPlab IDE or PICC, and it shows compile error. In which compiler you have compiled your source code.

Hugs,

1. He mentioned Mikro C pro

76. Hi sir I'm intrusting in programming pic can you help me sir.

77. I really enjoyed reading your post. We at Enertech also brings Voltage Stabilizers for the clients that are widely accepted for providing constant voltage even under unbalanced electric conditions. Our stabilizers are appreciated for their salient attributes like reasonable prices, stable output and free warranty. We make sure that our clients are provided with the stabilizers that are stringently tested on various parameters.

78. Hello Tahmid,
Please, I just assembled your PCB as it is and load the Hex file onto the ship as it is but there's no response at all. Power to the chip is ok at 5.0V and any other points received supply.
Please, is there any issue with the Hex for I've troubleshoot a lot even the code could not compile on MikroC pro.

a certain portion of the code ""while (ADC_Get_Sample(CalibrateSW_CHANNEL) < 512){ // While Calibrate switch is PRESSED""

Thanks.

79. what this code does

why u mtlply kc by 10000 if it btwn 0.00 to 2.00 why not mltbly by 100

80. This information is very useful for me. Thank you. For more details Click Here

81. Thanks for this tutorial! By the way, here is a post about businesses which needs avr.

82. Your blog post is very descriptive and love to read it. Thanks for sharing. I am working in Voltage stabilizer manufacturer company and after reading your blog I improve my knowledge.
Thanks for information.

83. The information is very nice and useful to users and manufacturer both ! if you are looking for the automatic Stabilizer for ac you can find the best Servo Stabilizer at Raju Electricals

Servo Voltage Stabilizer
Transformer Manufacturer In Noida

85. That was such an awesome topic to read and going through it.
Thanks for such a good information.
Our product related for Servo Voltage Stabilizer and Power Transformers Manufacturer in Hyderabad, india. Our company is also Servo Stabilizers Manufacturers in Hyderabad, bangalore, India.

86. That was such an awesome topic to read and going through it.
Thanks for such a good information.
Servomax Ltd
Our product related for Servo Voltage Stabilizer and Power Transformers Manufacturer in Hyderabad, india. Our company is also Servo Stabilizers Manufacturers in Hyderabad, bangalore, India

87. Hi Tahmid, we like to hear such awesome information, we are in the field of voltage stabilizer manufacturer and supplier for more than 60 years the information you shared here is 100% correct our point of views. It is very difficult to collect all information and write a blog on such a topic that not an easy task. Thank you for sharing this content. We also use this information for our website www.ieco.in you can also check and tell us if there is any correction needed.

Thankyou
IECO INDIA GROUP

88. Hi Tahmid, we like to hear such awesome information, we are in the field of voltage stabilizer manufacturer and supplier for more than 60 years the information you shared here is 100% correct our point of views. It is very difficult to collect all information and write a blog on such a topic that not an easy task. Thank you for sharing this content. We also use this information for our website IECO INDIA you can also check and tell us if there is any correction needed.

89. Congratulations

90. Nice information

91. Dear sir,
I want to make the same automatic voltage stabilizer for my project but i don't know how to make the pcb. So could you help me out. What is circuit diagram and pcb layout for this project.

92. Dear sir,
I want to make the same automatic voltage stabilizer for my project but i don't know how to make the pcb. So could you help me out. What is circuit diagram and pcb layout for this project.

9870128641 my no.

93. Thanks for providing a such useful information.
If you want to purchase stabilizer, transformer and electrical panel so visit innorade manufacturing private limited company.
Servo voltage stabilizer, transformer, electrical panel