PIC-based Digital Voltmeter (DVM) - Embedded Lab
PIC-based Digital Voltmeter (DVM) - Embedded Lab
Embedded Lab
aEmbedded Lab
Home Tutorials Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
HOME TUTORIALS PROJECTS PRODUCTS TIPS AND TRICKS CHIPKIT PROGRAMMING PRODUCT REVIEWS
ESP8266 TUTORIALS
AVR XMEGA PCB FAB
ARDUINO ABOUT US
PIC-BASED
NETDUINO DIGITAL
MICROCHIP PIC VOLTMETER (DVM)
TIVA C
This project will describe how to make a simple digital voltmeter (DVM) using a
PIC16F688 microcontroller. The range of this DVM is 0-20V, but you can easily increase
STM8
or decrease the range of input voltage as your requirements after you understand the
voltage scaling
MSP430 method described in this project. The PIC micro reads the input voltage
LAUNCHPAD ESP8266 LEARNING MADE EASY
through one of the 8 analog channels and convert it to a 10-bit digital number using
STC8051ADC. Doing some math with ADC conversion (you will see later), this
the internal EasyESP-1 is a rapid IoT
number can be converted to the actual measured voltage. The voltage is displayed in prototyping board for
an HD44780-based character LCD. ESP8266
You cannot feed a 20V signal directly to a PIC microcontroller’s input channel. It is too
higher than its operating voltage, and the microcontroller could be damaged. So, first
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 1/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
we Lab
Embedded need a voltage scaler that will scale down the input voltage to the safe operating
voltage range of PIC16F688. It can be achieved by a simple resistor divider network
Home Tutorials
shown below. Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
Ships worldwide
Get one for yourself
SUBSCRIBE
Embedded Lab
17K followers
Using
two resistors, R1 and R2, the input voltage ranging from 0-20V can be down converted
to 0-5V. For the chosen values of R1 and R2, you can see that the output (Va) from the
Follow Page
resistor divider network is 1/4th of the input voltage. If the input voltage goes beyond
20V, Va will exceed 5V, and this could be harmful for the PIC microcontroller. If you
connect a 5.1V Zener diode across the R1 resistor, the output voltage Va will never
exceed 5.1V. This will protect the microcontroller from any possible damage due to high Follow @EmbeddedLa
voltage input. The voltage Va will go to AN2 (pin 11) channel of the PIC16F688 Subscribe through email
microcontroller. The rest of the circuit is shown below.
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 2/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Home Tutorials Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
ESP8266 projects
Tiva C tutorials
AVR XMEGA tutorials
Netduino Tutorials
chipKIT Projects
Products
STM32 tutorials
Tips and Tricks
Product Reviews
PIC Projects
Arduino Projects
The LCD display is connected in 4-bit mode. If you have just 14 pins in your LCD
PIC Tutorials
module, then you may not have a back-light facility and you can ignore the pins 15 and
16. The contrast adjustment is done through a 5K potentiometer connected between
+5V and Gnd. An in-circuit serial programming (ICSP) header is provided so that you
OTHER ELECTRONICS
can easily upgrade the firmware inside the PIC microcontroller in future if you make WEBSITES
any changes. An external reset is helpful to bring the entire system to a known initial
condition, when the microcontroller stops executing the program for some reason.
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 3/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
TheLab
complete circuit built on a breadboard is shown here. You need a regulated +5V Electronics-Lab
Embedded
power supply for this project (Why regulated? You will find the answer in the Software
Home Tutorials
section below).Projects
You can use Products Tipsregulator
a LM7805 linear and Tricks
IC for chipKIT Programming
this purpose (read my Product Reviews ESP8266 Tutorials
PCB Fabarticle
About us a
Regulated Power Supply for your Breadboard).
CATEGORIES
Categories
Select Category
Software
Before writing the code for this project, you need to do some math related to AD
conversion. You know that any application that uses analog-to-digital converters
(ADCs), requires a fixed reference voltage to provide accurate digital count for input
analog signal. If the reference voltage is not stable, the ADC output is meaningless. In
this project, the reference voltage for ADC operation is selected to be Vdd (= +5 V).
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 4/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
ThisLab
Embedded is done by clearing the VCFG bit in ADCON0 register. Therefore, the ADC will
convert any input voltage between 0-5 V in to a digital count between 0-1023. A major
Home Tutorials
source of errorProjects
in this projectProducts Tipsofand
is the accuracy Tricks
R1 and chipKITYou
R2 resistors. Programming
are Product Reviews ESP8266 Tutorials
PCB Fabrecommended a
About us not to use the rated values of the resistors. Rather measure their values
with a good quality digital multimeter, and use those values for your calculation. What I
found is R1 = 1267 ? and R2 = 3890 ?. Now,
0 – 5 V Analog I/P is mapped to one of the 1024 levels (0-1023 Digital Count)
To avoid floating point, use I/P voltage = 2*Digital Count. Here’s how it works.
Suppose, Vin = 4.6V. Then,
Va = 0.2457*Vin = 1.13V
=> Digital Count = 1.13/0.0049 = 231
=> Calculated I/P Voltage = 2*231 = 0462
In the 4-digit product (0462), the first two digits are the tens and units digits of
measured voltage. and the last two are the decimal digits. So, the measured voltage
will be 04.62 V. Only the first three digits will be displayed (04.6 V).
The firmware is developed in C and compiled with mikroC Pro for PIC compiler from
Mikroelektronika. The PIC16F688 microcontroller uses internal clock oscillator at 4.0
MHz. MCLR is enabled and Power Up Timer is turned ON. You need to define RA2/AN2
input as analog by setting the corresponding bit in ANSEL register. VCFG bit of ADCON1
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 5/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
register
Embedded Lab is cleared to use Vdd = +5V as reference voltage for AD conversion. ADCON0
= 8 connects the AN2 input channel to the internal Sample and Hold circuit.
Home Tutorials Projects
Comparators on ports A and Products
C pins must Tips and Tricks
be disabled chipKIT
too (assign Programming
CMCON0 = 7). The Product Reviews ESP8266 Tutorials
PCB Fabconfiguration a
About us bits for the fuses are given below. You can set these in MikroC through
Project->Edit Project.
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 6/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
void main() {
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 7/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Lcd_Out(1,1,Message1);
Lcd_Chr(2,10,'V');
do {
ADC_Value = ADC_Read(2);
DisplayVolt = ADC_Value * 2;
Lcd_Out(2,5,volt);
} while(1);
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 8/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Embedded Lab
} // End main()
PCB FabTesting
Aboutthe
us DVM a
Here are the DVM measurement output for various input voltages ranging from 0-20V
obtained through a variable DC power source.
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 9/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Embedded Lab
Home Tutorials Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 10/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Embedded Lab
Home Tutorials Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
Related Posts
Tagged Digital Volt Meter, DIY voltmeter, DVM, PIC based voltmeter, PIC Projects
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 11/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
EmbeddedPIC
LabProjects
Home Tutorials Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
Please R-B your site has been very helpful to me. But there is something
I want to understand very well in DVM program code. that %10 what
does mean? why is it there?
Reply
hi. i was wondering if you could provide me the code for making your
LCD voltmeter into an LED type voltmeter.
thank you.
ron
Reply
may be good enough for 5mA rated zener, however that is only a fraction of mA current
Embedded Lab
which is usually required for commonly available zener diodes, which usually requre
Home Tutorials
even 40mA in Projects
order to work Products
properly. AndTips
thatand
kind Tricks
of currentchipKIT Programming
may destroy PIC (max. Product Reviews ESP8266 Tutorials
a
limit for I/O pins is 5.5V, 20mA by datasheet).
PCB Fab About us
This further require more expensive and less common 1-2W lower resistor values, or
making it with more usually several resistors in series/parallel or both, in order to
satisfy minimum required current of 40mA. However, that is not very good practice, as
dissipation is enormous (1W or more) and as well require additional resistor to limit
40mA under 20mA.
Thus this become unresolved chicken and the egg problem without few mA rated zener.
I’m unsure how to solve this instead to omit zener completely and ensure voltage is
always under maximum designed limit. Hopefully, all these are hobby projects, for my
own pleasure.
Reply
Reply
hy sir,,
i want to control the 5 Leds with the potentiometer….
like as,, ups charging level
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 13/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
plz,,
Embedded Lab
my mail,,,[email protected]
Home Tutorials Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
Reply
PCB Fab About us a
Rk July 2, 2015 4:48 am
hello friend RB
i am measure (0-250V) i change the code
Reply
Hi friend ,
nice work frd,
how to change the code & circuit to measure the voltage AC (0-600V)
please help friends
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 14/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Reply
nice post it will help me lots can you give me idea that how can i make
digital ammeter ( current meter) using pic16f877a
Reply
Hi, very nicely done. I wanna know that how can one make an
embedded system to measure 120 volt dc ? I am looking for some ADC
but can not find it. Can you please help me in finding a solution? Thanks.
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 15/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Hi Raj!
Embedded Lab
Very good project, but how did you find the resistor value?? try and
Home Tutorials Projects
error? Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
Reply
I think in this circuit you are measuring voltage drop across 1.3kOhm
resistor is that right?
Reply
Hey! I was wondering where in this voltage divider circuit could I connect
my load… say I have a 8W bulb that requires 12-18VDC.
Sorry, I am not an electrical engineer. Any help would be appreciated.
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 16/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Reply
Embedded Lab
Home Tutorials
jun
Projects
May 1, 2013 4:33 am Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
Reply
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 17/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Embeddedaya
Lab April 7, 2013 4:52 pm
Reply
hello,
really love this project and wish to try it at home. but you did not give a
step by step approach on how to get the bread board wired up with the
components.As am a new electronic student i will be glad if you could get
in touch with the steps. I will also love to buy the componets complet and try to
assemble it with your guidance.
Thank you
reply really appreciated!!!
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 18/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Hi RB,
Embedded Lab
I need your help on based on this project using PIC16F688,i’m working
Home Tutorials Projects
on one projectProducts Tips
which is need 3 ofand Tricks
analog chipKIT
channel,i Programming
have did the hardware Product Reviews ESP8266 Tutorials
// Define Messages
char message1[]= “USCC”;
char message2[]= “V=”;
char message3[]= “I=”;
char message4[]= “Temp=”;
// End Message
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 19/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 20/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
DisplayCurr=ADC_Value /22527;
Embedded Lab
amp[0] = DisplayCurr/10000 + 48;
Home Tutorials Projects Products
amp[2] = (DisplayCurr/1000)%10 + 48; Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
PCB Fabamp[4]
About= us a
amp[3] = (DisplayCurr/100)%10 + 48;
(DisplayCurr/10)%10 + 48;
Lcd_Out(2,3,amp);
Lcd_Chr(2,9,’A’);
//Read temp
Lcd_Out(2,1,Message4);
ADCON0=0b00010100;
ADC_Value=ADC_Read(5);
DispayTemp=ADC_Value * 2;
temp[0] = DispayTemp/10000 + 48;
temp[1] = (DispayTemp/1000)%10 + 48;
temp[2] = (DispayTemp/100)%10 + 48;
temp[4] = (DispayTemp/10)%10 + 48;
Lcd_Out(2,6,temp);
Lcd_Chr(2,13,’C’);
}while(1);
}
Reply
Raj! The problem is showing again, it seems that the pin 11 of the pic
doesnt work, i have changed the pic again, and it is always showing
20.4v which is frustrating because i made it for my mom’s birthday on
septembre 9th
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 21/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Dear sir , I have need a LCD type MPPT SOLAR charge controller circuit
diagram and hex code , c language, pls help
And how to purchase it from u
Reply
Hi RB,
thanks just stumbled on to your excellent site (you are doing good work,
thanks for your time) I need to build PIC-based Digital Voltmeter, can you
make it read 3 or 4 decimals after the . ex 12.2364 v, I do slow charging of big
batteries and will be nice to see them coming up slowly. What do I need to change if it
is possible? I have no programming knowledge and only build projects by using hex file
supplied if it is possible, if it is possible.
Virus
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 22/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
But I have to mention that it works independently of what the ADCON0 register is set.
In fact, even if I remove it from the code, it stil works!
1) What does the ADCON1 do? The reference voltage is set by the 2nd bit of the
ADCON0 register if you see the manual.
2) Why are the 2 LSB of the ADCON0 set “0”? If you see the manual, on page 71, the
first LSB is actually the enable bit of the ADC module and it has to be “1”!
-> But as I mentioned before, there is some kind of bug, because even if I completely
omit to set the ADCON0, it still works!
Now I’m going to implement a current meter as another of your projects. Hope I will
succeed in this! Keep up the good work!
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 23/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
EmbeddedGeorge
Lab August 25, 2012 7:37 am
It reads from both pins, but if I connect only one of them, it displays on LCD both
readings the same value! What is wrong? Please help me!
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 24/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
void main() {
Embedded Lab
ANSEL = 0x00000101; // RA0, RA2 is analog input
Home Tutorials Projects
ADCON1 = 0x00; Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
PCB FabTRISC
CMCON0 = 0x07 ;
About us a
= 0b00000000; // PORTC All Out
TRISA = 0b00010101;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
do {
ADCON0 = 0b00001000; // Analog channel select AN2
adc_v = ADC_Read(2);
DispVolt = adc_v * 1.174;
volt[0] = DispVolt/1000 + 48;
volt[1] = (DispVolt/100)%10 + 48;
volt[3] = (DispVolt/10)%10 + 48;
volt[4] = DispVolt%10 + 48;
Lcd_Out(2,12,volt);
delay_ms(100);
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 25/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
} while(1);
Embedded Lab
}
Home Tutorials Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
Reply
PCB Fab About us a
R-B August 26, 2012 12:21 pm
Make sure there’s no short circuit between the two ADC inputs. What
is your circuit diagram look like?
Reply
Hi george iam impressed by your ideas can you please send the
circuit diagram of this project.
Thanks In Advance
Regards,
BASILEA RUBAN
Reply
thanks Raj!
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 26/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Reply
Embedded Lab
Home Tutorials
Marc
Projects
August 1, 2012 11:51Products
am Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
a
PCB Fab About us The problem is solved, that was my jumper shorted off!!!
thanks a bunch!!!!
i really really appreciate what you are doing!
have a great day!
marC:)
Reply
Reply
gnd pin
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 27/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
EmbeddedMarc
Lab July 20, 2012 11:26 pm
Reply
Reply
Yes, my mistake, i have put 3.9k ohm resistor,anyway, what is wrong with
my circuit pleaseee??
thanks!
marC:)
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 28/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
thank you!
marC:)
Reply
Reply
Raj? Can you tell me what are these two resistors on the picture, you
have mention putting R1 and R2, and now there’s 3 resistor?? i don’t
quite understand…
http://img193.imageshack.us/img193/2017/voltmeterraj.jpg
thanks!
marC:)
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 29/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Marc,
Those resistors are not the part of the circuit, so ignore them.
Reply
Reply
Marc,
If you are measuring a constant 20.4V it means your analog input
voltage is always 5.0V because that will give 1023*2 = 2046, which is
shown as 20.4V on LCD. Make sure there is no short circuit between AN2
and VCC pin.
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 30/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
EmbeddedMarc
Lab July 5, 2012 9:12 am
Reply
The voltage from the battery to test is always 20.4v, anyway if i plug the
battery to test or not, it’s the same result… i don’t understand.. now
Reply
Reply
Thanks Raj! I will try it, i will let you know how it’s going…
Reply
Embedded Lab
Home Tutorials
Marc
Projects
June 18, 2012 10:57 Products
am Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
a
PCB Fab About us thanks for sharing the project! where do i connect the + and the – of the
battery to be tested? thanks!
marC:)
Reply
Reply
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 32/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
thanks!
Embedded Lab
marC:)
Home Tutorials Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
Reply
PCB Fab About us a
wasantha May 15, 2012 12:18 pm
Reply
using this project,i want to interface the pic 16f688 with pc and want to
make a pc to pc communication network so that the device can be
monitored from any place.please can u send me the hex code,program
and circuit diagram
Reply
Input voltage is 0 to 20 volts and anything over the zener voltage goes to
ground.
Why do you take this cheap wasteful way out ? Why not suggest a
purpose made chip with low currebt to ground on overvoltage . Tey cost
next to nothing and are common.
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 33/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
EmbeddedMarc
Lab April 15, 2012 12:06 pm
Reply
Marc,
Did you try this project exactly as it has been described, or are you
using a different microcontroller?
Reply
how can i diplay the value in lcd in my pc. basically how to interface the
input of pic16f688 with pc. please can you send me the hex code,
program and circuit configuration.
Reply
And when i measure 50.00 wolts – what will be the resolution of the measurement
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 34/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Embedded Lab
Home Tutorials Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
I’m asking you if you can give me the code written in assembly code
because I’m using THrsim11.
Reply
i forgot – R1 = 4k + 2k trim
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 35/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
first :
Embedded Lab
Va = 5.555k * Vin/(5.555k+50k) = 0.0999*Vin => Va = 5
Home Tutorials
=> I/P voltageProjects Products
= 10*Va = 10* Tips* and
Digital Count Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
0.0049
= 0.049 * Digital Count
PCB Fab About us a
= 0.05*Digital Count (Approx.)
Va = 0.1*Vin = 3.456V
=> Digital Count = 3.456/0.0049 = 705.3061224
=> Calculated I/P Voltage = 490*705.3061224 = 345600
First 4 digits of 6 digit product
and when i have this numbers – where in the software need to i write .
+ this
volt[0] = DisplayVolt/1000 + 48;
volt[1] = (DisplayVolt/100)%10 + 48;
volt[3] = (DisplayVolt/10)%10 + 48;
volt[4] = DisplayVolt%10 + 48;
please give me all the software text ready for measurement of 00.00 to 50.00 V = I do
not know where to record these numbers that I got
Voltmeter to both shows you two tensions – how to modify the scheme and the
software text ?
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 36/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
EmbeddedJohn
Lab
Home Tutorials IProjects Products
change the code Tipsbut
for 2 inputs, andI don’t
Tricks
no ifchipKIT Programming
this is wright. Product Reviews ESP8266 Tutorials
Please can you controle code of right place.
a
PCB Fab About us Friendly regards John.
/*
Digital Voltmeter 0-20V based on PIC16F688, 2 Analog Inputs
Internal Oscilator @ 4MHz, MCLR Enabled,PWRT Enabled, WDT OFF
Februari 2012
*/
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 37/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
void main() {
Embedded Lab
ANSEL = 0b00000110; // RA1/AN1 and RA2/AN2 is analog input
Home Tutorials Projects // Analog
ADCON0 = 0b00001100; Products Tips
channel andAN1
select Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
and AN2
PCB FabCMCON0
ADCON1 = 0x00;
a
About =us0x07 ; // Disbale comparators
TRISC = 0b00000000; // PORTC All Outputs
TRISA = 0b00001100; // PORTA All Outputs, Except RA3 and RA2
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // CLEAR display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,”CH1 =”);
Lcd_Out(2,1,”CH2 =”);
Lcd_Out(1,12,”Volt”);
Lcd_Out(2,12,”Volt”);
do {
ADC_Value1 = ADC_Read(1);
ADC_Value2 = ADC_Read(2);
DisplayVolt1 = ADC_Value1 * 2;
DisplayVolt2 = ADC_Value2 * 2;
volt1[0] = DisplayVolt1/1000 + 48;
volt1[1] = (DisplayVolt1/100)%10 + 48;
volt1[3] = (DisplayVolt1/10)%10 + 48;
volt2[0] = DisplayVolt2/1000 + 48;
volt2[1] = (DisplayVolt2/100)%10 + 48;
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 38/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Reply
Hello,
I’m a new user of MicroC and I use help.I want to read 2 analog inputs
I’ve change the code you say in post39 but I must also change the
“main”
I don’t understand. Please help withe change the code for use 2 analog input.
Reply
Reply
Pingback: Anonymous
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 39/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Embeddededil
Lab February 9, 2012 8:00 am
Where do I find above mentioned rotuines? Are they part of mikroC lib?
Regards, Erik
Reply
@edil,
Yes they are built-in routines of mikroC.
Reply
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 40/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
dear sir
Embedded Lab
i am student.i know about pic16f676 code in .bas
Home Tutorials Projects
please help meProducts Tips50Hz
how to control andwith
Tricks
pwm chipKIT
control Programming Product Reviews ESP8266 Tutorials
M Ameen
Reply
Dear Sir,
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 41/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Hi Kapilasri,
Embedded Lab
This project may not be repeated with PIC16F628A as this PIC does
Home Tutorials Projects Products
not have any Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
ADC channels.
My questions are:
1- What happened to left justified or right justified as in the data sheet
for ADC.
thanks
Reply
Uzo,
1. By default the MikroC LCD library use right justified data of ADC
output.
2. If the incoming voltage is 5V, then the actual input to ADC channel after resistor
divider is 0.2457*5 = 1.229V. The ADC value will be 1023*0.2457 = 251. So 251*2
= 502, which is displayed as 5.02V.
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 42/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Reply
Embedded Lab
Home Tutorials
M.Mathar
Projects Products
December 26, 2011 2:11 pm Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
Reply
The variable Volt carries the numeric digits of the measured voltage.
In order to display them on a character LCD, the numbers must be
converted to ASCII equivalent, which can be done by adding 48 (30h)
to actual numbers. For example the ASCII code for 0 is 48, for 1 is
49, for 2 is 50, so on.
Reply
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 43/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Embeddedmiu
Lab December 16, 2011 7:43 pm
…I’ve been following your post for a while now, it’s been very helpful.
Could you please assist with schematics and source codes for a PIC
digital clock…
Thanks alot…
Reply
Reply
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 44/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Embeddedares
Labprime August 28, 2011 6:31 pm
Reply
Reply
not clear , when we use 2 or 3 read analog inputs from multiple ADC channels
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 45/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Embedded Lab
Home Tutorials Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
hi Mr. R-B
my need HOW CAN GET ?
1_Calculated I/P voltage = 49*16161.6122 = 791918.9978
OR
2_Calculated I/P voltage = 16161.6122/100 =161.616122
who is right way ?
1_ =
or
2_ =
Reply
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 46/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Reply
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 47/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Reply
Embedded Lab
Home Tutorials
R-B
Projects
July Products
27, 2011 10:25 am Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
Reply
Hi RB. Nice job. Pls how can i make it 2 measure both ac and dc up 2
500v
Reply
hey…
i tried to use the USART but its not working with this configuration… and
the second thing i want to ask about is how to make this circuit sensitive
to small voltages.. so that i want to measure about 5 mili volts?? thanks in advance
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 48/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Use an OpAmp with appropriate gain to amplify the low voltage signal
Embedded Lab
before feeding to the ADC channel. Read this post http://embedded-
Home Tutorials Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
lab.com/blog/?p=1953
Reply
Reply
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 49/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
ok thanks alot ….
Embedded Lab
i found the problem.. the voltage divider wasn’t plugged correctly,,, but
Home Tutorials Projects
still Products
i have a question Tips
please.. if iand
wantTricks
to send chipKIT Programming
this data serillay to Product Reviews ESP8266 Tutorials
Reply
You don’t need to change the configuration setting for using USART.
You will be fine.
Reply
Reply
@Mostafa,
First of all, there is no resistance on pin 14 on the PIC, so correct what you are
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 50/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
saying. And are you using the same microcontroller and the program
Embedded Lab
that I provided? Make sure that the ADC channel that you are using is
Home Tutorials Projects
defined as Products
input in TRISTips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
register.
hi brother
first of all thank you so much for your help and for this wonderful
tutorial.. but i have a question please.. i configured the fuses and
programmed the pic and everything in ok.. but the display is wrong so
could you tell me why this happened?
Reply
@mostafa,
What do you mean by the display is wrong? Do you mean it shows
wrong values on LCD? Tell me more about the problem.
Reply
What is the initial display in the LCD once I power up the circuit?
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 51/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Embeddedrao
Lab July 12, 2011 4:36 pm
I’ve overlooked at my inbox. I’ve already received it. Thank you very
much!
Reply
Hi R-B! Thank you for the code. But I think I haven’t received it yet. Can
you resend it to my email? [email protected] Thanks!
Reply
can you please tell me whats ICSPDAT and ICSPCLK? im new to circuits,
cause i really need to understand this for my DVM project. thanks
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 52/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Embedded Lab
R-B July 8, 2011 10:34 am
a
programming of PIC microcontroller.
PCB Fab About us
Reply
R-B! When I tried to import the hex file of your code on my Pic16f676
(using pic kit 2), it could not write successfully. It was stated that the
program memory was not enough. 676 and 688 are really pin compatible
but when I looked at the datasheet, 688 has a larger memory space. So I
think the memory space matters in your project.
Is there any way that I can change or vary in your code so that I can use my Pic16f676
for your project? It’s the only pic that’s closest to your pic that is available in our
country.
Thank you!
Reply
I have sent you the PIC16F676 version of HEX file in your email
angel_joyce15 at yahoo.com. You should use exactly the same circuit
shown in the article with PIC16F676, and load the new HEX file.
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 53/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Embeddedangel
Lab July 7, 2011 1:20 am
You can implement this project with any other PIC with ADC channels.
PIC16F676 and PIC16F688 look pin compatible, but you can
recompile the source code for PIC16F676 to make sure it will run.
Reply
Thanks mate!
Reply
Hello RB,
I’m using 16f684 for this project & i’m still new in microcontroller world.
1 question, how can i sampling more than 1 analog input?
Like in sequence sampling input 1, input 2…..thanks
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 54/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Reply
Embedded Lab
Home Tutorials
R-B
Projects
June Products
21, 2011 10:49 pm Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
PCB Fab About us aYou can read analog inputs from multiple ADC channels but only one
A/D conversion at a time. Suppose if you want to read two analog
signals through RA0/AN0 and RA1/AN1 pins, you should first set their
directions as input by TRISA = 0b00000011. Then you should also set
ANSEL = 0x00000011. Now if you are using mikroC, you can read from AN0 using
ADC_Read(0) and from AN1 using ADC_Read(1).
Reply
Reply
@hamad,
The circuit diagram explains what parts you need for this project.
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 55/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
can you mail me the video of complete project of dvm u made. it will be
Embedded Lab
helpful for me.
Home Tutorials Projects
my Products Tips and Tricks
id is [email protected] chipKIT Programming Product Reviews ESP8266 Tutorials
Reply
Reply
Reply
Hello RB,
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 56/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Va = 0.2457* Vin, if max I/P voltage is 20V, so the calculation is 0.2457 * 20V & max.
Embedded Lab
Va = 4.914V rite?
Home Tutorials Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
a
So 20/4.914 = 4.07 correct?
PCB Fab About us
I’m calculating this math to have a 0~30V volt meter.
My calculation as below:
Assume Vin = 8V
Va = 0.1637 * 8 = 1.31V
=> Digital Count = 1.31/0.0049 = 267
Calculated I/P voltage = 3 * 267 = 0801
Reply
@ meguitarist
You are doing right.
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 57/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Hello RB,
Embedded Lab
Home Tutorials Projects website.
Wonderful Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
Reply
Reply
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 58/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Hamad,
Embedded Lab
It would be little bit more complicated with PIC16F84 as it doesn’t have
Home Tutorials Projects
built-in Products
ADC module Tips
and you and
have Tricks an
to connect chipKIT
externalProgramming
ADC chip to it. Product Reviews ESP8266 Tutorials
can you tell me program for PIC 16F84 for digital voltmeter i need it very
much .i will be thankful
Reply
hello sir, for an PIC-based Digital Voltmeter (DVM) the program are done
in computer and downloaded to the PIC 16F688 using usb pic
programmer.after downloaded there is need for connection of usb to the
board.. Is it possible to run the PIC after the program downloaded to the
PIC without USB PIC programmer
Reply
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 59/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
EmbeddedR-B
Lab April 24, 2011 7:59 am
Reply
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 60/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
PLEASE IF YOU HAVE ANY KNOWLEDGE OF THESE TOPICS PLEASE SEND ME THE
Embedded Lab
NAMES OF LINKS TO DOWNLOAD THEM FORM THE INTERNET OR
Home Tutorials Projects
THE PROCEDURE Products
TO GET THESE TASKS Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
COMPLETED
a
I WOULD BE THANK FULL TO YOU
PCB Fab About us
I THINK THAT YOU ARE ELECTRONIC IC SOFTWARE DESIGNER AS YOU KNOW THE
INTERFACING OF ELECTRONICS WITH THE PROGRAMMING.
Reply
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 61/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Reply
Embedded Lab
Home Tutorials Projects
JALIL AHMED
Products
March 3, 2011 2:46 pm Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
a
PCB Fab About us BROTHER i m working on project voltmeter(volt) + amp meter(current)
and want to switch it between volt/current with the help of push button.
i already have an volt meter designed by using Pic 16f676 microcontroller
but i dont have its program and procedure
if you have any knowledge please send me the schematic please
and tell me how can I simulate it on the computer. I have
soldering station work bench and Superpro 3000 Porgrammer.
I NEED TO KNOW THE COMPLETE PROCEDURE FOR DESIGNING VOLTMETER +
AMPARE METER WITH THE HELP OF PIC MICROCONTROLLER PIC 16F676
AND ITS C++ file and
Reply
Reply
Jalil,
Current could be measured using a different technique. I have
described one briefly in here:
Measure DC current with a Microcontroller
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 62/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Reply
Embedded Lab
Home Tutorials
Admin
Projects
February Products
10, 2011 6:41 pm Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
Reply
Sorry for pointing that to me, it was my mistake. I will link the correct file
as soon as I get home today.
Reply
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 63/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Embedded Lab
Home Tutorials Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
So far only simulates the Proteus. When finished I do post the pictures.
Merry Christmas
Reply
Reply
You can send the pictures of your finished project, I can post them
here, if you would like.
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 64/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Reply
Reply
Reply
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 65/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Embeddeddanj
Lab December 18, 2010 10:00 pm
Reply
You need to find the new values for resistors R1 and R2 in the voltage
divider network that could scale down the i/p voltage ranging from 0-30V
to 0-5V. After that, just follow the math described above.
Reply
HI can pls know how to measure for diff voltage range like for 0-30v
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 66/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Reply
Embedded Lab
Home Tutorials Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
LEAVE A REPLY
PCB Fab About us a
Your email address will not be published. Required fields are marked *
Comment
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 67/68
04/06/23, 17:11 PIC-based Digital Voltmeter (DVM) | Embedded Lab
Home Tutorials Projects Products Tips and Tricks chipKIT Programming Product Reviews ESP8266 Tutorials
https://embedded-lab.com/blog/pic-based-digital-voltmeter-dvm/ 68/68