Saturday, February 4, 2012

30 volts Panel Volt Meter Using PIC MCU

       This is a simple application of internal 10-bit ADC(analog to digital  converter) of PIC16F676 microcontroller.you can use this  circuit  to measure  up to 30 v dc. the possible  applications are on bench top power supply or as a panel meter in various system.

Circuit description 
            MICROCHIP'S PIC16F676 is the heart and brain of this circuit .the internal adc of the mcu with a resistor network voltage  divider is used to measure the input voltage . then 3 digest of comm anode 7 segment display is used to display final converted voltage. as you can see in the schematic the displays are multiplexed with each other . means we switch on one display and put the corresponding digit on this while other two displays are off this cycle go for each of the display.

you can find more about driving multiplexed 7 segment led display from a pic mcu in application note from microchip AN557 Four Channel Digital Voltmeter with Display and Keyboard

in my circuit the refresh rate is about 50hz.



 Voltage Divider Front End



as you can seen in the schematic the 47k resistor and 10 k trim pot is connected ias a voltage divider configuration  .we all know very well that by default pic micro controller ADC reference voltage is set to vcc(+5v in this case) . so what we have to do is make such voltage divider that can divide out maximum range 30 volts to 5 volts . so we need is Vin/6 ==> 30/6 =5v   voltage divider . and to keep as less as possible attenuation on the under test voltage we have to keep the voltage divider resistor value in few thousand ohms because it takes very little current from the target but as much to drive adc of pic.

calculation   
10bit adc resolution we get 1023 maximum count
with 5 v reference  we get  5/1023 = 0.0048878 V/Count 
means if the adc count is 188 then input voltage is 188 * 0.0048878 == 0.918 volts 


but now with the voltage divider  the maximum  voltage  is 30v so the calculations  
will be  30/1023= 0.02932 volts/count
if now we get 188 then 188*0.02932==5.5 Volts


you can also increase  or decrease  the range by changing resistor network and the calculations a little bit.

the capacitor 0.1uf makes the adc input a bit stable because 10bit adc is really sensitive .
the 5.1v zener will provide over votage protection to the internal adc because it wont allow voltage more than 5.1v.
Accuracy and calibration 
overall  accuracy of this circuit is great but it totally depends on the values of 47K resistor and 10k trim pot . as fine as you can go by adjustment of the trim pot your accuracy goes fine.


calibration of this circuit is done by adjustment of the 10k trimpot around value of 7.5k or so .
all you have to do is take any standard power like 5v or 12v and apply that to the input of the resistor network and adjust the trimpot until you get correct value on the display


PCB



Software  Sorce code and Firmware
the sotware is written in c and complied using hi-tech compiler

click here download firmware  and source code 


you may also like  MSP430 BASED 30V VOLT METER

48 comments:

  1. tnx for this post. its vary useful ........

    ReplyDelete
  2. i have a question, what means the "Pot" who arrows to 10k resitor

    ReplyDelete
    Replies
    1. that's a variable resistor whose value may go 0 Ohm to 10 K ohms

      Delete
  3. this is the best project for me and best regard

    ReplyDelete
  4. PLS SEND PCB TRACK IN PDF FORMAT TO rajeevexcelelectronics@gmail.com

    ReplyDelete
  5. nice work
    pls give author phone number

    ReplyDelete
  6. describle the HT07S function

    ReplyDelete
  7. does this software is good? i just concern co'z i gonna use this project as my main project and needed to be past. please help thanks.

    ReplyDelete
    Replies
    1. software is fine quality.

      but if you want to use for commercial product then i guess need to be few more fail safe mechanism.

      Delete
  8. thank you, the software is really fine, but my problem right now is that the 1st seven segment connected in pin 12 is not working while the other two is good. please help thanks.

    ReplyDelete
  9. sir, can you make me a simple explanation regarding on how the PIC compute the Input voltage. thanks.

    ReplyDelete
  10. Hello I am trying to simulate this project but I can't understand what is the clock frequency of the PIC. So what is the clock of the PIC and does it use RC generator?

    ReplyDelete
    Replies
    1. yes, the clock is set to internal RC oscillator, it is being defined in the second line of the source code with the other configuration settings

      Delete
  11. hey i am using PIC18f23k20 and i want to monitor the the voltage using the internal ADC and display it on the 16'4 LCD display(basically a digital voltmeter), i am not able to figure out how to convert the 10 bit ADC output into volts and Display it on the LCD the resolution while displaying on LCD has to be of 10mV. The input voltage to the ADC will be varying from 9-19 volts, so i want to know what is the maximum voltage that can be supplied to a PIC micro controller port pin in analog and digital mode. also i want to know what is the maximum reference voltage that can be supplied externally to the inbuilt ADC.
    my email id is ashish3366@gmail.com
    thanks a lot in advance!!!

    ReplyDelete
  12. Hi,
    What is the actual size of the PCB of this project...

    ReplyDelete
    Replies
    1. the size of the board which shown in the images is 5cm*6cm

      Delete
  13. Hi,
    Can I use another PIC with the Circuit Diagram?
    PIC's to be used are PIC16F628A, and PIC16F876A

    ReplyDelete
  14. I make this in SMD 4cm x 4cm and I get very unstable 3 digit.

    I use 7805 regulator. 12,12V is input volt and output is stable 5,05V. I use the same power source for power supply and for ADC.

    Measured voltage is 12,13V-12,14V.

    On ends of pot I measure 2,03-2,04V.

    On LED display third digit changing from 1 to 2 very frequently.

    Why third digit changes constantly? With unimer I check its around 12,13V only changing "C" digit (xx,xC).

    ReplyDelete
  15. On pot ends 2,04V is stable, but on LED third digit changing.

    Its like he present real 4-digit from unimer, as 3-digit on led.

    ReplyDelete
  16. On pot ends stable 2,03V

    On LED display 12,1V-12,2V changing frequently.

    Input voltage (unimer measure) 12,13V-12,14V changing frequently.

    Why 3-digit on led changing is not stable, in this case "1"?

    ReplyDelete
    Replies
    1. can you send me your pcb desing files ..

      Delete
    2. Of course I can, but I need address.

      Delete
  17. I solve this problem, with big help of Gaurav Chaudhary. I replace 100nF with Tantal 2,2uF on ADC input. Voltage on 3-digit is now ok.

    Regards

    ReplyDelete
  18. Hi, I translated your article in Russian, suddenly someone will be useful - Простой встраиваемый вольтметр 30В на PIC16F676
    http://radioaktiv.ru/shems/measure/478-prostoy-vstraivaemyy-voltmetr-30v-na-pic16f676.html

    ReplyDelete
  19. I love this article, it's a great work well-explained. I'm new to the use of PIC or MCU but I hope that very soon, I'll learn it. Thanks

    ReplyDelete
  20. can you give details information about this..i need it as a reference in my project

    ReplyDelete
  21. Hi
    it's a fine project, very simply to make it,
    but i want to made some changes, i need it to measure 90V, but the "htc.h" in MLAB IDE isn't the right one, and i can't find it on the net,
    please send me the right one you use
    Thanks
    mrthepael@gmail.com

    ReplyDelete
    Replies
    1. htc.h is a library file of Hi-tech compiler. you should install the compiler first before you recompile the project.

      Delete
  22. Replies
    1. i have used Hi-Tech compiler. if you wanted to use xc8 then you have to make few little modification.

      Delete
  23. I compile without problem in XC8, I just add MAIN.C in Source Files, and select XC8 compiler from Project Menu / Select Language Toolsuite / Microchip MPLAB XC8 Compiler and all works. Device works great in my car several weeks from now.

    Regards,
    Peter

    ReplyDelete
  24. HI
    i installed the XC8 compiler and i tried to compile it with this compiler but i get an error:"No valid installed HI-TECH compiler drivers"


    And when i compiled it with the Hi-Tech Compiler i get an error:
    "Error [500] ; 0. undefined symbols:_read_adc(test.obj) _setup_adc(test.obj) _setup_adc_ports(test.obj) _delay_ms(test.obj) _set_timer1(test.obj) _setup_comparator(test.obj) _enable_interrupts(test.obj) _set_adc_channel(test.obj) _setup_timer_1(test.obj)"


    i named my project "test"

    do someone know why ?

    Thanks for answer

    ReplyDelete
    Replies
    1. mrthepael did you extract all the files and open the PIC16 Voltmeter.mcp project file from MPLAB IDE? This should then compile fine.

      Delete
  25. http://p.globalsources.com/IMAGES/PDT/B1056904161/3-digit-7-segment-LED-Display.jpg

    if I redesign the pcb, could I use combined 3digits 12-pin CA 7-segment???

    ReplyDelete
  26. HI SIR SEGMENT THIRD IS NOT WORKING WHICH CONNECTED WITH PIN 12 OF MICRO

    ReplyDelete
  27. Hi, I would like to know if you used an USB conector for compile the code, because i didn't find any indicative in the PCB. Thanks! And somebody can send me the PCB in PDF, please?

    ReplyDelete
  28. this is great.. i would like to ask can i make any changes to enable this circuit to work as ammeter( clamp meter) of course it has to connect to ct. thanks.

    ReplyDelete
  29. Hi ur circuit is very useful,but am having problem with the codes for pic16f676
    Can u please mail me? Clemojunior1990103@hotmail.be
    Or via fb clemo mwenda
    Thx

    ReplyDelete
  30. Great project. Simple and clear. Can you send me eagle files to rasyoung@gmail.com?

    Thanks!!!

    ReplyDelete
    Replies
    1. Is there some reason this won't run on Piclite with MPlab free version?

      I want to use a 16f88 and have to make some changes but can't get it build on Piclite or \Microc.

      Thanks, Jack
      Marengo, Illinois

      Delete
  31. can anyone give me some videos about this . and i dont know why there is a capacitor in actual pic and in schematic there is no capacitor . what is the value of c1 ? the blue capacitor thanks for the answer .

    ReplyDelete
    Replies
    1. you can use any value between 10uf to 100uf

      Delete
  32. HI VERY GOOD, BUT WHEN RUN IT HAS ERROR
    AD CONVERSION PERIOD AND LED NUMBER 3 NO RUN.

    THANKS IN ADVANCE AND BEST REGARDS

    ReplyDelete