Closed sconklin closed 11 years ago
I hope this works, I inspected it pretty carefully but I have no way to test it. Let me know if you have any questions.
Hi Steve.
this night I did merge to my code. I am not completely sure what code suppose to do better. First I fixed code to get compiled and then tested with machine. Start with numbers like 1000 and when I move head start to increase even when encoder didn't move. if you want we can keep as separated branch and try to test it until works. I zipped the code that compiled.
I will go back main branch to my code by now. Anyway thanks for help.
Mar
On Fri, Mar 29, 2013 at 10:22 PM, Steve Conklin notifications@github.com wrote:
Differences between the old and new encoder methods:
Old code used string compares, New code uses an arrary lookup
Old code:
Tracked each change in the encoder signals as a movement in a direction Accepted two movements in the same direction as movement in that direction.
Divided the number of changes by four to get a position
Old encoder made changes according to this table, which treats "no change" conditions 00 and 11 as movement (_). //directionEncoders +=8segmentEncoder; // head direction // old new result old new // 00 00 +1 0 0 () // 00 10 +1 0 2 // 10 11 +1 2 3 // 11 01 +1 3 1 // 01 00 +1 1 0 // // 01 11 -1 1 3 // 11 11 -1 3 3 (*) // 11 10 -1 3 2 // 10 00 -1 2 0 // 00 01 -1 0 1
New Code:
Counts each cycle through all 4 encoder values as a movement in a direction Is able to declare a direction after one cycle Does not divide by four to get a position No movement is counted if input signals do not change
General Changes:
Used unsigned char where possible to save memory
Signed-off-by: Steve Conklin steve@conklinhouse.com
You can merge this Pull Request by running
git pull https://github.com/sconklin/knitic for-upstream
Or view, comment on, or merge it at:
https://github.com/mcanet/knitic/pull/22
Commit Summary
Handle encoders with a state machine
File Changes
M arduino_code/openKnitting_handMadepcb_v0_1/openKnitting_handMadepcb_v0_1.ino (201)
Patch Links:
https://github.com/mcanet/knitic/pull/22.patch https://github.com/mcanet/knitic/pull/22.diff
Differences between the old and new encoder methods:
Old code used string compares, New code uses an arrary lookup
Old code:
New Code:
General Changes:
Used unsigned char where possible to save memory
Signed-off-by: Steve Conklin steve@conklinhouse.com