-
Notifications
You must be signed in to change notification settings - Fork 153
Open
Description
First of all - using a state machine for this task is an elegant solution I must say.
I tested the code and it looks like it detects full step when both pins are high contrary to written that the step is detected when both pins go low:
CCW: CW:
10 01
00 00
01 10
11 <- this state returns DIR_CCW 11 <- this state returns DIR_CW
Maybe I`m doing something wrong or I have different kind of rotary encoder but for me the sequence is like this:
CCW: CW:
10 01
11 11
01 10
00 00
Here is the state table that works for me:
const unsigned char ttable[7][4] = {
// R_START
{R_START, R_CW_BEGIN, R_CCW_BEGIN, R_START},
// R_CW_FINAL
{R_START | DIR_CW, R_START, R_CW_FINAL, R_CW_NEXT},
// R_CW_BEGIN
{R_START, R_CW_BEGIN, R_START, R_CW_NEXT},
// R_CW_NEXT
{R_START, R_CW_BEGIN, R_CW_FINAL, R_CW_NEXT},
// R_CCW_BEGIN
{R_START, R_START, R_CCW_BEGIN, R_CCW_NEXT},
// R_CCW_FINAL
{R_START | DIR_CCW, R_CCW_FINAL, R_START, R_CCW_NEXT},
// R_CCW_NEXT
{R_START, R_CCW_FINAL, R_CCW_BEGIN, R_CCW_NEXT},
};
Maybe this helps someone else...
Metadata
Metadata
Assignees
Labels
No labels