Sign In

Trouble In Sending The Value In Lc

anusam anusam2004@gmail.com India

Hardware: Using Pic16f6887a Software: Using Mplab With Hi-tech Compiler

I unable get proper ouput in display unit w.r.t varying input reference voltage

Images

trouble in sending the value in lc

Program

#include<pic.h>
#include<lcd.h>

void adc_init();
void adc0();
void adc1();
void hex_dec_cur(unsigned char);

unsigned int temp1,temp0;
unsigned int j,v1,v2;

void main()
{
TRISC=0x0C;

adc_init();
lcd_init();

command(0x80);
//lcd_condis("   ADC testing  ",16);
command(0xc0);
//lcd_condis("    Display     ",16);
delay(60000);
command(0x80);
//lcd_condis("VOLTAGE 1        ",16);
command(0xc0);
//lcd_condis("VOLTAGE 2 :      ",16);
delay(60000);

while(1)
{
adc0();
command(0x85);
hex_dec_cur(v1);

adc1();
command(0xc5);
hex_dec_cur(v2);


}
}

void adc_init()
{
  ADCON1=0x02;		 // 8-channel,ADC control
  TRISA=0xff;		 // to select the port A as input port
}

void adc0()
{
 temp0=0;
for(j=0;j<10;j++)
 {
    ADCON0=0x00;			// Channel select (Cha: 0)
    ADON=1;					// ADC module ON
    delay(255);
    ADCON0 =0x05;           // selecting a particular channel and making the go/done bit high
    while(ADCON0!=0X01);	// Chk whether conversion finished or not
	temp1 = ADRESH;			// 8 bit value taken into one variable 
 temp0 = temp0 + temp1;
 }
v1=temp0/1;
}

void adc1()
{
temp0=0;
 for(j=0;j<10;j++)
 {
    ADCON0=0x08;			// Channel select (Cha: 0)
    ADON=1;					// ADC module ON
    delay(255);
    ADCON0 =0x0d;           // selecting a particular channel and making the go/done bit high
    while(ADCON0!=0X09);	// Chk whether conversion finished or not
	temp1 = ADRESH;			// 8 bit value taken into one variable 
 temp0 = temp0 + temp1;
 }
v2=temp0/1;
}

void hex_dec_cur(unsigned char vv)
{
 h=vv/100;
 hr=vv%100;
 t=hr/10;
 o=hr%10;

 lcd_disp(h+0x30);
 lcd_disp(t+0x30);
 lcd_disp('.');
 lcd_disp(o+0x30);
}

Post a reply to anusam

Think you can help anusam ? Then post your thoughts that might help anusam . You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.