Multiplexing 6 rotary hex encoders
Ltech
Posts: 380
Question
I need 6 hex rotary dip encoders as input on a propeller.
How can I get this working and save pins.
Firs I think easy, I put all the outputs in parallel as 4 inputs on the prop with pull down resistor.
Next I put the input of each switch from 1 to 6 high after each other, and read each time the inputs. Wrong
I try with diode in the input line, but still influences between switches
My trouble is when I use more as one switch.
It is not software, but hardware .
[C0DE]
Pub TallyDec
outa[RotTally..RotID] := 0 ' ALL LOW
outa[RotTally] := 1 ' Mesure High
case INA[Hex4..Hex1] ' READ 4 BITS
1..8 : Tally := INA[Hex4..Hex1] ' READ 4 BITS
other : ValidHex := -1
outa[RotTally] := 0 ' Mesure Low
Pub GpoDec
outa[RotTally..RotID] := 0 ' ALL LOW
outa[RotGpo] := 1 ' Mesure High
case INA[Hex4..Hex1] ' READ 4 BITS
1..8 : Gpio := INA[Hex4..Hex1] ' READ 4 BITS
other :ValidHex := -1
outa[RotGpo] := 0 ' Mesure Low
[/C0DE]
I need 6 hex rotary dip encoders as input on a propeller.
How can I get this working and save pins.
Firs I think easy, I put all the outputs in parallel as 4 inputs on the prop with pull down resistor.
Next I put the input of each switch from 1 to 6 high after each other, and read each time the inputs. Wrong
I try with diode in the input line, but still influences between switches
My trouble is when I use more as one switch.
It is not software, but hardware .
[C0DE]
Pub TallyDec
outa[RotTally..RotID] := 0 ' ALL LOW
outa[RotTally] := 1 ' Mesure High
case INA[Hex4..Hex1] ' READ 4 BITS
1..8 : Tally := INA[Hex4..Hex1] ' READ 4 BITS
other : ValidHex := -1
outa[RotTally] := 0 ' Mesure Low
Pub GpoDec
outa[RotTally..RotID] := 0 ' ALL LOW
outa[RotGpo] := 1 ' Mesure High
case INA[Hex4..Hex1] ' READ 4 BITS
1..8 : Gpio := INA[Hex4..Hex1] ' READ 4 BITS
other :ValidHex := -1
outa[RotGpo] := 0 ' Mesure Low
[/C0DE]
Comments
You could, possibly, get tricky by reading them as analog. Put unique resistors on all but one knob. Say, 220 ohm, 330 ohm, 1K. Since the voltage read from a pin will be unique for each combination of resistance, you should be able to work out which switches are active.
But I dream somboddy get a trick for this.
wat's go missed upstairs ?
However, as Jason Dorie said, the simplest and easiest thing to do would would probably be to use an I/O expander.
Sorry, that should have been '165 shift registers.
2 x 4051 HW mux will drop 12 pins to 5, and can scan 16 contacts.
You could use a HEF4894 or NPIC6C4894 (12 op shift register) to lower pin count further, but an irony there is a small MCU is today cheaper and smaller than a 12b shift register.
My post above assumed 6 rotary encoders, but I see you meant 4 bit Hex Switches.
The problem is the same, you can use diodes on every output, (24 diodes) and open drain the common pin.
With 6 x 4 bit Hex Switches you need 6+4 = 10 pins
Or, 3 x 4051 can do this in 6 pins. (no diodes)
Thank you for looking.
@ jmg I only draw 4 of the 6 Hex encoders.
My first draw was with lcd, menu and rotary encoder.
But the users do not want to change from the ugly old way design they use now ....
I have to push my design I guess.
You're probably better off using shift registers, though. It will be a lot less soldering, and there's probably already Spin code to read any of the shift register chips that have been listed here so far.
I think you need the one on the front to get a "try-state" pin
Propeller pin is high, or low
So if you are not reading the encoder it has to be low.
The other encoders are connected trough ground, trough the first selected output values
My last draw works, I build it and test ok
So need 4 input pins, and 6 output pins, go high when read appropriate encoder
Here's a schematic for a 3x3 scanner that I found via Google. Note that there are only diodes on one side of each switch, not both (The box on the left is the microcontroller):
But why are you so insistent on using matrix scanning? Shift registers would be so much easier.
@Ltech
Electrodude is right on both counts. You do not need the diodes to the left of the encoders in your diagram, and using three '165 parallel to serial shift registers is easier than 24 diodes. It also needs only three pins to read the data in.
OTOH if you have the diodes, six output pins, and four input pins available you can do it that way.
I understand the parallel to serial, but it is for a proof of concept now on a breadboard.
For the final I want to put a small lcd and a rotary push encoder + menu system or micro sd setup card read on boot-up.
Strange nobody think about build a rotary hex encoder with build in diode ?
A rotary hex encoder company makes switches, and the tracks take most of the space, adding diodes to a stamped lead frame is not easy, and adding a PCB would move outside standard footprints, and the market for these is already small & shrinking.
ie not really a surprise.
The rotary encoder can be done with diodes or shift registers. A lot of the older equipment I worked on used rotary encoders with diodes on the encoder board, and they worked well. Shift registers became more popular on later microcontroller based systems because they needed fewer I/O pins and it was easier to place one IC than 8 diodes on a board.