Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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.
 
  • Like
Reactions: 4s7ww

    4s7ww

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

**broken link removed**
 

Attachments

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

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
    sch24.png
    7.8 KB · Views: 122

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 .
 

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:

// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections

unsigned int value;
unsigned char car,x,y;
char *voltage = "000.0";
long temp;

void ShowVoltage (int x,int y, unsigned int value) // Routine to show the ADC_read conversion in Volt
{
temp = (long)value* 50 * 80;
temp = (temp / 1023);

voltage[0] = (temp/1000)%10 + 48;
voltage[1] = (temp/100)%10 + 48;
voltage[2] = (temp/10)%10 + 48;
voltage[4] = temp % 10 + 48;
Lcd_Out (x,y,voltage);
delay_ms(10);
}

void main() {

ADCON1 = 0x80; // All analogs - right justify
TRISA = 0xFF; // PORTA Input
TRISB = 0; // PORTB Output

Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);

do {
value = ADC_Read(1); // channel 1 (RA1)
Lcd_Out(1,1,"Ch1:");
ShowVoltage(1,6,value);
} while(1);
}
 

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);
.....
 
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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top