Trouble with PIC interrupts with a incremental encoder

Status
Not open for further replies.

Err404

Junior Member level 1
Joined
Mar 20, 2011
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
London
Activity points
1,429
I am relatively new to using PICs (or any microcontrollers in anger).

I have experimented with a couple of pic16f variants using PICC lite on a PicKit2.

I think the major problem I'm having now is debouncing the signahttps://www.edaboard.com/#topl pins A and B from the (gray code) encoder.

I am trying to use the PIC's (16f628A) 'on PortB change' interrupt event.

But I could sure use some guidence right now as I can't see the wood for the trees!


//Method of detecting: (pinA:last xor pinB:current) ? 1 -> CW : 0 -> CCW

// Am trying to take care of debounce on encoder by looking for
// change back & forth, but should probably have a TMR0 timeout as well
// If it goes 10 - 11 - 10 then it's bouncing
 

Here's the code I've got:
 

Attachments

  • encoder.txt
    2.7 KB · Views: 73

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…