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.
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
tnx for this post. its vary useful ........
ReplyDeletei have a question, what means the "Pot" who arrows to 10k resitor
ReplyDeletethat's a variable resistor whose value may go 0 Ohm to 10 K ohms
Delete"Pot" means Potentiometer
Deletethis is the best project for me and best regard
ReplyDeletePLS SEND PCB TRACK IN PDF FORMAT TO rajeevexcelelectronics@gmail.com
ReplyDeletenice work
ReplyDeletepls give author phone number
describle the HT07S function
ReplyDeletedoes 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.
ReplyDeletesoftware is fine quality.
Deletebut if you want to use for commercial product then i guess need to be few more fail safe mechanism.
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.
ReplyDeletesir, can you make me a simple explanation regarding on how the PIC compute the Input voltage. thanks.
ReplyDeleteHello 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?
ReplyDeleteyes, 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
Deletehey 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.
ReplyDeletemy email id is ashish3366@gmail.com
thanks a lot in advance!!!
Hi,
ReplyDeleteWhat is the actual size of the PCB of this project...
the size of the board which shown in the images is 5cm*6cm
DeleteHi,
ReplyDeleteCan I use another PIC with the Circuit Diagram?
PIC's to be used are PIC16F628A, and PIC16F876A
Ps. Also this PIC16F84A.
ReplyDeleteI make this in SMD 4cm x 4cm and I get very unstable 3 digit.
ReplyDeleteI 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).
On pot ends 2,04V is stable, but on LED third digit changing.
ReplyDeleteIts like he present real 4-digit from unimer, as 3-digit on led.
On pot ends stable 2,03V
ReplyDeleteOn 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"?
can you send me your pcb desing files ..
DeleteOf course I can, but I need address.
DeleteI send material on Your email.
ReplyDeleteRegards
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.
ReplyDeleteRegards
Hi, I translated your article in Russian, suddenly someone will be useful - Простой встраиваемый вольтметр 30В на PIC16F676
ReplyDeletehttp://radioaktiv.ru/shems/measure/478-prostoy-vstraivaemyy-voltmetr-30v-na-pic16f676.html
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
ReplyDeletecan you give details information about this..i need it as a reference in my project
ReplyDeleteAszniedaa_89@yahoo.com
DeleteHi
ReplyDeleteit'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
htc.h is a library file of Hi-tech compiler. you should install the compiler first before you recompile the project.
DeleteUse Microchip MPLAB XC8 Compiler.
ReplyDeletei have used Hi-Tech compiler. if you wanted to use xc8 then you have to make few little modification.
DeleteI 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.
ReplyDeleteRegards,
Peter
HI
ReplyDeletei 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
mrthepael did you extract all the files and open the PIC16 Voltmeter.mcp project file from MPLAB IDE? This should then compile fine.
Deletehttp://p.globalsources.com/IMAGES/PDT/B1056904161/3-digit-7-segment-LED-Display.jpg
ReplyDeleteif I redesign the pcb, could I use combined 3digits 12-pin CA 7-segment???
sure why not
DeleteHI SIR SEGMENT THIRD IS NOT WORKING WHICH CONNECTED WITH PIN 12 OF MICRO
ReplyDeleteHi, 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?
ReplyDeletethis 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.
ReplyDeleteHi ur circuit is very useful,but am having problem with the codes for pic16f676
ReplyDeleteCan u please mail me? Clemojunior1990103@hotmail.be
Or via fb clemo mwenda
Thx
Great project. Simple and clear. Can you send me eagle files to rasyoung@gmail.com?
ReplyDeleteThanks!!!
Is there some reason this won't run on Piclite with MPlab free version?
DeleteI 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
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 .
ReplyDeleteyou can use any value between 10uf to 100uf
DeleteHI VERY GOOD, BUT WHEN RUN IT HAS ERROR
ReplyDeleteAD CONVERSION PERIOD AND LED NUMBER 3 NO RUN.
THANKS IN ADVANCE AND BEST REGARDS
Hi anyone tried this for pic16F88?
ReplyDeleteSuper project could you pleas send me Eagle PCB File to neil.nathan@pixie.co.za Thanks
ReplyDeleteThis comment has been removed by the author.
ReplyDeletecan guide me ,how can read more 1 adc with 16f676 ?,becoz no left any pin for reading more 1 adc
ReplyDeletei 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 ?
or with 74595
ReplyDeleteCan we use as a current meter ?
ReplyDeleteThis comment has been removed by the author.
ReplyDeletewill someone pls send me all the steps abt how to design this ckt in proteus software, i am in need
ReplyDeleteHi
DeleteI m Lutfur Rahman Khan
My email Jobislifelutfur@gmail.Com
Plz contact me on Facebook or email
This was very informative. I want to Buy Digital Clamp Meter with non-contact voltage detection & remote display. Thanks for sharing. Keep exploring,.
ReplyDeleteGreat project , can you send me Eagle PCB layout ? vhafuwi@gmail.com
ReplyDeleteGreat project , can you send me Eagle PCB layout ? vhafuwi@gmail.com
ReplyDeletesir i want circuit of 199.9mV meter,can we change it in required circuit.
ReplyDeleterequired circuit for 0-199.9mV maximum
ReplyDeletethere are many such meters available on the internet.
ReplyDeletebut 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.
sir i will change in hardware my self,but pls guide me in software,b'couse i am zero in software
ReplyDeletefor show in a LCD type 16X2, what's modifications?
ReplyDeletehello sir,
ReplyDeletewhat will be changes if we want to measure current?
I want to measure current & have to take proper controlling actions like on/off appliances.
sir can we use 16f684 for the same code i tryed but there is not output
ReplyDeletesir i am trying to simulate this circuit on Proteus.But it is not runing properly
ReplyDeletehelp me ......
Great project , can you send me Eagle PCB layout ? dhanus1953@gmail.com
ReplyDeletecan uupgrade to mesure 50volt dc in this circuite ????
ReplyDeletethanks ,i think this good circuit, I will try .
ReplyDeleteoi bom dia
ReplyDeleteja tentei de varias maneiras mudar o código mas o seguimento(G) do pino 2 do pic naõ funciona
pode me dizer porque
AMIGOS ESTE PROJETO ESTA ERRADO POIS O PROGRAMA ESCRITO NAO ACENDE O PINO 2 DO PIC QUE LIGA NO G DO DISPLAY
ReplyDeletePOIS GASTAR TEMPO E PEÇAS COM O MESMO NÃO COMPENSSA
Hello
ReplyDeleteI 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)
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
DeleteComo haces para que no le afecte el ruido al pic? Como proteger el pic de un motor de dc?
ReplyDeleteExelente trabajo!! !
ReplyDeleteCan we have a Volt Amp meter Circuit of 30V upto 10Amp?
ReplyDeleteThank you very much in anticipation...
Dear friend source code is not found in given link, please check
ReplyDeleteSource code and hex link has been fixed
Delete