Rotary encoder: 4 counts per click?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Posts: 445
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 112 times
Been thanked: 99 times

Rotary encoder: 4 counts per click?

Postby MJU » Wed Dec 20, 2017 7:49 pm

Am I missing something? Probably I do :D

I've made a simple Flowchart with a GLCD and a rotary encoder.
The encoder triggers an interrupt and if the "check for change" macro doesn't return 255 the counter is read.

But each click gives me an increace or decrease of 4...
I've tried several changes for the encoder (fast/medium/slow) but this error is persistent.

What am I doing wrong?

User avatar
Matrix Staff
Posts: 14674
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4659 times
Been thanked: 4283 times

Re: Rotary encoder: 4 counts per click?

Postby Benj » Wed Dec 20, 2017 8:24 pm


I've experienced this.

For each click of the encoder it travels through 4 states hence the output count of 4. Not sure why but it's normal.

Simply divide the number by 4 (or right shift the value by 2 for efficiency) to collect the click count.

Posts: 56
Joined: Tue Sep 16, 2008 2:09 pm
Location: Minnesota USA
Has thanked: 4 times
Been thanked: 17 times

Re: Rotary encoder: 4 counts per click?

Postby alanwms » Wed Dec 20, 2017 9:57 pm

The reason it is called a "quad" encoder, is because it counts the state change of each edge. Since there are 4 edges per cycle, that would equate to 4 counts per "count".
Your encoder is probably mechanically indented creating the sine and cosine signal. For a no indented encoder (such as on a motor) it would be possible to count a single edge.
The advantage of this is that the encoder resolution for a 200 count/rev encoder would be 800 counts per revolution. Creating better resolution

Hope this throws some light on the subject.
These users thanked the author alanwms for the post (total 2):
Benj (Thu Dec 21, 2017 12:33 pm) • medelec35 (Mon Jul 23, 2018 9:13 am)
Rating: 10%