ansarmytheen
Full Member level 3
Hai friends,
In my project i interface an IR module with PIC 16F877a,This system is used for counting motro rotation.
PIC in Counter mode using timer1.Now the problem is that when i connect manually to an IR then PIC count properly.But when it connected to the motor it reads wrong count.OR it does not work properly.
Here i post my code.
CODE
int i=0,j=0,k=0;
void main()
{
trisc=0xff;
trisb=0;
t1con=0x0b;
tmr1l=0;
tmr1h=0;
while(1)
{
i=tmr1l;
if(i<50)
{
portb.f0=1;
}
if(i==50)
{
portb.f0=0;
portb.f1=1;
Delay_ms(100);
portb.f1=0;
portb.f2=1;
tmr1l=51;
}
if(i>100)
{
portb.f1=0;
tmr1l=0;
}
}
}
In my project i interface an IR module with PIC 16F877a,This system is used for counting motro rotation.
PIC in Counter mode using timer1.Now the problem is that when i connect manually to an IR then PIC count properly.But when it connected to the motor it reads wrong count.OR it does not work properly.
Here i post my code.
CODE
int i=0,j=0,k=0;
void main()
{
trisc=0xff;
trisb=0;
t1con=0x0b;
tmr1l=0;
tmr1h=0;
while(1)
{
i=tmr1l;
if(i<50)
{
portb.f0=1;
}
if(i==50)
{
portb.f0=0;
portb.f1=1;
Delay_ms(100);
portb.f1=0;
portb.f2=1;
tmr1l=51;
}
if(i>100)
{
portb.f1=0;
tmr1l=0;
}
}
}