Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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
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:

https://www.edaboard.com/threads/304920/#post1305244

102531d1393339674-sim.png
 

Attachments

  • adc o.rar
    92.8 KB · Views: 79
  • sim.png
    sim.png
    148.3 KB · Views: 95
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top