It also uses digitalRead, which is much slower than reading the port pins directly, and it spends (wastes) some time reporting serial data to the host PC. It is a polled design, which could be speeded up by using interrupts – the code is suitable – and there is a 10ms delay which could be reduced to zero, but in either of these cases, the output is likely to follow contact bounce – it will still count correctly, but there will be additional up and down counts before it settles to the correct count. ![]() ![]() error – an invalid combination of two old bits and two new bitsĪn advantage of the look-up table approach is that all valid and invalid conditions are definitely covered, in a methodical and easily-read (I claim) form.As there are only 16 possible combinations of two new bits (the encoder has two outputs) and two previous bits, a 16×1 or 4×4 look-up table can, depending on new and previous readings, return: They are compared using a simple look-up table rather than the state machines or XOR tricks sometimes used.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |