I can find direction with this code:
A tied to portb.4
B tied to portb.5
Direction = portb.5 ^ portb.4
lcdout $FE,1,DEC(Direction)
but, the reading is NOT consistent , if I turn clockwise , Direction is not always 1 ( well , most of the time it is 1 ) and vice versa
any tips anyone ?
When doing it like that you don't "where" in the cycle you are reading the inputs.
Since you're basically first reading one input then the other it's possible for "the other" input to change state from what it actually was when you read the first input.
Try something likeThis will insure that both bits are sampled at exactly the same time.Code:Temp = PortB Direction = Temp.5 ^ Temp.4
/Henrik.
Sorry to be so dumb, but I don't see how XOR'ing A and B produces a direction signal. When I try it on paper I get a new signal at double the frequency??
Bookmarks