Close

Adding inputs: Bonus round!

A project log for Pro Trinket USB Keyboard

A USB keyboard for custom shortcuts based on the Pro Trinket and Pro Micro

stefan-lochbrunnerStefan Lochbrunner 12/16/2014 at 19:420 Comments

When I was talking about polling the keypad and rotary encoders in the last log, I felt like it might not become very clear for someone who is new to this. So I wanted to go into a little more detail and illustrate the issue a little better. To do this I probed the A and B outputs of an encoder while the Pro Trinket enables the input, revealing what the polling looks like:

(I know this is a pretty poor graph but it's the best my scope would do)

I intentionally offset channel 1 (green) and 2 (red) such that it would be easier to see the traces rising. Please ignore the beginning of channel 2, which should have started out in a low state. Yes, in the device the A and B signals are active low but for this example I wanted a high level to indicate the polling so I inverted the signals.

When the rotary encoder isn't actuated, both outputs/channels are in a low state... well, not in this image but let's just say they are ;) ... and when it is rotated the signals follow the outline indicated by the solid fill. Now we can finally get to the point: As mentioned before, the encoders aren't enabled the whole time but only momentarily to check the current state and this is what is indicated by the peaks (obviously when one encoder is disabled one of the other 3 is enabled). This test was to show that the rotary encoders are indeed sampled frequently enough to make a reliable decision about the direction.

It actually was quite difficult to produce such a short event, therefore I'm pretty confident that the encoders will work reliably.

Is this actually helpful or should I just stop complicating things ;)

Discussions