VOLTMETER with PIC 16F877A

Status
Not open for further replies.
hi everyone good post here. please how can i measure a negative voltage with the pic. for instance i want to measure frm -12 to 0 to 12v

You can use a circuit that detects whether the input is +ve or -ve. Then, use a differential amplifier with unity gain to read the "magnitude" of the input voltage. This is one of many possible circuits.

Hope this helps.
Tahmid.
 
Reactions: 4s7ww

    4s7ww

    Points: 2
    Helpful Answer Positive Rating
negative voltage circuit (Elektor)

**broken link removed**
 

Attachments

  • LMC - Copy.png
    184.7 KB · Views: 159

how can calculate it ? , means equation =?

PIC16F877 have 8 channels with 10-bit. That means 2^10 = 1024. 1023 steps in 5V - 5/1023= 0,0048V (4,8mV) per step.

For ADC 12-bit:
2^12 = 4096 steps in 5V. 5/4095 = 0,0012V (1,2mV) per step.

We have 8-bit, 10-bit, 12-bit, 16-bit, 18-bit, 24-bit ADCs.
 

**broken link removed**
 

Attachments

  • sch24.png
    7.8 KB · Views: 155

dear Tahmid

can you please show me how to modify this code t (pic16f877a voltmeter) to measure two voltages, using pins ra1, ra2
wasantha(4s7ww)
thanks...
 
Last edited:

i dont under stand
why you adding 48 ???
all of you added 48 on the value that will be on the lcd???
whyy
i dont under stand this
i am a beganner
 

Float value display on LCD - Simple method


Code:
----------------------------------------------------------------------------
float  value=5.0005;    //float value 
int tmp1,tmp2;

tmp1=(int)value;             // tmp1=5            //display tmp  5  on lcd 
value=value-(float)tmp1;   //value=0.0005
value+=1;                     // value = 1.0005   
value=value*10000;           10005
                                                //display '.' in lcd 
tmp2=(int)value;
                                             //display tmp2   4 digit on lcd , avoid  MSB value 1    
----------------------------------------------------------------------------
 

i dont under stand
why you adding 48 ???
all of you added 48 on the value that will be on the lcd???
whyy
i dont under stand this
i am a beganner

To display a character on the LCD, the corresponding ASCII value must be sent.

Here is an ASCII chart: **broken link removed**
**broken link removed**

As you can see, for 0 to 9, the ASCII values are 48 greater than the character value. So, ASCII value of 0 is 48, of 1 is 49, of 2 is 50 and so on. That's why 48 is added.

Hope this helps.
Tahmid

- - - Updated - - -

dear Tahmid

can you please show me how to modify this code t (pic16f877a voltmeter) to measure two voltages, using pins ra1, ra2
wasantha(4s7ww)
thanks...

You will need to use the ADC channels corresponding to RA1 and RA2 which would be AN1 and AN2. Take reading from AN1, do the processing and display it on the LCD. Then take reading from AN2, do the processing and display it on the LCD.
 

Hi All,
This is my first post, I am new to micro controllers, have made a multi channel voltmeter using 16F877A and microcosm pro. I would like to eliminate leading zeros, i.e. my vm is 0 to 400 V, when measuring 50 V the display must be 50.0 instead of 0500.0. Can I get any suggestion .
 


Post relavent code, for suggestion.
 

Many Thanks lijoppans, I will try to implement in my code.

Hi iukhan,

My Code is as below:

 

My Code is as below:

Add the following code in ShowVoltage() function [before Lcd_Out (x,y,voltage); statement]

Code:
......
voltage[4] = temp % 10 + 48;

if (voltage[0]==48){
   voltage[0]=32;
   if(voltage[1]==48) voltage[1]=32;
}
Lcd_Out (x,y,voltage);
.....
 

Many thanks iukhan, this works like charm.
 

Hi all,
One of the two volts reading is fluctuating too much, I am using 16F877A for measuring AC volts. I have used step down transformer 400 : 5 V and a10k preset to further reduce to 2 V, which is fed to precision rectifier using 2 lm301, this reading is fluctuating while in other I have used resistive divider and have reduced the measuring volts to 400mV, this is also fed to similar precision rectifier but this reading does not fluctuate. I have used 100 nf capacitors after precision rectifiers and also on power supply pins of micro. Please suggest how to eliminate the fluctuations
 

Many thanks for such fast reply, will try it and come back soon.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…