Hello everyone,
i need some help about reading voltage that going to ADC of PIC18F252 and then display that value to LCD.my input of adc is from current sensor that produce output in term of voltage
My range input voltage should be 4.00V to 4.10v only,and the output produce at lcd also in that range but the problem here at certain time the output at lcd go outside that range (but in short time). Why its happen?. I really need precision value to calculate some formula.
And second problem,the output that display at lcd are change from one to another are to fast (about 1 second).
below is my coding
unsigned char ch;
unsigned int adc_rd;
char *text;
long tlong,;
void LCD()
{
Delay_ms(500);// need delay
adc_rd = ADC_Read(2); // A/D conversion. Pin RA2 is an input.
Lcd_Out(2,1,text); // Write result in the second line
tlong = (long)adc_rd * 4800; // Convert the result in millivolts
tlong = (tlong / 1024)
ch = tlong / 1000; // Extract volts (thousands of millivolts)
// from result
Lcd_Chr(2,9,48+ch); // Write result in ASCII format
ch = (tlong / 100) % 10; // Extract hundreds of millivolts
Lcd_Chr_CP(48+ch); // Write result in ASCII format
Lcd_Chr_CP('.');
ch = (tlong/ 10) % 10; // Extract tens of millivolts
Lcd_Chr_CP(48+ch); // Write result in ASCII format
ch = tlong % 10; // Extract digits for millivolts
Lcd_Chr_CP(48+ch); // Write result in ASCII format
Delay_ms(1);
}
i need some help about reading voltage that going to ADC of PIC18F252 and then display that value to LCD.my input of adc is from current sensor that produce output in term of voltage
My range input voltage should be 4.00V to 4.10v only,and the output produce at lcd also in that range but the problem here at certain time the output at lcd go outside that range (but in short time). Why its happen?. I really need precision value to calculate some formula.
And second problem,the output that display at lcd are change from one to another are to fast (about 1 second).
below is my coding
unsigned char ch;
unsigned int adc_rd;
char *text;
long tlong,;
void LCD()
{
Delay_ms(500);// need delay
adc_rd = ADC_Read(2); // A/D conversion. Pin RA2 is an input.
Lcd_Out(2,1,text); // Write result in the second line
tlong = (long)adc_rd * 4800; // Convert the result in millivolts
tlong = (tlong / 1024)
ch = tlong / 1000; // Extract volts (thousands of millivolts)
// from result
Lcd_Chr(2,9,48+ch); // Write result in ASCII format
ch = (tlong / 100) % 10; // Extract hundreds of millivolts
Lcd_Chr_CP(48+ch); // Write result in ASCII format
Lcd_Chr_CP('.');
ch = (tlong/ 10) % 10; // Extract tens of millivolts
Lcd_Chr_CP(48+ch); // Write result in ASCII format
ch = tlong % 10; // Extract digits for millivolts
Lcd_Chr_CP(48+ch); // Write result in ASCII format
Delay_ms(1);
}