[sdiy] mcu project with too few I/O lines :(

Rainer Buchty buchty at cs.tum.edu
Fri May 23 21:32:11 CEST 2003


> I thought about using a key encoder and maybe an LED driver but
> those ICs are pretty expensive (7$ for a key encoder, that's more
> than a microcontroller!). does anyone have some advice here and
> how to interface this stuff without buying tons of additional ICs
> which cost a lot of $$$?

You didn't mention what lines exactly your LCD needs, so I assume we have
a more or less common interface consisting of the data bus (the given 8
bit), a command/data line, a read/write line and a select line.

As for the 16 LEDs, you probably want to have some LED drivers. One
74245 per 8 LEDs should do the job as the data sheet claims Iol to be
24mA, so attach them with the cathode facing the 74245 output which means
that pulling the corresponding data line low will lit the LED. Don't
forget to add pull-up resistors at the 74245 outputs, as you want to
control which block of LEDs should be accessed:

Since you already have the c/d and r/w lines from the LCD interface, you
OR each of them with an additional LED select line; these two ORed signals
you feed to the respective 74245's enable input.

Price for the LEDs: 1 additional select line, 2 74245 and 16 Rs (two 8-1
arrays)

The 16 keys (actually even 18) can be done with just 4 I/O pins, 4
resistors and 12 diodes: Take the 4 I/O lines and apply pulldown Rs. Keys
can be placed between 1/2, 1/3, 1/4, 2/3, 2/4 and 3/4 which can be further
coded using diodes which are: no diode, A/K or K/A direction. Parsing is
done by applying high level to one I/O line and check what's coming back.
Do this for both diode directions (A/K and K/A). If the return bit is set
for both directions you have the no-diode case. However, if you want to
parse multiple button presses, then this scheme won't work for you.

Price for 18 keys: 4 lines, 4 resistors (one 4-1 array), 12 diodes, ~60
assembler commands (8051)

Alternatively, if you have as spare ADC input, you can also code the 16
keys using a voltage divider, then you just need 15 Rs.

Makes in total 8+2+1+1+4(1)=16(13) lines, a bunch of diodes and resistors
plus two 74245.

HTH,
	Rainer



More information about the Synth-diy mailing list