Probably Bug in Kye's QEDEngine
Duane Degn
Posts: 10,588
In Xanadu's treaded robot thread, Wildatheart reported some strange behavior in Kye's quadrature encoder object.
I was able to replicate the strange behavior.
The transition from 00 to 01 registers as an increase in the encoder count however the reverse transitions, from 01 to 00 doesn't decrement the count. It's possible to continuously increment the encoder count by transitioning between 00 and 01 without a net rotation of the encoder.
I'm attaching the program I used to test Kye's object.
I know I personally use a lot of Kye's objects and I figure a lot you probably do too. This bug isn't likely to cause trouble very often but it could cause strange behavior if you have repeated 00 to 01 and back transitions.
Edit: There was a bug in my demo program. Instead of displaying the new count and the total count, the program displayed the total count twice.
I was able to replicate the strange behavior.
The transition from 00 to 01 registers as an increase in the encoder count however the reverse transitions, from 01 to 00 doesn't decrement the count. It's possible to continuously increment the encoder count by transitioning between 00 and 01 without a net rotation of the encoder.
I'm attaching the program I used to test Kye's object.
I know I personally use a lot of Kye's objects and I figure a lot you probably do too. This bug isn't likely to cause trouble very often but it could cause strange behavior if you have repeated 00 to 01 and back transitions.
Edit: There was a bug in my demo program. Instead of displaying the new count and the total count, the program displayed the total count twice.
Comments
You are correct, the transition from 01 to 00 doesn't cause a change. But did you try this on both the rising and the falling pulse edges? One edge of the pulse will increment the count and the other edge will decrement the count - although the second condition is of no consequence at this point. If there's a fault on just one of the pulse edges, Houston has a problem.
Thanks for confirming this. I'm sure it'll be of help to other folks using this object.
I've used this object for robot races and I've not had a problem before... the PID control works for both going forward and backwards. Additionally, when I wrote it I tested it being able to count up and down...
It does count up and down.
The only time the problem shows up is when the motor is just about stopped. It's the single bit transitions back and forth that are the problem.
The code as it is should work in most applications but it doesn't follow the rules a "well behaved" quadrature encoder program should (it should catch all reverses).
I don't have a bug fix. The code is too advanced for my basic understanding of PASM. The problem would likely never be noticed if the encoder is being used on a motor. The problem would be more apparent if used on an encoder used as a knob.
It could be a problem if used with a motor if the motor oscillates while nearly stopped.
If you're one of the four who downloaded the "c" version, make sure and download the corrected "d" version. Or you can just fix the code yourself. The error is an obvious one.
Erlend
I've used the object in the Propeller Tool library several times.
I couldn't find any demo code for the object in the library so I'm attaching a couple of my demos here (this are demos to the library object).
Here's the simple demo:
I'm getting very close to having a useable demo for my quadrature encoder object.
Erlend