Shift Register / Encoder

Hi there, I bought an 8x8 LED matrix. The tutorial says to wire up each used pin of the led matrix to an individual out on the arduino. To me this seems a little basic (which I'm sure is the point of the tutorial), but I think I'd rather like to try an encoder. The problem is, I'm sure my terminology is wrong!

The forums say to use shift registers. I googled them but was having trouble understanding what they do. To me, it sounds like they are flip flops whose state gets pushed over one spot every time you add a "bit"; just like a shift register in C or assembly (MIPS).

but what I need is an encoder. a binary encoder? something that will convert my binary input to a bigger output.

are these the same thing? if not, what is the encoder called?

please and thank you, marco.

You were right the first time... google 74hc595 for starters and take a look here: http://www.arduino.cc/en/Tutorial/ShiftOut

hmm. this sounds great actually.

however its a little different from the encoder that id like to see. is there an IC that will decode inputs from binary to the expanded form (eg. 3 pins needed to control 8 values, 4 for 16).

this would be much simpler if such a thing existed. i know you can program this stuff into ROMs and PLOs (i think) but there must be a pre made decoder/encoder that will do this. any ideas?

Well to decode 3 bit binary input into 1 of 8 active low outputs one can use a 74hc138 ( http://www.nxp.com/documents/data_sheet/74HC_HCT138.pdf )

for a 4 bit to 16 bit decoder a 74hc154 would work ( http://www.nxp.com/documents/data_sheet/74HC_HCT154.pdf )

Lefty

I think what you might want is actually called an I/O expander. The PCF8574 is the oldest I2C device of this kind still readily available. Other devices similar to it are like the mcp23016.

You would use the "WIRE" library to talk to these devices.

http://www.nxp.com/documents/data_sheet/PCF8574.pdf

http://ww1.microchip.com/downloads/en/DeviceDoc/20090C.pdf

You would have full control over many outputs (or inputs) and never use more than a few pins.

this is much closer to what im looking for. but its got so many things inside. when we studied PLA's and ROMS it seemed that they were simply made of many AND's and NOT's to encode and decode input. maybe these gadgets are a more efficient solution. thanks all!

oops. retro lefty linked me to what i was thinking of. i saw the data sheet but i was looking at a few and must have missed it.

looks good! i wonder what a 5 input one looks like!

so are these decoders? or de multiplexers?

so are these decoders? or de multiplexers?

Well according to the datasheet for the 74HC138, they are "3-to-8 line decoder/demultiplexer; inverting"...in other words, this particular part can be used either need. There is also a complement part that does the 8-to-3 line encoding/multplexing (don't remember the part number off-hand, but it would be easy to find)...

:)

There is also a complement part that does the 8-to-3 line encoding/multplexing

Called a Priority Encoder, takes 3 bits in and outputs a zero on the line number represented by the value on the inputs. You can also do the same things with a data select if you ground the input.

74147: 10-Line to 4-Line Priority Encoder

74148: 8-Line to 3-Line Priority Encoder

74150: 16-Line to 1-Line Data Selector/Multiplexer

74151: 8-Line to 1-Line Data Selector/Multiplexer

74152: 8-Line to 1-Line Data Selector/Multiplexer

74153: Dual 4-Line to 1-Line Data Selector/Multiplexer

74154: 4-Line to 16-Line Decoder/Demultiplexer

74155: Dual 2-Line to 4-Line Decoder/Demultiplexer

74156: Dual 2-Line to 4-Line Decoder/Demultiplexer with open collector outputs

74157: Quad 2-Line to 1-Line Data Selector/Multiplexer, Noninverting

74158: Quad 2-Line to 1-Line Data Selector/Multiplexer, Inverting

74159: 4-Line to 16-Line Decoder/Demultiplexer with open collector outputs

looks good! i wonder what a 5 input one looks like!

They don't make one a 4 input one is big enough. You can cascade them so you can make what ever size you want.

74147: 10-Line to 4-Line Priority Encoder

74148: 8-Line to 3-Line Priority Encoder

Two of my favorite TTL chips.

oh dear. i am sorry. i just realized that i need a shift register and not a decoder.

a decoder would be a good way to reduce many pins to few, but i would only be able to control one of the output pins at a time. so this would be great if i wanted to light up one led at a time in the matrix. but if i ever wanted to light up multiple ones, im gonna need a shift register. and i just realized why.

learning thank you all

eventually lighting up multiple leds even with latches becomes cumbersome, you loose a little brightness but you can flicker each led one at a time, and fairly slow (in cpu time) so the eye picks it up as a solid image

i just realized that i need a shift register and not a decoder

Well you can add a latch onto a multiplexer to give you a steady output. The 74LS259 is one such 8 bit addressable latch. I use it in this project:- http://www.thebox.myzen.co.uk/Hardware/Transistor_Tester.html To generate 16 outputs. The advantage over a shift register is that you just have to update the bit you want to change and it is much faster changing a bit than outputting all 16 bits or so with a shift register.

a decoder would be a good way to reduce many pins to few, but i would only be able to control one of the output pins at a time. so this would be great if i wanted to light up one led at a time in the matrix.

Yes. Or in the case of a matrix display, also useful for selecting one row at a time.

but if i ever wanted to light up multiple ones, im gonna need a shift register.

You can also combine using a shiftregister and a decoder with a matrix display. Using a shiftregister for column data and a 3-to-8 line decoder for (de?)multiplexing the rows, for example. To further reduce pins needed, the decoder can be connected to a counter (but then some synchronizing measures should be taken, like resetting the counter each frame or similar).

You should have some form of driver, especially for the rows as these may source/sink the currents for one hole row (all columns, if row multiplexing is used) at once.

Another alternative to the 74HC138 is the 74HC238 (outputs inverted).

Btw, what is really correct to say: row multiplexing, or row demultiplexing? I think the last but everyone (me included) seems to say row multiplexing.

You can also combine using a shiftregister and a decoder with a matrix display.

As used on this project:- http://www.thebox.myzen.co.uk/Hardware/Econo_Monome.html

Very nice build! Also a really nice video of it! (The music was...interesting :P )

I have a similar method used here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1256090448. Old code though, that is (finally) better now. Also this is not a finished project, it was just a test for another project not using any 8x8 matrices at all.

In fact I took this up again yesterday with the intent to finally make it a more permanent system (boxing it eventually), and also improve on it slightly. I don't have common cathode matrices anymore, so I modified it for common anode matrices, and swapped the 74HC138 for a 74HC238, among other things. Also having 16 buttons via 74HC165 PISOs. Basically I just want to make a dual 8x8 matrix display thing to play with programming it mainly.