Your single channel encoders are unidirectional or "tachometer" encoders.
(They are used to provide speed information).
Best regards,
Luciano
Your single channel encoders are unidirectional or "tachometer" encoders.
(They are used to provide speed information).
Best regards,
Luciano
Yes, this is the right one.
See this thread:
Decoding quadrature encoders
http://www.picbasic.co.uk/forum/showthread.php?t=1552
Luciano
thank you Luciano
I will read all the thread and if I dont' understand all
I would ask you of another questions
Hello Picusers
Now I use an optical coder with 1000 pulses per turn,but the final result is not good,the PIC does not count all the pulses (~ -200 pulses)
For you it's a problem of time with the routine of the LCD?
DEFINE OSC 20 'Fréquence du quartz utilisé
ADCON1=7 'PortA et PortE en numérique
'-----------------------------------------------------------------
'Configuration LCD
DEFINE LCD_DREG PORTB ' LCD o/p on port B
DEFINE LCD_DBIT 4 ' LCD on lower 4 bits of port B
DEFINE LCD_RSREG PORTB ' LCD reset on port B
DEFINE LCD_RSBIT 3 ' LCD reset portB.3
DEFINE LCD_EREG PORTB ' LCD enable on port B
DEFINE LCD_EBIT 2 ' LCD output on PortB.2
DEFINE LCD_BITS 4 ' LCD o/p is 4 bit data
DEFINE LCD_LINES 2 ' Number of lines on LCD = 2
DEFINE LCD_COMMANDUS 1500
'-------------------------------------------------------------------
'Configuration des registres
TRISB = %00000011 ' Port B en sortie sauf B1 et B0
OPTION_REG = %01000000 ' Config registre
INTCON = %10010000 ' Config registre
'----------------------------------------------------------------------
'Déclarations des variables
Pulse_Rev VAR WORD ' Pulses par Rev
Pulse_Rev = 0
'-----------------------------------------------------------------------------
On Interrupt Goto ISR ' Si appui sur le BP saut en "ISR"
Main:
Lcdout$fe,1
Lcdout #Pulse_Rev," pulses" 'Affiche valeur variable incrément
pause 1
goto Main
Disable 'interdit toute interruption
'-------------------------------------------------------------------------------
'Routine d'interruption + comptage
ISR:
Pulse_Rev = Pulse_Rev +1 'Incrémente de 1 la valeur de la variable
INTCON.1 = 0 'Remet le flag d'interruptio à 0
Resume 'fin de l'interruption
Enable 'Autorise à nouveau une interruption
End
How fast is the encoder turning?
Even in assembler there is a limit in the speed a PIC can respond.
As a suggestion, try to put the LCD commands inside your ISR handler. If they are executed within the main, lot of time is wasted with no reason. If you don't move the encoder, LCD will still be accessed.
Ioannis
Bookmarks