A
aduri
Guest
Ciao,
Ho provato questi 2 programmi, ma non funzionano molto bene.
Essi perdere alcuni impulsi durante il conteggio.
Can anybody help me?
GrazieCodice:'*
'* Project name: Rotary encoder
'* Descrizione: Rotary encoder con interrupt
'* Test di configurazione:
'Pensione: Il mio consiglio Aduri
'MCU: PIC16F877A
'Oscillator: HS, 20.000 MHz
'Ingressi: A su RB4, B su RB1
'SW: mikroBasic v5.0 o superiore
'* NOTE:
'LCD su PORTD, trigger con CD4093
'*programma Rotary_encoder
dim temp come byte
dim txt come stringa [3]sotto procedura di interrompere 'Interrompere il servizio di routine
Se PORTB.4 = 1 alloraaltro
Se PORTB.1 = 1 allora
temp = temp - 1
altro
temp = temp 1
fine se
fine se
delay_ms (25) 'ritardo
INTCON.RBIF = 0 'interrompere bandiera disabilitare
End Subprincipali:
LCD_init (PORTD) 'display LCD PORTD
TRISB =% 11111111 'PORTB.1 e ,4 ingressi sono
INTCON =% 10001000 'Enable interrupt sul cambiamentomentre 1 = 1 'loop
delay_ms (100)
bytetostr (temp, txt)
LCD_out (1,1, "Numero impulsi:")
LCD_out (2,1, txt)
wendfine.
Ho provato questi 2 programmi, ma non funzionano molto bene.
Essi perdere alcuni impulsi durante il conteggio.
Can anybody help me?
GrazieCodice:'*
'* Project name: Rotary encoder
'* Descrizione: Rotary encoder con interrupt
'* Test di configurazione:
'Pensione: Il mio consiglio Aduri
'MCU: PIC16F877A
'Oscillator: HS, 20.000 MHz
'Ingressi: A su RB4, B su RB1
'SW: mikroBasic v5.0 o superiore
'* NOTE:
'LCD su PORTD, trigger con CD4093
'*programma Rotary_encoder
dim temp come byte
dim txt come stringa [3]sotto procedura di interrompere 'Interrompere il servizio di routine
Se PORTB.4 = 1 alloraaltro
Se PORTB.1 = 1 allora
temp = temp - 1
altro
temp = temp 1
fine se
fine se
delay_ms (25) 'ritardo
INTCON.RBIF = 0 'interrompere bandiera disabilitare
End Subprincipali:
LCD_init (PORTD) 'display LCD PORTD
TRISB =% 11111111 'PORTB.1 e ,4 ingressi sono
INTCON =% 10001000 'Enable interrupt sul cambiamentomentre 1 = 1 'loop
delay_ms (100)
bytetostr (temp, txt)
LCD_out (1,1, "Numero impulsi:")
LCD_out (2,1, txt)
wendfine.