sbit LCD_RS at RC4_bit;
sbit LCD_EN at RC5_bit;
sbit LCD_D4 at RC0_bit;
sbit LCD_D5 at RC1_bit;
sbit LCD_D6 at RC2_bit;
sbit LCD_D7 at RC3_bit;
sbit LCD_RS_Direction at TRISC4_bit;
sbit LCD_EN_Direction at TRISC5_bit;
sbit LCD_D4_Direction at TRISC0_bit;
sbit LCD_D5_Direction at TRISC1_bit;
sbit LCD_D6_Direction at TRISC2_bit;
sbit LCD_D7_Direction at TRISC3_bit;
// End LCD module connections
char *l,*m,*q,*v,y[7],u[7],n[7],o[7];
unsigned int k,j,i,b,a;
unsigned int e;
float x;
float t;
void main() {
TRISC = 0x00; // PORTC All Outputs
TRISA = 0b00000110; // PORTA All Outputs, Except RA1 and RA2
ANSEL=0b00000110;
ADCON1=0b00000000; // Fosc/8
CMCON0 = 0x07 ; // Disbale comparators
Lcd_Init(); // Initialize LCD
//Lcd_Cmd(_LCD_CLEAR); // CLEAR display
Lcd_Cmd(_LCD_CURSOR_OFF);
//Lcd_Out(1,7," "); // Cursor off
//Lcd_Out(1,1,Message1);
//Lcd_Chr(2,10,'V');
//do {
while(1)
{
ADCON0=0b00001001;
Delay_us(50);
ADCON0.GO_DONE=1;
t = ADC_Read(2);
k=t;
k=k*6.911961-3510.65;//0.48876;
if (t<509)
Lcd_out(1,7,"-");
else
Lcd_out(1,7," ");
j=k/10;
i=k%10;
inttostr(j,o);
inttostr(i,n);
l=ltrim(o);
m=ltrim(n);
if ((j<=99)&&(j>9)){
Lcd_out(1,8,l);
Lcd_out(1,10,".");
Lcd_out(1,11,m);
}
else if (j<=9)
{
Lcd_out(1,8,l);
Lcd_out(1,9,".");
Lcd_out(1,10,m);
//Lcd_out(1,13," ");
}
else
{
Lcd_out(1,8,l);
Lcd_out(1,11,".");
Lcd_out(1,12,m);
}
///////
ADCON0=0b00000101;
Delay_us(30);
ADCON0.GO_DONE=1;
x = ADC_Read(1);
e=x;
e=1.3*(e*3.42131*0.28572*2-1000)-2;//-20;
if (x<509)
Lcd_out(1,1,"-");
else
Lcd_out(1,1," ");
b=e/10;
a=e%10;
inttostr(b,y);
inttostr(a,u);
q=ltrim(y);
v=ltrim(u);
if ((b<=99)&&(b>9)){
Lcd_out(1,2,q);
Lcd_out(1,4,".");
Lcd_out(1,5,v);
//Lcd_out(1,5," ");
}
else if (b<=9)
{
Lcd_out(1,2,q);
Lcd_out(1,3,".");
Lcd_out(1,4,v);
//Lcd_out(1,4," ");
}
else {
Lcd_out(1,2,q);
Lcd_out(1,5,".");
Lcd_out(1,6,v);
}
delay_ms(500);
} //while(1);
}