Ac voltage calculation using pic16f877a

Status
Not open for further replies.

anjalimidhuna

Member level 3
Joined
Jan 4, 2014
Messages
62
Helped
2
Reputation
4
Reaction score
2
Trophy points
8
Location
india
Visit site
Activity points
358
Hi all,
i have searched a lot in Google as well as in our forum. but i didn't get a correct solution. :-(

i am trying to read ac voltage with ADC (channel 2) and display it to LCD. it shows value 486 (can be scale to 0) when ac supply is off. but when the supply is on it hold the LCD display in the previous position. :?:

Code:
void interrupt isr(void)
{
 if(TMR1IF==1)
 {
	TMR1IF=0;
	TMR1H=0XFC;
	TMR1L=0X17;
	cnt++;
	tmr++;
	if(cnt==5)
	{
		value=AdcRead(channel[2]);
		cnt=0;
	}
	if(tmr==1000)
	{
		tmr=0;
		lcdflag=1;
	}
 }
}
void main()
{
    T1CON=0b00000001;			
    TMR1H=0XFC;					
    TMR1L=0X17;					
    INTCON=0b11000000;					
    PIE1=0b00000101;			
	 Lcd_Init();
	 adc_init();
 while(1)
 {
	if(lcdflag==1)
	{
		LCD(Lcd_clear,ModCmd);
		Delay_ms(100);
		LCD(FstLin_FstColumn,ModCmd);
		Disp_STRING(int_to_string(value,buf));
		lcdflag=0;
	}
 }
}

i tried bit toggling in interrupt it works. but it have no change when it is in the if loop.
i am using hitech c with pic16f877a. i got the correct output when i programmed in micro c .

am i misd any cmds ??
is there any other setting ??
 
Last edited:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…