Upload
mauro-h-s-wencelewski
View
75
Download
0
Embed Size (px)
Citation preview
(http://fabienroyer.files.wordpress.com/2011/03/imag0063.jpg)
LED Matrix Glow
Fabien's Bit Bucket
Voiding warranties since 1980
TAGS
C#, driver, logic-level shifter, MAX7219, MAX7221, netduino, SPI
Using a MAX7219/MAX7221 LED display driver
with a netduino
March 13, 2011
In a
previous
post, I
described
how to
drive an
LED
matrix
relying
on
persistence of vision (http://fabienroyer.wordpress.com/2010/12/03/driving-an-8x8-led-matrix-with-a-
netduino-using-persistence-of-vision/). While beautifully minimalist, this method has drawbacks: it
requires 11 digital pins on the netduino and takes constant CPU cycles to refresh the matrix. This can
potentially put tough resource constraints on the rest of the application.
This is where a chip like the MAX7219/MAX7221 LED display driver (http://datasheets.maxim-ic.com
/en/ds/MAX7219-MAX7221.pdf) comes in handy: all you need to do is to send it the data that you want
to display over SPI and it will drive LEDs without further involvement from the micro controller.
The chip offers 2 display modes: Decode Mode is intended to manage 7 segment displays (plus a dot)
and another which displays raw bitmaps instead, perfect for controlling an 88 LED matrix.
Multiple MAX72xx chips can be daisy-chained together to form larger displays as well.
Being a popular chip, a great deal has been written about the Max7219 and after you familiarize yourself
with the datasheet (http://datasheets.maxim-ic.com/en/ds/MAX7219-MAX7221.pdf), you should check
out this article on the Arduino Playground (http://arduino.cc/playground/Main/MAX72XXHardware)
and come back here when youre done.
About these ads (http://en.wordpress.com/about-these-ads/)
Using a MAX7219/MAX7221 LED display driver with a netdui... http://fabienroyer.wordpress.com/2011/03/13/using-a-max7...
1 de 10 22-04-2014 14:47
Connecting the MAX72xx to the netduino
Here are the hardware components that youll need:
1 Max72xx chip (http://www.sparkfun.com/products/9622)
1 monochrome LED matrix (http://www.futurlec.com/LED/LEDMS88R.shtml) (for example)
1 Logic-level shifter (DigiKey (http://www.nxp.com/documents/data_sheet/HEF4050B.pdf))
(optional: see note below)
1 10K resistor minimum
1 100 uF capacitor
1 0.1 uF ceramic capacitor
many hookup wires (as short as possible)
Note: The MAX72xx requires 3.5 volt logic levels minimum and because the netduino uses 3.3 volt logic
level on its digital output pins, you may need to place a logic-level shifter between the netduino SPI
interface and the Max72xx SPI interface. Check out this article (http://wp.me/p18Z1X-2U) if youre not
sure how this works.
While the Max72xx SPI clock can go up to 10 MHz based, I was unable to get stable communications
above 2 MHz when using the MAX7219 with a logic-level shifter. Without the shifter, SPI @ 10 MHz
works flawlessly but because this is out of the chips specifications, so your mileage may vary.
The following summarizes the connections. It doesnt matter which pins you choose on the logic-level
shifter provided that theyre matching low-level input/high-level output pins.
SPI CLK: netduino pin 13 -> Logic-level shifter -> Max72xx pin 13 (CLK)
SPI MOSI: netduino pin 11 -> Logic-level shifter -> Max72xx pin 1 (DIN)
SPI CS: netduino pin 10 -> Logic-level shifter -> Max72xx pin 12 (LOAD/CS)
Note: the MAX72xx is extremely sensitive to EMI (http://en.wikipedia.org
/wiki/Electromagnetic_interference)and power fluctuations. So, be sure to:
Place the capacitors as close as possible to the V+ and GND pins of the chip
Using a MAX7219/MAX7221 LED display driver with a netdui... http://fabienroyer.wordpress.com/2011/03/13/using-a-max7...
2 de 10 22-04-2014 14:47
Connect both GND pins to ground
Use the shortest possible hookup wires
If EMI is an issue, reducing the speed for the SPI bus and/or using shorter hookup wires may help. If
you still have EMI issues, the MAX7221 is likely the right alternative.
Connecting the Max72xx to the LED matrix
The LED matrix that Im using is wired like this:
(http://fabienroyer.files.wordpress.com/2011/03
/ledmatrixwiring.png)
LED matrix
Connecting it to the MAX72xx is straight forward:
The MAX72xxs SEG pins correspond to the columns of the LED matrix
The MAX72xxs DIG pins correspond to the rows on the LED matrix
(http://fabienroyer.files.wordpress.com/2011/03
/max7219matrixwiring.png)
Max72xx -> LED matrix Wiring
Using the netduino.helpers Max72xx C# driver
The C# driver attempts to stick to the Max72xx datasheet as closely as possible. It presents properties
matching the various registers of the chip and a simple overloaded Display method. Be sure to check
Using a MAX7219/MAX7221 LED display driver with a netdui... http://fabienroyer.wordpress.com/2011/03/13/using-a-max7...
3 de 10 22-04-2014 14:47
out the unit tests in the /Samples for usage details. (http://netduinohelpers.codeplex.com
/SourceControl/changeset
/view/057608a47a9d#Samples%2fMax72197221Test%2fMax72197221Test%2fProgram.cs)
(http://fabienroyer.files.wordpress.com/2011/03
/max72xxinterface.png)
Max72xx C# Interface
Action shot
Maxim 7219-7221 LED driver - netduino unit test...
0:00 / 0:48
Happy hacking!
-Fabien.
Using a MAX7219/MAX7221 LED display driver with a netdui... http://fabienroyer.wordpress.com/2011/03/13/using-a-max7...
4 de 10 22-04-2014 14:47
You May Like1.
From C#, components, electronics, netduino25 Comments
Mario Vernari permalink
Hi Fabien.
Nice work, indeed.
Just a couple of things that could be useful.
The first is that probably the level shifter is not mandatory. Even the Maxims sheet indicates a
minimum high voltage of 3.5V, I guess that it should work anyway. I have done it with a 74HC595
powered at +5V and it works OK.
The second thing is about the length of wiring. The problems of SPI communication are not because
EMIs, I think, but the impedance of wiring instead. You may have some better result if you twist the
data+clock wires together: I think there will no problem even to 10MHz (as long you dont exceed
5-10 in length).Bye
Mario
Reply
Fabien Royer permalink
Thanks Mario.
Ill definitely try twisting the CLK/DATA wires together and will report my findings here.
Cheers,
-Fabien.
Reply
Fabien Royer permalink
I forgot to mention in my earlier comments: removing the logic-level shifter allowed me to
bump up the speed to 10 MHz, even w/o twisting CLK/DATA
Cheers,
-Fabien.
Fabien Royer permalink
Hey Mario,
I tested w/o the logic-level shifter tonight and everything worked fine.
1.
:)
:)
Using a MAX7219/MAX7221 LED display driver with a netdui... http://fabienroyer.wordpress.com/2011/03/13/using-a-max7...
5 de 10 22-04-2014 14:47
This strays from the chips specifications though, so it may not always work. It also appears that
the SparkFun logic-level shifter doesnt keep up at higher frequencies.
Cheers,
-Fabien.
Reply
Mark Stevens permalink
Timely, I| was just wiring up my MAX7219 to a 4 digit seven segment display. This will help a lot.
Thanks,
Mark
Reply
Mark Stevens permalink
I have recently tried this library with a 4 digit, 7 segment display and experienced some problems
with the display. The chip appears to be turning the LEDs on all the time. So in test mode they
turn on and are bright but when test mode is exited they are still on just very dim.
Did you experience this?
Regards,
Mark
Reply
Fabien Royer permalink
Thats very odd. I havent experienced that problem at all.
Can share your code? I can see if I can get a repro of your issue.
Also, be aware that we updated the interface of the driver a bit (got rid of the write-only
properties in favor of functions with the same names) after running ReSharper on the code.
2.
Mark Stevens permalink
Im beginning to think Ive damaged the chip trying to get this to work. I replaced your main
program in the samples with:
_max.Shutdown = Max72197221.ShutdownRegister.ShutdownMode;
Thread.Sleep(4000);
_max.Shutdown = Max72197221.ShutdownRegister.NormalOperation;
And now I do not get the dimming I get one blank digit followed by three 9s and the decimal point.Nothing seems to change the display.
Logic analyser is showing the right commands going over SPI. Wiring is good double checked that.
Thanks for the reply,
Mark
Reply
Fabien Royer permalink
Something is definitely wrong hardware-wise here.
Are you working on a breadboard or have you soldered things together?
3.
Using a MAX7219/MAX7221 LED display driver with a netdui... http://fabienroyer.wordpress.com/2011/03/13/using-a-max7...
6 de 10 22-04-2014 14:47
Reply
Mark Stevens permalink
Im still on breadboard at the moment.
Courtney Wilson permalink
Fabien,
Ive just started using your C# library for the Max7219 (thanks for making it). Ive wired up an led
matrix (currently 4 columns, 3 rows of leds). When I plug in the power, all of the leds light up
immediately and they stay on. My code builds and runs but seems to have no effect on the matrix. It
seems like the spi is having no effect on the matrix whatsoever (in fact disconnecting the clock, cs
and mosi lines do not affect anything at all). Have you run across this before? Any thoughts on
where I might start looking to find the problem?
Thanks
Courtney
Reply
Fabien Royer permalink
Hi Courtney,
Yes, I know exactly what youre talking about.
This behavior is caused by the Netduino switching all of its outputs to high on power-up. The
Max7219 interprets this as a test mode command and lights up all of the LEDs connected to it.
The remedy is simple though: the power to the Max7219 chip needs to be controlled through a
PNP transistor by the application on the Netduino.
Does this help?
Cheers,
-Fabien.
Reply
Courtney Wilson permalink
Thanks for the quick response. I am a long time programmer, not an electrical engineer,
although I have tinkered with a few tiny circuits and read a couple of digital electronics books
in the distant past.
From how I read your response, instead of powering the Max chip with 5V directly, instead
put a general purpose PNP transistor in line controlled by some unused Netduino IO pin that
will switch on the 5V power to the Max chip when I set the Netduino IO port low. So basically
I can control when power is first sent to the Max chip IN CODE thus preventing the Max chip
from entering its test mode on Netduino bootup.
I have modified the Max/Netduino schematic from Arudino Playground to include this
change. Is there way I can post this image (or email it to you), so that you could verify if I have
the concept correct?
Thanks again,
Courtney
4.
Using a MAX7219/MAX7221 LED display driver with a netdui... http://fabienroyer.wordpress.com/2011/03/13/using-a-max7...
7 de 10 22-04-2014 14:47
Fabien Royer permalink
So basically I can control when power is first sent to the Max chip IN CODE thus preventing the
Max chip from entering its test mode on Netduino bootup.
Exactly! If you like, you can email me your diagram at froyer67 at gmail.com
Cheers,
-Fabien.
Ron Barry permalink
Im having a similar problem with a MAX7219, but rather than going straight to the PNP
transistors, I changed my code so there was a 10 second pause between when setup() was
called and when I instantiated the LedControl. I then powered down the arduino, connected
the three 7219 inputs to ground and powered it up again. During the 10 second delay, I
switched the inputs back to being connected to the output pins on the arduino. This should
have the effect of keeping the 7219 out of test mode by preventing it from getting three high
inputs while it is starting up, but it should still be able to initialize normally when I allocate
the LedControl.
Ive swapped out the 7219 for a different one (from the same batch,) swapped out arduinos,
checked the connectivity of every wire in my circuit, and my capacitors are only one pin away
from the controller. Im completely out of ideas. What else might cause the LED matrix to
come up with all 64 LEDs on as soon as power is applied?
Thanks,
Ron
Fabien Royer permalink
Hi Ron,
I dont have a straight answer for you but I would suggest connecting a logic analyzer to the
SPI lines between the Arduino and the Max7219 to see whats being sent to the chip on
power-up. I would double-check the ground plane connections and would ensure that the
caps in your circuit provide sufficient power supply decoupling and digital noise isolation.
I hope this helps.
-Fabien.
Courtney Wilson permalink
Fabien,
Im still having difficulties with getting this Max7219 chip working with the Netduino. I am using
the chip to drive up to 64 individual LEDs. I suspect that I am still running into the issue you
described previously regarding the Max7219 being stuck in test mode. I noticed you updated your
unit tests for the Max chip on Netduino Helpers to include an output port (pin D0) to control the
PNP transistor that manages the power to the Max chip. Do you have a wiring diagram or
explanation of how to wire in the PNP transistor to the circuit?
Thanks again
Courtney
5.
:)
Using a MAX7219/MAX7221 LED display driver with a netdui... http://fabienroyer.wordpress.com/2011/03/13/using-a-max7...
8 de 10 22-04-2014 14:47
Reply
Fabien Royer permalink
Hi Courtney,
Im in the process of building a complete diagram showing how this is all wired up using the
PIX-6T4 as the working example. The power to the Max is actually switched using a PNP / NPN
transistor combo to deal with voltage differences between control logic (netduino) and power
switching (Max @ 5v). Both transistors are saturated in this scenario. Check back the blog soon as
Ill publish the wiring diagram as part of the series on building your own PIX-6T4 console.
Cheers, -Fabien.
Reply
Courtney Wilson permalink
Great! I cant wait to see this article. This Max chip has been a little thorn in my side. Ive got a
162 LCD working, a 64 button shield working, and managed to get 2 SOMO sound modules
working together with an electronic mixer and amp circuit two play two sounds
simultaneously. Finishing the 64 led Max chip circuit and then getting my 4 Sure Electronics
HT1632C Dot Matrix panels working are the last steps in my plan to rule the world.
Thanks again for your time and I look forward to your article!
Courtney
Fabien Royer permalink
Hi Courtney,
Check out the docs section on the new PIX-6T4 site. I uploaded the schematics that youll need
to resolve your issue there. Hope this helps.
Cheers,
-Fabien.
Osama Ashaikh permalink
Hi Fabien,
The new site does not seem to be working, is it possible to send me a copy of the resolved schematics
to my email address
Thankyou
Reply
Fabien Royer permalink
Hi Osama,
Are you talking about the new PIX-6T4 site? Weve been having difficulties with the sites hoster
but its working fine now Check this page: http://www.pix6t4.com/schematics
Cheers,
-Fabien.
Reply
6.
:)
Using a MAX7219/MAX7221 LED display driver with a netdui... http://fabienroyer.wordpress.com/2011/03/13/using-a-max7...
9 de 10 22-04-2014 14:47
Trackbacks & Pingbacks
Windows Client Developer Roundup 063 for 3/14/2011 - Pete Brown's 10rem.net1.
Driving a LED matrix from a Netduino one more time: The Right Way2.
Silverlight Developer Blog Archive 4 Digit, 7 Segment Display Part 1 Ouput a Byte3.
Blog at WordPress.com. | The Titan Theme.
Follow
Follow Fabien's Bit Bucket
Powered by WordPress.com
Using a MAX7219/MAX7221 LED display driver with a netdui... http://fabienroyer.wordpress.com/2011/03/13/using-a-max7...
10 de 10 22-04-2014 14:47