Reading incremental encoder interupt
Hi
I would like to make a small project to read an incremental encoder
with differencial A/B outputs and send its position on request via RS232
I need to count the pulses, determinate if it is going CW or CCW
on a serial request I need to send the number of counted pulses via RS232
Which way shall I go:
Use I/O ports for the A & B pulses and use a Hardware UART to handle the incoming request of the encoder (the request command is only 2 bytes)
Or count the pulses of the encoder with an interupt based routine ?
Any idea's are welcome
1 Attachment(s)
Re: Reading incremental encoder interupt
Hi I have a problem with interrupts code in pbp.I want to count encoder ticks in both directions,I have done the code without interrupt routine and it works fine but it is to slow for greater speeds.So I tryed with INT on port B.0 but it is not working.I am useing PIC 16F877A, compiler 2.5. Here is the code which is not working.Where was I wrong?
Attachment 8380
1 Attachment(s)
Re: Reading incremental encoder interupt
I used the interrupt for my low cost mechanical encoder to control my power supply.
You can find the whole code in the attachement.
The interrupt service routin is the following:
'---[INT - interrupt handler]---------------------------------------------------
ToggleLED1:
if EB=0 then INC_DEC=2
IF EB=1 THEN INC_DEC=1
@ INT_RETURN
Thanks to Darrel Taylor work.
Bye
Ambrogio
Iw2fvo