encoder2
Bernard
Posts: 3
Hi
Thanks for your answer(So quick), i understood my mistake,
i was searching since 1 day, I saw your answer to somebody else bebore.
My problem is when the encoder increment or decrement. I have not the same numbers of points.
I's not i problem of quality of coder or rebounce.
decrement is always good 1 by 1.(increment always 2 by 2 or more)
if I change the order in the PGM of inc and decr like this:
Check_Encoder:
· encNew = EncPort & %0011 ·'IN0 coderA IN1 coderB
· IF ((encNew ^ encOld) <> 0) THEN
· IF (encOld.BIT0 ^ encNew.BIT1) THEN
· value = value +(Span - 1) // Span····· ' increment by·decrement value
· ELSE
· value = value + 1 // Span············· ' decrement by increment value
· ENDIF
· encOld = encNew
· ENDIF
· RETURN
The problem is reverse
Can I do something or it's a problem of Basic stamp speed.
Regards
Bernard
Thanks for your answer(So quick), i understood my mistake,
i was searching since 1 day, I saw your answer to somebody else bebore.
My problem is when the encoder increment or decrement. I have not the same numbers of points.
I's not i problem of quality of coder or rebounce.
decrement is always good 1 by 1.(increment always 2 by 2 or more)
if I change the order in the PGM of inc and decr like this:
Check_Encoder:
· encNew = EncPort & %0011 ·'IN0 coderA IN1 coderB
· IF ((encNew ^ encOld) <> 0) THEN
· IF (encOld.BIT0 ^ encNew.BIT1) THEN
· value = value +(Span - 1) // Span····· ' increment by·decrement value
· ELSE
· value = value + 1 // Span············· ' decrement by increment value
· ENDIF
· encOld = encNew
· ENDIF
· RETURN
The problem is reverse
Can I do something or it's a problem of Basic stamp speed.
Regards
Bernard
Comments
Bernard: What are you trying to do? Are you saying you want to increment by value X and decrement by value Y? That is not a problem, it's a simple change in the code. Just remember that with any microcontroller, the rate you can change the encoder will depend on how frequently your check it. I've posted a program that shows how to put the encoder check in the top part of a main program loop that does everything else as a task, that way the encoder is checked every iteration of the loop and gives the best performance.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office