i am a bit new to arduino programing an i am working on a project for my wood shop. I am looking to create a DRO (digital read out) using an incremental rotary encoder. i have googled this topic quite a bit and there is not allot of info reguarding this specifically but there is plenty on doing something similar.
Right now i am having throuble grasping the idea of how i go about measureing the pulses from the encoder, specifically on how i can code it to be as accurate as possible. i have read that i want to count the riseing and falling edges of the pulses that come off of the CLK and DT lines from the encoder and to use a volatile int to store those values. i also need to determin witch direction the encoder is turning, but im still not shure how i would go about codeing that.
Is there anybody that had any expierence in this subject that could provide me with an example sketch and possibly explain why i would use a volatile int?
It's a long thread, so you may want to jump to the end and just cut out the bits that read the encoders. Alternatively, reading from the start will let you see how we evolved the code from the basics, which IIRC, did start with reading encoder pulses.