I am trying to create a little project with spin. I have an encoder which two outputs A+ and B+ are connected to the propeller chip. A and B outputs produces a 360 pulses per each rotation and depending of the direction of rotation A+ will lead or lag to the B+. I want to be able to get the direction of the rotation and the speed of the rotation using parallax chip i mentioned in title. Max input frequency from the encoder will be around 12 kHz, difference between A+ and B+ is a quarter of the period.
To accomplish this i am trying to use internal counters ctra and ctrb. But i am really stuck on that. I am getting some date from the encoder, but it makes no sense. First i only getting pulses from the encoder when encoder wheel is moving, but i am keep getting values from phsa even though the encoder stopped. Plus if i do the single full rotation on the encoder i expect my value of phsa add up to 360. But the numbers i am getting are way different.
In the examples i found in forum seems that everyone is using gate time and getting the amount of pulses which happens during that time. Is it possible to measure the frequency with these counter without using this wait gate and if the frequency from the encoder isn't constant. Can you point out what i am doing wrong here, and maybe explain a bit how actually these counter works? I have read the parallax article about the counter.
This is my code example, for now i am just trying to read single encoder input and display value.
Thank you for help.