Quote:
Originally Posted by jhersh
"UpRisingEdge => count A if B is high"
"UpFallingEdge => count A if B is low"
|
Here you lost me. I would have been ok if you'd said
"DownRisingEdge => countup A if B is high"
"DownFallingEdge => countdown A if B is low"
Quote:
Here are the much anticipated logic equations used in the 1x and 2x quadrature decoding mode of the counters.
Count = (ARising | AFalling) & ((BHigh & UpRisingEdge) | (BLow & UpFallingEdge))
CountUp = Count & !(BHigh ^ DownRisingEdge ^ ARising)
CountDown = Count & (BHigh ^ DownRisingEdge ^ ARising)
With this, there will hopefully be no more mystery.
|
Ok, I'm going to think outloud and see if you agree I see the light.
Lets try an example for 1x: UpRisingEdge = true , DownRisingEdge=false
Assume B is static high so Bhigh=true
Now A channel gets a rising pulse so ARising = true , AFalling= false
Evaluate 1)
Count = true;
(BHigh ^ DownRisingEdge ^ ARising)=(true^false^true) = false;
so
CountUp = true & !(false) = true
CountDown = true&false = false
Hence we count up ....
Now A channel gets a falling pulse so Arising = false, AFalling = true
Evaluate 2)
Count = true:
(BHigh ^ DownRisingEdge ^ ARising)=(true^false^false) = true;
so
CountUp= true &!(true)=false
CountDown = true&true = true
Hence we count down ....
This repeats so with a stuck B channel, it oscillates.
In the case where B is not static , it inhibits the count when AFalling = true because Bhigh= false during that transition.
So I guess I'm with you.
Since this logic requires a transition to count 1x properly, it seems the code should throw a flag when the B is static since this is an invalid input. Otherwise why require it.