Forum Discussion
Altera_Forum
Honored Contributor
12 years ago --- Quote Start --- There's room for improvements. A good quadrature encoder is expected to count on any rising or falling input edge, not only rising edge of one input channel. This way, the encoder resolution can be increased by a factor of four. Acting on all edges is also necessary to detect overun conditions respectively inplausible input sequences (hardware defects) and flag them as error. --- Quote End --- Yes - this would be 4x decoder then. I have code shown to detect rising and falling edges of both A and B signals (in posted code it is commented out). It is a matter of extra ELSIF statements in the process to correctly decode should the counter be incremented or decremented at those edges. For example on falling B, if A leads B (and this is declared to be incrementing the counter) then if B='1' and A='0' counter should be incremented and if B='0' and A='1' counter should be decremented. I will do an update and post the revision later. As for error - it can be detected when in all other cases not covered in the code. For my application in particular, user will know the error....flagging/flashing is not useful.