Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

74hc126 (12 pins to 8 pin connector)

Status
Not open for further replies.
I have built LED matrix display (12x8), and I want to control it with microcontroler at89c51ed2. It has 4 ports with 8 pins each. Problem is that if i want to put them together normally, i would put all rows in port 1, and first 8 columns in port 2, and other 4 in port 3.

I heard of chip 74hc126 that with it, i could put all 12 pins in one port (8pins)

I really dont understand how, so can someone tell me how can i do it, and maybe if someone knows, how can i do "shift bit" function in C easily..
 
I have no idea how you could do it with a 74hc126, but you could use a couple of 74hc138s to make a 4 to 16 decoder. Use 12 of those outputs to select one column at a time.

So you can drive your 12x8 matrix with a total of 12 pins. 8 bits for the 8 rows, and 4 bits to select which column those 8 bits go to.
 
So i should put 8 bits for rows directly to connector, and 12 pins for columns through that chip and then to 4 pins of other port?

I think i understand :)

So i put 12 rows into 12 output pins of chip, and 4 input pins of chip i put to PORT 1. And in program C, when i type for example "PORT1=1" that would light first (or the last) row. So i would have to just type 0-12 and it would do what it is supposed to?

If so, that is really fantastic because i thought i would have to shift bit or sth else, and that is more complicated :)
 
If you're using the 74HC138, they can typically drive 25mA. That's ok for one LED, but if you're driving a column, that'll be a little larger. And if you're matrixing your display, you need to overdrive the LEDs for brightness. So you'll need some kind of buffer to drive both the row and the column into your LED matrix.

A 74HC237 gives a high output, the 74HC138 gives a low output. If you're driving your columns low, you might try a combination of the '237 feeding a ULQ2003.

these are examples I used for another post... The row drive would be the same, and he used a shift register for the column drivers. You would replace the shift register with the decoders. Also, his column input was the anode, and the row drive was the cathode. I guess I'm just assuming this is how your matrix is, but you really don't say....

View attachment 68729 View attachment 68727 View attachment 68728
 
Last edited:
View attachment 68733

I wrote the whole story and now it is gone :( so here we go again

I have made matrix 4x4 from this video, with 2n3904 transistors, 1k resistors, and 0-20K pot, and i tried it with 9V and it was good: https://www.youtube.com/watch?v=lZyc6ulpkyM
All bases are put to my 1 port through resistors 1K, so it is hard to program because i have to calculate what led i need and so on, and if i have while loop for all 16 leds, every led is on on its 1/16 brightness.

A 74HC154 i have found is 4-to-16 decoder, which i think would be the best for my 12 columns, because when i program for example LED=0 to 11, it would light exactly led i wanted, and on the rest 4 outputs i could put some switches
I thought i could but every base of columns to outputs, and inputs directly to one of my ports, but i think i am wrong?

One thing i really need is the leds to be at the same brightness, not at 1/96 of it if i have while loop, and for example if i have a loop with these 96 leds and i want all of them to seem ON, how fast should i switch it? I think 1ms woudl be slow
 
Last edited:
1ms on x 16 = 16msec which would yield a 62.5 Hz scan rate. TVs have a 50 or 60 Hz scan rate, so you'd be in that area. Unless you're going to latch the data to drive each LED individually, you have to suffer the loss off brightness due to scan .

The biggest concern would be off time vs on time. You need to write your routine so that when you turn the display off, update your data output and column drive, and then turn it back on, the off time is at a minimum, as the longer the LEDs are off, the dimmer they will be.
 
Yeah, i understand that, but for now forget about that 4x4 display
I am concerned about my 8x12 display. Can you send me schematic or just tell me how should i put some 4to16 decoder chip, and my transistor bases together? ( i mean should i just put them together or they need something between to make it brighter or watever).

Because with 96 LEDS (8x12), i have very dimm leds (on 1/96 their possible brightness), and with 1ms each led on, it is total of 90ms which is really slow refresh rate
 
no no no, with 8 x 12 matrix, you turn all 8 of your one port on, with whatever pattern for that column. Then you turn the column on. This means LEDs are on for 1/12 (or 1/16th) of the time, not 1/96th.

since your LEDs use a resistor on the top port, none is required on the bottom, you can just send them straight to ground. This is a little harder with a decoder that drives to ground, but all you need to do is add another transistor to invert the drive... for example....

View attachment 68735
 
no no no, with 8 x 12 matrix, you turn all 8 of your one port on, with whatever pattern for that column. Then you turn the column on. This means LEDs are on for 1/12 (or 1/16th) of the time, not 1/96th.

since your LEDs use a resistor on the top port, none is required on the bottom, you can just send them straight to ground. This is a little harder with a decoder that drives to ground, but all you need to do is add another transistor to invert the drive... for example....

View attachment 68735

Thank you very much for trying to help me, but i dont i dont understand it clearly

I will send you what i ment to do, and please tell me what is wrong with it?

I am not an expert in this, so that is why i am not sure. If it is ok to put it together like this in my picture, what will happen if i send for example 0001 in P1 and 0001 in P2, would it light just one led or the whole matrix and that led would be off? That is also thing i am concerned of, because i dont know if my schematics is right or wrong.
Also you have seen that i have already put ROW things like in the picture, and i did nothing yet with the columns

View attachment 68737
 
Last edited:
The scheme you show a 0001 0001 will only turn OFF one LED at a time. The output of the 74HC154 has an active LOW output.

I thought you had said you were going to drive the 8 on top individually with 8 bits, and decode the bottom 16 with 4 bits (see your post #4)?

Also, with an NPN on top, the base voltage has to get above the emitter voltage by .7V to turn it on. I guess that wouldn't be a problem with the way the LED is configured in the circuit, it's anode (+ pin) will be about 1.4V when on. You might be better off using a pair of '237 with outputs active HI. Drive the top row directly from the 8 bit port, so you can individually turn LEDs on and off. And then decode the bottom column drives with 4 bits. Otherwise, you only turn on one LED at a time, and your LED scan rate will be 1/96th.

Also note that the 74HC154 is only good from 3V-6V...
 
Yep, you are right about the rows, i will not use demultiplexer there.
So you told me to replace 4-to-16 decomplexer with 2x 3-to-8? Why?
Also, you are right about voltage, i will use 5V limiter, and replace 20k pot with 2k pot so i could put that 5V to leds to. Or maybe one 7805 and one 7809?

With a schematic on picture, i have made exactly the same display except this decoders. So i have 4x4 display, and when i put 0 to one pin there is nothing, and 1 is ON.
So with this chip 4to16 or 2x 3to8 it will also turn on only one led or not? And also, it wont be too hard to program 2x 3to8? 4to16 would be much easyer in my opinion :/

The scheme you show a 0001 0001 will only turn OFF one LED at a time. The output of the 74HC154 has an active LOW output.

I thought you had said you were going to drive the 8 on top individually with 8 bits, and decode the bottom 16 with 4 bits (see your post #4)?

Also, with an NPN on top, the base voltage has to get above the emitter voltage by .7V to turn it on. I guess that wouldn't be a problem with the way the LED is configured in the circuit, it's anode (+ pin) will be about 1.4V when on. You might be better off using a pair of '237 with outputs active HI. Drive the top row directly from the 8 bit port, so you can individually turn LEDs on and off. And then decode the bottom column drives with 4 bits. Otherwise, you only turn on one LED at a time, and your LED scan rate will be 1/96th.

Also note that the 74HC154 is only good from 3V-6V...
 
As has been mentioned, the selected output of the HC138, and HC154 are LOW. Use these outputs to drive the base of 12 PNP transistors, whose emitters are tied to +5V. The collectors feed the anodes of the 8 LEDs in each column through 12 current limiting resistors.

The cathodes of the 12 LEDs in each row connect to the collector of 8 NPN transistors. The base pins of these resistors are driven by an 8 bit port of your uC.

Of course, you need a current limiting resistor between all IC outputs and the base pin of all of the transistors. About 1K should work for all 20 places.

Each LED will be driven 1/12th of the time. It is typical to increase the LED current to compensate for the short on time.

In your code, you want to make the moments of changing the 8 bit 'row'port and the 4 bit 'column' values right next to each other to reduce ghosting in adjacent LEDs.
 
programing a 4 to 16 or 2x8's is the same, you apply a 4 bit address to them and they decode to 1 of 16 positions. It's the hardware hookup that's different. The most significant bit will go to a (-) enable on the lower decoder, enabling it when the most significant bit is low. It is routed to a (+) enable on the upper decoder to enable that one when the bit is high. The lower three address bits go to the decoder address inputs, the same place on both decoders.

I want you to switch from a '154 (4 to 16) to a pair of '237s (2x 3 to 8) because their output is active high and will turn on an NPN transistor when the proper address is decoded. Otherwise, with the '154, output is active low, and you'd need to turn on a pair of transistors, the first one inverts and the second one drives the LED. See my examples in post #10.
 
I just looked at the data sheet for the 74hc237... I don't remember there being a latch enable...

the parts you want are the 74HC238
 
Ok, now i understand better. But there is not 4-to-12 decoder that has output high for on? If i find it, can i use it insted of 237s?

EDIT: maybe this one? HCT4514
 
Last edited:
OK, i have finished my project, but it is only half working
First of all, in the end i bought CD4514BE chip because they didnt have the other one. It is 4-16 decoder with output high for ON.

Problem is that if i put for ROW=255 (that should turn all rows on - 11111111), and COL in for loop
(here it is: for (i=0; i<12; i++) {ROW=248; COL=i; Delay(100); })
that works well, but third row is not on, just first LED in that row is On when it comes to it

Now the second, bigger problem: you told me to turn col by col, 12 times for whole display, so if i dont want all rows to be on in some col (ROW=248 (11111000)), and for example do the same for loop, it does something wierd, it turn some of leds very bright, some of them so dimm that you cant even see it is on..

Do you know what could be a problem?

EDIT: I fixed third row. But the problem with wierd not-turning-on-leds remains . {ROW=15; COL=i; Delay(18); }: ROW=15 is 00001111. And it acts like it is 00001011. I dont understand
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top