LED matrix

Post your NXJ projects, project ideas, etc here!

Moderators: 99jonathan, roger, imaqine

LED matrix

Postby entozoon » Mon Aug 29, 2011 3:42 pm

I was wondering if there's any way I could use the NXT to control an LED array?
If not I guess I'll have to buy an arduino, but it would be awesome if the NXT could do it.. display patterns and such.
Any ideas?
User avatar
entozoon
New User
 
Posts: 14
Joined: Wed May 04, 2011 12:05 am

Re: LED matrix

Postby s.frings » Thu Sep 01, 2011 11:07 am

Sure you can. Connect some PCF8574 chips to a sensor port, and you will get lots of free programmable I/O ports. Youe only need some transistors and resistors to attach an LED matrix as usual.
s.frings
Active User
 
Posts: 131
Joined: Tue Jul 20, 2010 2:01 pm

Re: LED matrix

Postby entozoon » Thu Sep 01, 2011 12:22 pm

That's a great idea!
although when you say connect it to an array 'as usual', i've never done this sort of thing before.. I'm a perpetual noob, but I'll give it a go.
If each chip can have 8 outputs, does that mean it could only control 8 LEDs or is there a way of using those to control a larger array?

Then again if I use all four sensor ports, that'd give me 32 I/Os .. which is still a small 5x5 array, and it'd have to be monochrome too
User avatar
entozoon
New User
 
Posts: 14
Joined: Wed May 04, 2011 12:05 am

Re: LED matrix

Postby skoehler » Thu Sep 01, 2011 1:34 pm

entozoon wrote:That's a great idea!
although when you say connect it to an array 'as usual', i've never done this sort of thing before.. I'm a perpetual noob, but I'll give it a go.
If each chip can have 8 outputs, does that mean it could only control 8 LEDs or is there a way of using those to control a larger array?


I2C is a bus. It should be possible to connect many of those chips to one I2C bus (= to one sensor port).
skoehler
leJOS Team Member
 
Posts: 1422
Joined: Thu Oct 30, 2008 4:54 pm

Re: LED matrix

Postby gloomyandy » Thu Sep 01, 2011 2:16 pm

or you may want to look into using them in an nxm matrix with multiplexing...
http://www.best-microcontroller-project ... splay.html
Though you may find that the update rate is not fast enough...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4081
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: LED matrix

Postby entozoon » Thu Sep 01, 2011 4:50 pm

Hmm.. cheers guys,
I guess i'll buy one of these http://www.mindsensors.com/index.php?mo ... PAGE_id=71

and an array and see how it goes from there..
User avatar
entozoon
New User
 
Posts: 14
Joined: Wed May 04, 2011 12:05 am

Re: LED matrix

Postby s.frings » Thu Sep 01, 2011 6:18 pm

I would not use that prototyping board, because it's quite expensive and you still would need to add more additional parts than the board has space for. If you buy the few parts that are in the set, it would cost about 1/4 of the set price. There is only one Problem: It's really difficult to find a show for the cable connectors. Easiest solution: Buy a set of replacement cables from Lego's online shop and cut one of them in half which you can directly solder ti the pins of the I2C chip.

You can connect up to 8 chips of PCF8574 to a single I2C connector. Be sure to use 82k-Ohm pull-up resistors as stated in Legos hardware development manual. Most other I2C instuctions recommend 4,7-10k Ohm which would not function with the NXT computer.

There is also the A version of that chip available, allowing you to attach additional 8 chips to the same I2C bus. Thus giving you the possibility to have up to 128 I/O lines.

An Led Matrix of 64 linex and 64 rows would have 4096 LED's. Is that enough? :-)

You should read an instruction how to build such cirquits (http://www.piclist.com/images/www/hobby ... c6_a44.htm). Be aware that you need transistors or high current driver chips. I would use BC337 for up to 500mA or Power-MOS-Fet's for higher currents.

If you have a matrix of 8x8 LED's, each LED will be powerded only for 1/8 of the time. If you use regular LED's that are designed for 20mA, you would need to drive them with 8x20mA = 160mA to get full brightness. The NXT computer provides a max. of 180mA for all 7 ports in sum.

Be aware that LED matrixes usually emit a lot of electromagnetic waves even when operated with low frequence (e.g. 400Hz) because of the rectangular waveform and high currents. You should keep the wires as short as possible and use a filter in the power supply lines. Check with an AM radio, to be sure not to disturb devices outside your home.

Think about using an LCD display with LED backlight. They need much less power and are much less problematic regarding the electromagnetic waves. There are devices with I2C bus available that can be connected directly to the NXT.

For example this one: http://www.lcd-module.de/pdf/doma/t123-i2c.pdf
Last edited by s.frings on Thu Sep 01, 2011 6:42 pm, edited 1 time in total.
s.frings
Active User
 
Posts: 131
Joined: Tue Jul 20, 2010 2:01 pm

Re: LED matrix

Postby entozoon » Thu Sep 01, 2011 6:28 pm

Wow, 64x64 would be more than enough lol, I was thinking more like 16x16.
Thank you for the reply, I think I could quite confidently build a PCF8574 circuit that controlled 8 LEDs.. But going from that to controlling a big array, that's the hard part. I suppose I could have a bunch of PCF8574A chips like you were saying.. although I've got to do this project as cheaply as I possibly can
User avatar
entozoon
New User
 
Posts: 14
Joined: Wed May 04, 2011 12:05 am

Re: LED matrix

Postby burti » Thu Sep 01, 2011 6:46 pm

How about this?
http://www.hitechnic.com/cgi-bin/commerce.cgi?preadd=action&key=NPS1055
That would be the easiest way to switch on/off at most 6 LEDs.
You need only some small I2C-commands. That's all. No hardware issues at all.

I have tried it out and it works well.
Last edited by burti on Thu Sep 01, 2011 6:50 pm, edited 1 time in total.
burti
Novice
 
Posts: 61
Joined: Thu Jun 25, 2009 11:41 pm

Re: LED matrix

Postby s.frings » Thu Sep 01, 2011 6:49 pm

That board is also much too expensive. You can simply solder such a board by yourself for less than 1/4 of the price.

Just checkout the datasheet of the PCF8574 chip. I also did it myself: http://stefanfrings.de/mindstorms/index.html
(scroll down). My experimental board provides 8 digital I/O plus 4 analog inputs and one analog output.And it costs only 10 Euro. As you can see, I only use two PCF chips, two resistors, one capaciator and optionally a power LED with resistor.

I just inserted a link to a description of how to build such matrix cirquits to my article above.

I case of that document, they use a microcontroller that can drive some few milliampere for high and low level.

If you use the PCF8574, note that this chip can drive higher current for low level but only a very small current on high level (see datasheet of the PCF8574). That means, you better use the low level to switch a line "on" instead of high, which means you would need the complementary types (NPN/PNP) of transistors.
Last edited by s.frings on Mon Sep 05, 2011 1:13 pm, edited 1 time in total.
s.frings
Active User
 
Posts: 131
Joined: Tue Jul 20, 2010 2:01 pm

Re: LED matrix

Postby s.frings » Thu Sep 01, 2011 7:22 pm

16x16 is a size that should be no problem for manual work. You would need four PC8574 chips, and a handfull of transistors. Lets assume you organize your matrix to 16 colums of 16 rows, where one counter switches to the next column every millisecond.

So in the first step, the first colum gets operated, then the second column, then the third column and so on.

Since each column gets power of 1/16 time, you would need to drive each LED with 16x20mA=320mA. Each colum can have up to 16 LED's that are powered on simultaneously, so the column driver transistor must be capable of driving up to 16x320mA=5.1 Ampere ! Also the power supply must be capable to drive that current. I would use a switching power supply of 3.3V 6A, or a set 3 batteries providing 4.5 Volts. Batteries of size AA (LR6) are to small, they cannot drive such high currents efficiently. Better use the bigger sizes.

There is one big problem:
Lets assume you stop the Java program or it stop because of any error. Then the timer that switches the column will also stop. In this case, a single column will be powered all the time instead of 1/16 time. That causes 16x of the nominal current to the Led's of that column. They will surely burn within a few seconds.

So you need a fuse in easiest case in series to each column transistor, that breaks the current for that case. Im sure that these fuses will burn quite often during software development.

Another option could be, to simply reduce the current to whatever the maximum of the LED's is. For example 16x2mA per LED instead of 16x20mA. This will reduce brightness but allows you to use much smaller transistors, power supply and they will not burn when the program stops.

My recommendation: Dont solder such thing yourself. Better use an LED illuminted LCD display with an I2C controller.

For learning the basics, a single PCF8574 with only 4x4 Leds and low current (4x5mA) should be enough. The much lower current makes things much easier. Larger Matrix displays work of the same principle but introduce some difficulties because of the high currents.

What also could be interesting are fluorescent tube displays. Many home entertainment devices (e.g. radio tuners, video tape recorders, microwave ovens) use such displays. They consume much less power than LED matrixes, however the electronic part is a little more complex because of the required voltages. Search for "VFD Display".

Example with integrated I2C controller:
http://parts.digikey.com/1/parts/678572 ... 62-12.html
http://www.bipom.com/lcds/manuals/VK162-12.pdf
s.frings
Active User
 
Posts: 131
Joined: Tue Jul 20, 2010 2:01 pm

Re: LED matrix

Postby entozoon » Thu Sep 01, 2011 8:00 pm

That's all very fascinating, thank you for everyones' replies.

It's blowing my mind at the minute, I hadn't considered the power problems with using large arrays of LEDs.. fuses and such.
Perhaps you're right and I ought to look into LCD screens, although they don't have quite the same magic of the potential to generate nice bright LED patterns.
User avatar
entozoon
New User
 
Posts: 14
Joined: Wed May 04, 2011 12:05 am

Re: LED matrix

Postby s.frings » Fri Sep 02, 2011 6:46 am

But Vacuum Fluorescent displays look very fine and provide good brightness for any viewing angle. Ok, its difficult to build the required controller yourself, but it's easy to use industrial modules with embedded controller and serial (maybe I2C) interface.

Since the project idea interest me, I found some time tonight to think/dream about it :-)

It might be a good idea to implement an electronic overcurrent protection using a counter and a timer. This is near to the solution that I found many years ago as I built an 8x8 matrix display with character generator using an Eprom and a counter. However lets get back to your project...

Did you notice that you can buy LED matrixes of 7x5 size? They are commonly used in elevators and in trains. If you connext a display with 7 rows to an 8 bit I/O chip, you have one bit left. What can we do with that one bit?

Think about a column counter with decimal output (such as CD4017, also called Johnson counter). You could use the free I/O line to clock that counter. Using two 7x5 LED matrixes, one PCF8574 and one CD4017, you can build a 7x10 matrix. You would use 7 of the 8 I/O lines to power the LED rows (through transistors, because of the high current), and use the free 8th line to clock the counter. Whenever the clock line pulses, the counter switches over to the next column. This principle is used there: http://www.best-microcontroller-project ... splay.html

You need a reset signal, to synchronize the hardware column counter with the NXT software since you would have a variable that must contain the current column number. When using a single PCF8574, there is no line free to connect to the reset input of the counter. But also remember there was a situation that we need to avoid: The counter must not stop for a longer time (>10ms) otherwise the LED's would burn.

Build a timer cirquit that detects when the timer clock fails (when the pulse is missing for more than 10ms). That timer can be used to reset the counter and it can also be used to switch of power to the whole LED matrix. When the NXT computer starts pulsing the clock line, the timer switches power on and resets the counter. Then the counter starts counting the columns starting with the first column.

I assume that you can use a 6x schmitt trigger chip such as CD40106 and some R/C combinations to build the required timer.

So you may use two 7x5 LED matrixes to get a 7x10 display, one PCF8574 (I2C I/O), one CD4017 (Johnson counter), one CD40106 (6x Schmitt Trigger) and a handfull of transistors, resistors and capaciators. If you need a larger display, then simply multiply the whole circuit, e.g. double it to build a 14x10 Matrix.

By the way, instead of using lots of transistors, you can also use driver chips of the ULN series. For example an ULN2804.

How does that sound?
s.frings
Active User
 
Posts: 131
Joined: Tue Jul 20, 2010 2:01 pm


Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 1 guest

cron
more stuff