Go Down

Topic: Rotary encoders and shift registers? (Read 5315 times) previous topic - next topic

FreebirdRising

Mar 10, 2012, 03:40 am Last Edit: Mar 10, 2012, 04:24 am by FreebirdRising Reason: 1
Hi! I'm still very new to all of this and diving in to learning about electronics with a custom midi controller project, so please bear with me. :)

I'm looking to put 8 rotary encoders on a Teensy++ without using the two I2C pins (so I have 6 interrupt pins to work with). I'm a little unclear as to how this will work with shift registers... Will I need two shift registers and wire one pin to the first shift register and the other pin to the 2nd shift register, or would I wire 4 to one and 4 to the other?

Edit: Or can I make some sort of matrix and do it all with one shift register?

Thanks! :)

Grumpy_Mike

Reading rotary encoders through shift registers is not a good idea.
It is not clear how you are proposing to use them.

FreebirdRising

Quote
It is not clear how you are proposing to use them.


They are part of an HID design - controlling music software.

One person I've been conversing with suggested that I may be able to use all of the PORTB pins on the Teensy++ as interrupts as well, but we're not 100% sure about that. Do you know?

Though, I wanted to avoid using pin 0 & 1 because of the potential for linking units...

Quote
Reading rotary encoders through shift registers is not a good idea.


I've read things along these lines a few times, but I haven't found anything explaining why. Would you mind explaining (or pointing me to an explanation?)

Grumpy_Mike

Quote
but I haven't found anything explaining why

Because the outputs from a shaft encoder change rapidly and so you need to continually read in the shift register in case you miss a change. Even then you will probably miss a change if your sketch has something else to do.
A safer way is to use a port expander like a 23S17 or a 23016, these are very much like a shift register but with extra circuitry. These have a single output that can signal if a change has occurred in any of the up to 16 inputs. Then when you know a change has happened you can then spend the time to read in the levels and work out what has changed.

Quote
I may be able to use all of the PORTB pins on the Teensy++ as interrupts as well,

Yes on all AVR processors there is a "pin change interrupt mode", where by an interrupt is generated when ever any pin changes state.
An example of using this is in this project I did.
http://www.thebox.myzen.co.uk/Hardware/Crazy_People.html

FreebirdRising

#4
Mar 12, 2012, 04:19 pm Last Edit: Mar 12, 2012, 04:21 pm by FreebirdRising Reason: 1
Another person I was talking with described why the only way shift registers would work is if I was using absolute encoders... Unfortunately I already have a handfull of incremental types that were gifted to me for the project. :\

Will a port expander work with incremental encoders?

Grumpy_Mike

Quote
Will a port expander work with incremental encoders?

Yes that is why I told you about it.

Quote
if I was using absolute encoders

Have you seen the price of these!!!!
http://uk.farnell.com/pepperl-fuchs/fvs58-011k2ragb-0013/encoder-absolute/dp/3778022

FreebirdRising

They're not *all* that expensive: http://www.mouser.com/ProductDetail/ALPS/EC18AGB20401/?qs=sGAEpiMZZMvS%2fYaWaOF37xnRn301lCUI

Anyway, thanks for letting me know about port expanders - I'll end up using that since it goes with what I already have. :)

Grumpy_Mike

Yes but that is only a low resolution mechanical switch one. Good for some things but not for others. For example I would not put it on the end of a motor, for that you need optical encoders not mechanical ones. With only 16 steps per revolution you are limited to simple front panel controls , which might be what you wanted but you didn't say.

FreebirdRising

Ah - yes, a MIDI controller is an HID.  It's for controlling music software, so a high resolution isn't necessary.  Either way, I already have the EN11-HSM's so I'll just stick with that and the port expander suggestion.

Go Up