solkirans
Üye
- Katılım
- 10 Kas 2008
- Mesajlar
- 31
- Puanları
- 1
- Yaş
- 40
Merhaba
16f877A kullanarak, aşağıdaki kod ile bir encoder okuyorum, encoder hızlı dönerken ( 1500 2000 rpm) kod çalışıyor fakat encoder yavaşladığında ( 20~30 rpm) hiç bir pulse'ı sayamıyorum. Sorun ne olabilir acaba?
void interrupt(void) {
if(INTCON.INTF == 1)
{
if (PORTB.F1 == 1) // pulse geldiğinde diğer kanal 1 ise artı yonde gidiyoruz
{
pulse++;
}
if (PORTB.F1 == 1) // pulse geldiginde diger kanal 0 ise eksi yonde gidiyoruz
{
pulse--;
}
INTCON.INTF = 0; //You HAVE to clear interrupt flag
}
}
void main()
{
TRISA = 0xFF;
PORTA = 0x00;
TRISE = 0x00;
PORTE = 0x00;
TRISB = 0x0F;
PORTB = 0x0F;
TRISC = 0x00;
PORTC = 0x00;
TRISD = 0x00;
PORTD = 0x00;
PORTB.F7 = 1;
//ADCON1 = 0x00;
INTCON.GIE = 1; //Enable Global Interrupt
INTCON.INTE = 1; //Enable RB0/INT external Interrupt
INTCON.PEIE = 0; //Disable all unmasked peripheral interrupt
OPTION_REG.INTEDG = 1; //Interrupt on rising edge
Lcd_Config(&PORTD, 4, 5, 7, 3, 2, 1, 6);
Lcd_Cmd(Lcd_CLEAR); // Clear display
Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off
while(1)
{
Lcd_Out(1, 1,"Position:");
yazici(pulse);
}
}
16f877A kullanarak, aşağıdaki kod ile bir encoder okuyorum, encoder hızlı dönerken ( 1500 2000 rpm) kod çalışıyor fakat encoder yavaşladığında ( 20~30 rpm) hiç bir pulse'ı sayamıyorum. Sorun ne olabilir acaba?
void interrupt(void) {
if(INTCON.INTF == 1)
{
if (PORTB.F1 == 1) // pulse geldiğinde diğer kanal 1 ise artı yonde gidiyoruz
{
pulse++;
}
if (PORTB.F1 == 1) // pulse geldiginde diger kanal 0 ise eksi yonde gidiyoruz
{
pulse--;
}
INTCON.INTF = 0; //You HAVE to clear interrupt flag
}
}
void main()
{
TRISA = 0xFF;
PORTA = 0x00;
TRISE = 0x00;
PORTE = 0x00;
TRISB = 0x0F;
PORTB = 0x0F;
TRISC = 0x00;
PORTC = 0x00;
TRISD = 0x00;
PORTD = 0x00;
PORTB.F7 = 1;
//ADCON1 = 0x00;
INTCON.GIE = 1; //Enable Global Interrupt
INTCON.INTE = 1; //Enable RB0/INT external Interrupt
INTCON.PEIE = 0; //Disable all unmasked peripheral interrupt
OPTION_REG.INTEDG = 1; //Interrupt on rising edge
Lcd_Config(&PORTD, 4, 5, 7, 3, 2, 1, 6);
Lcd_Cmd(Lcd_CLEAR); // Clear display
Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off
while(1)
{
Lcd_Out(1, 1,"Position:");
yazici(pulse);
}
}