As far as I understood the spec of the KY040, I had assumed for a "constant turning speed" the output of the encoder looks like the following:
Clockwise
Counter clockwise
As far as I get it in the simulation, it looks more like:
Clockwise
Counter clockwise
The high parts (for CW) / low parts (for CCW) are much longer.
So, the edge sequence is right but the "duty cycle" seems strange to me. I thought this should be 50:50 be the sensor wheel.
Background:
I have seen some debouncing algorithm which do fail see any rotation. These were not based on edge or pin change detection, but used periodical probing of DT and CLK.
Clockwise
- Code:
DT ___/"""\___/"""\___/"""\___/"""\
CLK _/"""\___/"""\___/"""\___/"""\___
Counter clockwise
- Code:
DT _/"""\___/"""\___/"""\___/"""\___
CLK ___/"""\___/"""\___/"""\___/"""\
As far as I get it in the simulation, it looks more like:
Clockwise
- Code:
DT """""\__/"""""""""""""""""""""\__/"""
CLK """\__/"""""""""""""""""""""\__/"""""
Counter clockwise
- Code:
DT __/""\____________________/""\____
CLK ___/""\____________________/""\__
The high parts (for CW) / low parts (for CCW) are much longer.
So, the edge sequence is right but the "duty cycle" seems strange to me. I thought this should be 50:50 be the sensor wheel.
Background:
I have seen some debouncing algorithm which do fail see any rotation. These were not based on edge or pin change detection, but used periodical probing of DT and CLK.
Last edited by arcachofo on Fri Apr 29, 2022 2:06 pm; edited 1 time in total (Reason for editing : Mark as solved (green color))