Hi,
Anyone else here using the two bit rotory encoders ?
These are the type with five terminals, one for positive, one for ground, one for the push switch, and two for the two bits. I dont need the push switch right now, so am just using the two bits and plus and minus supplies.
The internal working is such that if terminal 1 goes to ground before terminal 2 (the two bits) then the program detects rotation in one direction, and if 2 before 1 then the other direction, and there is also logic for sensing which one has been released first. Supposedly this can be used to increment say a large number counter that counts from say zero to over 65,000 but it can really go up to whatever you want it to go up to such as type long long or even single digits grouped any way you wish.
So the typical use is to set a setting for another device, such as a frequency generator. For example, say you want to set it to 1Hz, then you turn the encoder one click clockwise.
Then for 2Hz, another click to the right.
Now say you really wanted 32Hz. After you do the above, you push the button in and the 'counter' display moves to the next digit to the left (the 10's digit), and then you turn the encoder one more click and it goes up to 12, then if another click clockwise it goes to 22, then 32, etc.
Now say you want 432Hz, you push again then turn the rotory encoder four clicks clockwise, and the counter display goes to 432. Seems simple enough.
However, sometimes the rotory encoder does not respond as well as we would like, so it misses some counts. It may take 7 clicks clockwise to get to 4 instead of just 4.
The library i am using is simple enough, and it detects all possible state transitions and increments or decrements the counter as it should. It just doesnt seem fast enough even though it uses two interrupts.
It may be that the I2C display routine does not like to be interrupted. If i allow it to be interrupted it gets lost and does not display anymore, just the numbers that had shown up before turning the encoder. If i disable interrupts when displaying a number, then the display works fine but the encoder does not catch all the turns because it is not allowed to interrupt the display routine.
I can probably use a 4 bit parallel display instead, but i would like it to work with the I2C display too.
Any ideas, or how you do it in your code?
Maybe it would be better to modify the library, but it still wont like being interrupted while it is sending bits to the display.
When i uses three switches: one for up, one for down, and one for digit select, it works perfectly because the switches are polled, not using interrupts.
Anyone else here using the two bit rotory encoders ?
These are the type with five terminals, one for positive, one for ground, one for the push switch, and two for the two bits. I dont need the push switch right now, so am just using the two bits and plus and minus supplies.
The internal working is such that if terminal 1 goes to ground before terminal 2 (the two bits) then the program detects rotation in one direction, and if 2 before 1 then the other direction, and there is also logic for sensing which one has been released first. Supposedly this can be used to increment say a large number counter that counts from say zero to over 65,000 but it can really go up to whatever you want it to go up to such as type long long or even single digits grouped any way you wish.
So the typical use is to set a setting for another device, such as a frequency generator. For example, say you want to set it to 1Hz, then you turn the encoder one click clockwise.
Then for 2Hz, another click to the right.
Now say you really wanted 32Hz. After you do the above, you push the button in and the 'counter' display moves to the next digit to the left (the 10's digit), and then you turn the encoder one more click and it goes up to 12, then if another click clockwise it goes to 22, then 32, etc.
Now say you want 432Hz, you push again then turn the rotory encoder four clicks clockwise, and the counter display goes to 432. Seems simple enough.
However, sometimes the rotory encoder does not respond as well as we would like, so it misses some counts. It may take 7 clicks clockwise to get to 4 instead of just 4.
The library i am using is simple enough, and it detects all possible state transitions and increments or decrements the counter as it should. It just doesnt seem fast enough even though it uses two interrupts.
It may be that the I2C display routine does not like to be interrupted. If i allow it to be interrupted it gets lost and does not display anymore, just the numbers that had shown up before turning the encoder. If i disable interrupts when displaying a number, then the display works fine but the encoder does not catch all the turns because it is not allowed to interrupt the display routine.
I can probably use a 4 bit parallel display instead, but i would like it to work with the I2C display too.
Any ideas, or how you do it in your code?
Maybe it would be better to modify the library, but it still wont like being interrupted while it is sending bits to the display.
When i uses three switches: one for up, one for down, and one for digit select, it works perfectly because the switches are polled, not using interrupts.