0% found this document useful (0 votes)
117 views

LED Matrix

The document describes an 8x8 LED matrix that can display arbitrary patterns through a raster scanning technique. It provides instructions to interface the LED matrix with a microcontroller using 24 digital I/O pins to separately control the rows and columns of green and red LEDs. The demonstration code uses two 64-bit arrays to represent patterns and animates a converging square. Suggested enhancements include mapping sensor measurements to the display and using an LED driver chip to reduce processor load.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
117 views

LED Matrix

The document describes an 8x8 LED matrix that can display arbitrary patterns through a raster scanning technique. It provides instructions to interface the LED matrix with a microcontroller using 24 digital I/O pins to separately control the rows and columns of green and red LEDs. The demonstration code uses two 64-bit arrays to represent patterns and animates a converging square. Suggested enhancements include mapping sensor measurements to the display and using an LED driver chip to reduce processor load.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

29 LED Matrix

The LED matrix pictured in Figure 29.1 is an 4. Design an animation sequence.


8×8 grid with one green LED and one red LED
behind each circular dot. The LED matrix uses the
same row/column wiring scheme as the keypad 29.1 Component Demonstration
of Chapter 25 with two column lines (one for each
LED) and a shared row line. Follow these steps to demonstrate correct operation
of the LED matrix.

Select these parts:


• LED matrix, http://www.sparkfun.com/datasheets/
Components/SanYoung-Medium-RG.pdf
• Breadboard (2×)
• Jumper wires, M-F (24×)

Build the interface circuit: Refer to the pin diagram


shown in Figure 29.2 on page 131 and recommended
breadboard layout shown in Figure 29.3 on page 132.

TIP: Use the resistor color code for the DIO


wire colors, e.g., black (0) for B/DIO0, brown
Figure 29.1: NI myRIO Embedded Systems Kit LED (1) for B/DIO1, and so on.
matrix.
The interface circuit requires eight connections
to NI myRIO MXP Connector A and sixteen connec-
Learning Objectives: After completing the activities tions to Connector B (see Figure A.1 on page 233):
in this chapter you will be able to: 1. Row 1 (1) → A/DIO0 (pin 11)
1. Describe the LED matrix wiring diagram, 2. Row 2 (2) → A/DIO1 (pin 13)
2. Explain the raster display technique to display 3. Row 3 (3) → A/DIO2 (pin 15)
arbitrary patterns, 4. Row 4 (4) → A/DIO3 (pin 17)
3. Describe the need to alternately activate the 5. Row 5 (21) → A/DIO4 (pin 19)
green and red LEDs, and 6. Row 6 (22) → A/DIO5 (pin 21)
130 29. LED MATRIX

7. Row 7 (23) → A/DIO6 (pin 23) (downloads) to NI myRIO before the VI starts
8. Row 8 (24) → A/DIO7 (pin 25) running.
9. Column 1 green (5) → B/DIO0 (pin 11) NOTE: You may wish to select the “Close on
10. Column 2 green (6) → B/DIO1 (pin 13) successful completion” option to make the VI start
11. Column 3 green (7) → B/DIO2 (pin 15) automatically.
12. Column 4 green (8) → B/DIO3 (pin 17)
13. Column 5 green (9) → B/DIO4 (pin 19) Expected results: The VI begins in “automatic
14. Column 6 green (10) → B/DIO5 (pin 21) pattern” mode and the display should show a
15. Column 7 green (11) → B/DIO6 (pin 23) converging square animation in which the display
16. Column 8 green (12) → B/DIO7 (pin 25) changes every half second. Move the pattern loop
17. Column 1 red (20) → B/DIO8 (pin 27) time pointer slide to adjust the animation speed. Do
18. Column 2 red (19) → B/DIO9 (pin 29) you notice anything unusual for loop times below
19. Column 3 red (18) → B/DIO10 (pin 31) 100 ms?
20. Column 4 red (17) → B/DIO11 (pin 18) Click the auto pattern switch and then try clicking
21. Column 5 red (16) → B/DIO12 (pin 22) buttons on the green 2-D array control. You should
22. Column 6 red (15) → B/DIO13 (pin 26) see the corresponding green LED activate on the
23. Column 7 red (14) → B/DIO14 (pin 32) display. Take a moment to try each of the rows
24. Column 8 red (13) → B/DIO15 (pin 34) and columns to ensure that your wiring is correct.
Repeat for the red 2-D array control.
TIP: Short on jumper wires? You can connect The green pattern and red pattern indicators
a subset of the array, e.g., rows 1 to 4 and under the array controls show the state of the 8×8
columns 1 to 4 for a green-only display that 2-D Boolean arrays as a single 64-bit hexadecimal
requires only eight jumper wires. value. Select Edit | Reinitialize Values to Default
to clear all 64 array buttons and then click the
lower-right button. Note how this corresponds to
Run the demonstration VI: the least-significant bit in the 64-bit value. Click
the upper-left button; this is the most-significant bit.
• Download http://www.ni.com/academic/myrio/
Click more buttons to determine the ordering of the
project-guide-vis.zip if you have not done
remaining bits. These 64-bit pattern codes provide a
so previously and unpack the contents to a
convenient way for you to create individual display
convenient location,
patterns to be used for animations.
• Open the project LED Matrix demo.lvproj
Click the Stop button or press the escape key to
contained in the subfolder LED Matrix demo,
stop the VI and to reset NI myRIO.
• Expand the hierarchy button (a plus sign) for
the myRIO item and then open Main.vi by
double-clicking, Troubleshooting tips: Not seeing the expected
• Confirm that NI myRIO is connected to your results? Confirm the following points:
computer, and • Glowing power indicator LED on NI myRIO,
• Run the VI either by clicking the Run button on • Black “Run” button on the toolbar signifying that
the toolbar or by pressing Ctrl+R. the VI is in run mode, and
Expect to see a “Deployment Process” window • Correct wiring — ensure that your wiring order
showing how the project compiles and deploys is correct (it is easy to make a mistake).
29. LED MATRIX 131

Figure 29.2: Demonstration circuit for LED matrix: pin diagram and connection to 24 digital I/O terminals
on NI myRIO MXP Connectors A and B.

29.2 Interface Theory control of the two LEDs at each dot. Activating both
LEDs can color mix to yellow.
Interface circuit: Each circular dot of the 8×8 LED
matrix contains a green LED and a red LED. The Study the video LED Matrix Interfacing Theory
cathode of each diode pair connects to the same (youtu.be/vsBjZBLdeNc, 9:51) to learn more about
horizontal row wire. The anode of all the green the LED matrix wiring diagram and pin connections,
LEDs in the same column connects to the same electrical interfacing (especially the substantial
vertical column wire; the anodes of the red LEDs are voltage/current mismatch between the red and
similarly connected, thereby providing individual green LEDs), and the raster display technique that
132 29. LED MATRIX

Figure 29.3: Demonstration circuit for LED matrix: recommended breadboard layout.
29. LED MATRIX 133

permits an arbitrary pattern of dots to be selected. want to use “Array Size” from the Programming
| Array subpalette instead of the constant “4”
NOTE: The interfacing technique described in to make your code accommodate an arbitrary
this chapter requires no additional parts and number of 64-bit patterns.
also helps you to understand how to set up a 3. Think of a way to map one or more measure-
raster display (also known as a multiplexed ments such as the onboard accelerometer output
display). However, 24 DIOs uses more than or analog input voltages onto the display. For
half of the available 40 DIOs and also ties up example, you could make eight bar graphs to
shared resources such the SPI, I2C-bus PWM, show eight analog input voltages, or you could
and encoder. Furthermore, the raster scan code map the X and Y outputs from the accelerometer
requires a significant amount of a CPU effort. onto a Cartesian grid. Your mapping destination
Consider instead using the MAX7219 LED is the 2-D Boolean array global variables.
Display Driver (see “For More Information” 4. Add a pointer slide to vary the loop time of
section at the bottom of the page) to completely the timed loop: pull down on the “Right Data
offload the detailed control of the LED matrix; Node” on the upper-right interior of the timed
you simply transfer the desired patterns via loop to expose the “Next Loop Iteration Timing”
the SPI bus. This technique becomes manda- terminal (appears at dt), and then create a
tory should your application need more LED front-panel control to interactively adjust the
matrices to build a larger display. loop time. Set the lower limit to 1 ms to avoid
selecting 0 ms (this hangs the application).
LabVIEW programming: Study the video Digital 5. Observe the effects of jitter on the display:
Output Low-Level VIs (youtu.be/WvnInG3ffqY, change the timed loop to a standard while
4:53) to learn how to use the low-level VIs to connect loop (right-click on the loop frame and select
Boolean arrays directly to the digital outputs, i.e., “Replace with While Loop”) and then add a 1 ms
as a bus. time delay. You should notice that the display
intensity has a slight random flicker because the
real-time processor now has more freedom to
29.3 Basic Modifications process background tasks. The timed loop, on
the other hand, guarantees a precise loop time.
Study the video LED Matrix Demo Walk-Through
(youtu.be/Bqq63sKwQKE, 12:14) to learn the
design principles of LED Matrix demo, and
then try making these modifications to the block
diagram of Main.vi: 29.4 Integrated Project Ideas
1. Finish the “Auto pattern generator” loop and
update the main loop to add a pattern codes Now that you know how to use the LED matrix
array for the red LEDs. consider integrating it with other devices to create
2. Create a set of 64-bit pattern codes to make your a complete system, for example:
own animation, and then update the 1-D array
constant in the “Auto pattern generator” loop. • Digital Bubble Level (57)
You may find it more convenient to change the • NTP Clock (43)
constant to a front-panel control. You may also
134 29. LED MATRIX

29.5 For More Information


• 8×8 LED Matrix Datasheet by SparkFun ∼
Datasheet for the 8×8 LED matrix:
http://www.sparkfun.com/datasheets/Components/
SanYoung-Medium-RG.pdf
• MAX7219 LED Display Driver with SPI Interface
by Maxim Integrated ∼ Includes power transis-
tors and raster display controller to completely
offload the detailed control of each LED. Simply
send the patterns via the SPI serials bus:
http://www.maximintegrated.com/MAX7219

You might also like