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.





3A Current meter using PIC 

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



80 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. 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
  7. 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
  8. sir, can you make me a simple explanation regarding on how the PIC compute the Input voltage. thanks.

    ReplyDelete
  9. 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
  10. 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
  11. 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
  12. Hi,
    Can I use another PIC with the Circuit Diagram?
    PIC's to be used are PIC16F628A, and PIC16F876A

    ReplyDelete
  13. 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
  14. 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
  15. 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
  16. I send material on Your email.

    Regards

    ReplyDelete
  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. Use Microchip MPLAB XC8 Compiler.

    ReplyDelete
    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
  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
  33. Hi anyone tried this for pic16F88?

    ReplyDelete
  34. Super project could you pleas send me Eagle PCB File to neil.nathan@pixie.co.za Thanks

    ReplyDelete
  35. This comment has been removed by the author.

    ReplyDelete
  36. can guide me ,how can read more 1 adc with 16f676 ?,becoz no left any pin for reading more 1 adc
    i think i may posibol with 7447 as u use it on http://www.circuitvalley.com/2012/02/msp430g2231-volt-meter-adc.html#more
    pl guide me ?

    ReplyDelete
  37. This comment has been removed by the author.

    ReplyDelete
  38. will someone pls send me all the steps abt how to design this ckt in proteus software, i am in need

    ReplyDelete
    Replies
    1. Hi
      I m Lutfur Rahman Khan
      My email Jobislifelutfur@gmail.Com
      Plz contact me on Facebook or email

      Delete
  39. This was very informative. I want to Buy Digital Clamp Meter with non-contact voltage detection & remote display. Thanks for sharing. Keep exploring,.

    ReplyDelete
  40. Great project , can you send me Eagle PCB layout ? vhafuwi@gmail.com

    ReplyDelete
  41. Great project , can you send me Eagle PCB layout ? vhafuwi@gmail.com

    ReplyDelete
  42. sir i want circuit of 199.9mV meter,can we change it in required circuit.

    ReplyDelete
  43. required circuit for 0-199.9mV maximum

    ReplyDelete
  44. there are many such meters available on the internet.

    but still you want to modify this board then there can be many ways , you can implement yourself, one way is to change the ADC reference to be such low 200mV and then remove input voltage divider and then change the software a little to show correct numbers , right now software is programmed to show 5v as 30v scale. then it will be 200mV at scale what ever you say.

    or remove voltage divider and have a opamp which will apply gain on input 0-200mv to 0-5V , modify software a little to display correct numbers according to your scale.

    ReplyDelete
  45. sir i will change in hardware my self,but pls guide me in software,b'couse i am zero in software

    ReplyDelete
  46. for show in a LCD type 16X2, what's modifications?

    ReplyDelete
  47. hello sir,
    what will be changes if we want to measure current?
    I want to measure current & have to take proper controlling actions like on/off appliances.

    ReplyDelete
  48. sir can we use 16f684 for the same code i tryed but there is not output

    ReplyDelete
  49. sir i am trying to simulate this circuit on Proteus.But it is not runing properly
    help me ......

    ReplyDelete
  50. Great project , can you send me Eagle PCB layout ? dhanus1953@gmail.com

    ReplyDelete
  51. can uupgrade to mesure 50volt dc in this circuite ????

    ReplyDelete
  52. thanks ,i think this good circuit, I will try .

    ReplyDelete
  53. oi bom dia
    ja tentei de varias maneiras mudar o código mas o seguimento(G) do pino 2 do pic naõ funciona
    pode me dizer porque

    ReplyDelete
  54. AMIGOS ESTE PROJETO ESTA ERRADO POIS O PROGRAMA ESCRITO NAO ACENDE O PINO 2 DO PIC QUE LIGA NO G DO DISPLAY
    POIS GASTAR TEMPO E PEÇAS COM O MESMO NÃO COMPENSSA

    ReplyDelete
  55. Hello

    I am running this code in MPLAB IDE XC8. But getting following error when i am trying to generate the HEX file. Please help.
    ../main.c:20:6: error: variable has incomplete type 'void'
    void interrupt timer1_isr(void)
    ^
    ../main.c:20:15: error: expected ';' after top level declarator
    void interrupt timer1_isr(void)

    ReplyDelete
    Replies
    1. It is quite old project, I had used hi-tech c compiler, but you are using xc8 ,to make it work either you make changes in code or use hi-tech compiler

      Delete
  56. Como haces para que no le afecte el ruido al pic? Como proteger el pic de un motor de dc?

    ReplyDelete
  57. Can we have a Volt Amp meter Circuit of 30V upto 10Amp?
    Thank you very much in anticipation...

    ReplyDelete
  58. Dear friend source code is not found in given link, please check

    ReplyDelete