# Digital Voltmeter (0-50v) using PIC Microcontroller

If we know how inbuilt ADC work then we can easily build Digital Voltmeter using PIC Microcontroller. In my previous post, we can see how easily we build “Digital thermometer with auto saving log file in excel by Pic microcontroller”. Using the same principle here we build Digital Voltmeter using PIC Microcontroller.

Requirement:

To make digital voltmeter we uses some material here I give you the list of that.

1)    PIC16F877

2)    LCD (lm106l)

3)    Resistors (100k & 11.11k).

Project Details:

In this project we use internal ADC of PIC16f877 microcontroller for getting input voltage which we have to measure. After getting the input it processed in microcontroller and the equivalent voltage is display in the LCD which is attached with port D. In bellow see the block diagram of our project Digital Voltmeter using PIC Microcontroller.

Working Principal:

We know that PIC16f877 has 10 bit ADC. So input in form 10 bit and we need 8 bit data to farther process. So getting equivalent integer value we have to convert the 10 bit ADC value in equivalent integer number. Now question is how we convert it? For converting it we have to take a reference voltage let we take reference voltage 5 volt. Now the formula of conversion is

Value =value * (reference millivolt / 210-1)

=value *  5000/1024-1

= value * 4.89

Now here we can use maximum reference voltage 5 Volt beyond that voltage PIC cannot tolerate. Now if we give max 5v as reference then how can we measure 50v? We cannot give 50v at input pin of in build ADC for measure 50 v DC. So we have to reduce the voltage with proportionate with reference voltage 5v. For that reason here we introduce Voltage divider circuit with taking R1 = 100k and R2 = 11.11k. Now for selecting R1 and R2 we use voltage divider formula I,e

Vout = (R2/R1+R2) * Vin .

So using above formula let see what happen if we want to measure 50v

Vout = (11.11/100+11.11)*50

= 5v

So we can easily measure maximum 50 v DC. See the circuit diagram for proteus simulation.

Now in bellow see the complete C code

Embedded C Code
// Name : Digital Voltmeter using PIC Microcontroller
// Author : Subham Dutta
// Date : 28-02-14
// Website : www.nbcafe.in

sbit LCD_RS at RD2_bit;
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
char *l,*m,n,o;
unsigned int k,j,i;

void main() {
int t;
TRISA=0x01;
TRISd=0x00;

lcd_init();
lcd_cmd(_LCD_CURSOR_OFF);

while(1)
{
k=t;
k=k*0.489;
j=k/10;
i=k%10;
inttostr(j,o);
inttostr(i,n);
l=ltrim(o);
m=ltrim(n);
if (j<=9){
lcd_out(1,1,”***Voltmeter***”);
lcd_out(2,1,”Volt :”);
Lcd_out(2,8,l);
lcd_out(2,9,”.”);
Lcd_out(2,10,m);
Lcd_out(2,12,”v”);
}
else {
lcd_out(1,1,”***Voltmeter***”);
lcd_out(2,1,”Volt :”);
Lcd_out(2,7,l);
lcd_out(2,9,”.”);
Lcd_out(2,10,m);
Lcd_out(2,12,”v”);
}

}
}

`>`

## Not Enough, Need More

### 1 thought on “Digital Voltmeter (0-50v) using PIC Microcontroller”

1. what’s the range of crystal oscillator

### E-Mail Subscription  ##### LED blinking using timer0 of pic16f877 microcontroller

Here I discuss very good knowledge based project LED blinking using timer0 of pic16f877 microcontroller. You can see in my Earlier project “Simple Project on  ##### Advantages of PIC 18 Series over PIC 16 series

This is the common question that what are the advantages of PIC 18 Series over PIC 16 series ? Why should we use PIC 18  ##### Interfacing GLCD with PIC16F877A

Today I discuss on interfacing GLCD with PIC16F877A. To overcome the limitation of LCD display we use GLCD (Graphical LCD). By using GLCD, now we 