Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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
how can calculate it ? , means equation =?
----------------------------------------------------------------------------
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
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...
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 .
// 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:
......
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); .....