Controlling a Dot Matrix LED Display with a Microcontroller



Similar documents
2.0 Command and Data Handling Subsystem

PHYS 2P32 Project: MIDI for Arduino/ 8 Note Keyboard

Surveillance System Using Wireless Sensor Networks

Advanced LED Controller (LED Chaser)

Using and Wiring Light Emitting Diodes (LEDs) for Model Railroads

Switch board datasheet EB

ET-BASE AVR ATmega64/128

ARDUINO SEVERINO SERIAL SINGLE SIDED VERSION 3 S3v3 (REVISION 2) USER MANUAL

Cornerstone Electronics Technology and Robotics I Week 15 Voltage Comparators Tutorial

TEECES DOME LIGHTING SYSTEMS

8 by 8 dot matrix LED displays with Cascadable Serial driver B32CDM8 B48CDM8 B64CDM8 General Description

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

AUTOMATIC NIGHT LAMP WITH MORNING ALARM USING MICROPROCESSOR

Your Multimeter. The Arduino Uno 10/1/2012. Using Your Arduino, Breadboard and Multimeter. EAS 199A Fall Work in teams of two!

GLOLAB Universal Telephone Hold

4 Character 5x7 LED Matrix Display

Transistor Characteristics and Single Transistor Amplifier Sept. 8, 1997

STEPPER MOTOR SPEED AND POSITION CONTROL

POINTS POSITION INDICATOR PPI4

PROJECT PRESENTATION ON CELLPHONE OPERATED ROBOTIC ASSISTANT

BrightSign Expander Hardware Guide

ECEN 1400, Introduction to Analog and Digital Electronics

K8025 VIDEO PATTERN GENERATOR. Check the picture quality of your monitor or TV, ideal for adjustment or troubleshooting.

IR Communication a learn.sparkfun.com tutorial

Designing VM2 Application Boards

FFT Frequency Detection on the dspic

Experiment #5, Series and Parallel Circuits, Kirchhoff s Laws

SYSTEM 4C. C R H Electronics Design

Tire pressure monitoring

Joule Thief 3.0 Kit. June 2012, Rev Joule Thief 3.0

Physics 623 Transistor Characteristics and Single Transistor Amplifier Sept. 13, 2006

Introduction to Arduino

Microcontroller Based Low Cost Portable PC Mouse and Keyboard Tester

LM 358 Op Amp. If you have small signals and need a more useful reading we could amplify it using the op amp, this is commonly used in sensors.

Data Sheet. Adaptive Design ltd. Arduino Dual L6470 Stepper Motor Shield V th November L6470 Stepper Motor Shield

A Digital Timer Implementation using 7 Segment Displays

The $25 Son of a cheap timer This is not suitable for a beginner. You must have soldering skills in order to build this kit.

Hands On ECG. Sean Hubber and Crystal Lu

FLYPORT Wi-Fi G

Introducing AVR Dragon

Interfacing Analog to Digital Data Converters

Accurate Measurement of the Mains Electricity Frequency

FREQUENCY RESPONSE OF AN AUDIO AMPLIFIER

Computer Automation Techniques. Arthur Carroll

STK User Guide

Welcome to the tutorial for the MPLAB Starter Kit for dspic DSCs

Interfacing To Alphanumeric Displays

An Experimental Study on Pixy CMUcam5 Vision Sensor

Touch Screen for Pictiva OLED display. Application Note. Introduction

1. General Description

8051 MICROCONTROLLER COURSE

Measuring Resistance Using Digital I/O

A+ Guide to Managing and Maintaining Your PC, 7e. Chapter 1 Introducing Hardware

Objectives: Part 1: Build a simple power supply. CS99S Laboratory 1

8-Bit Microcontroller with Flash. Application Note. Using a Personal Computer to Program the AT89C51/C52/LV51/LV52/C1051/C2051

Glolab Talking Phone Dial Monitor

Electronic Rotary Table Divider V2.1 Construction

Lab 1 Course Guideline and Review

POCKET SCOPE 2. The idea 2. Design criteria 3

Robot Board Sub-System Testing. Abstract. Introduction and Theory. Equipment. Procedures. EE 101 Spring 2006 Date: Lab Section # Lab #6

XBee USB Adapter Board (#32400)

RGB for ZX Spectrum 128, +2, +2A, +3

Points Position Indicator (PPI1) for Points Motors with Common Ground

RGB LED Strips. Created by lady ada. Last updated on :00:18 PM EST

ENGI E1112 Departmental Project Report: Computer Science/Computer Engineering

SMARTCARD XPRO. Preface. SMART ARM-based Microcontrollers USER GUIDE

The basic set up for your K2 to run PSK31 By Glenn Maclean WA7SPY

AXE033 SERIAL/I2C LCD

The components. E3: Digital electronics. Goals:

INTRODUCTION TO SERIAL ARM

An Introduction to MPLAB Integrated Development Environment

3-Digit Counter and Display

RS232/DB9 An RS232 to TTL Level Converter

The Programming Interface

APPLICATION NOTES: Dimming InGaN LED

AVR Butterfly Training. Atmel Norway, AVR Applications Group

EvB 5.1 v5 User s Guide

Microcontroller to Sensor Interfacing Techniques

User s Manual of Board Microcontroller ET-MEGA2560-ADK ET-MEGA2560-ADK

Fingerprint Based Biometric Attendance System

CHAPTER 11: Flip Flops

0832 Dot Matrix Green Display Information Board User s Guide

How To Program A Microcontroller Board (Eb064) With A Psp Microcontroller (B064-74) With An Ios 2.5V (Power) And A Ppt (Power Control) (Power Supply) (

IRT Eurocard. Types DAX-3200

NTE2053 Integrated Circuit 8 Bit MPU Compatible A/D Converter

C8051F020 Utilization in an Embedded Digital Design Project Course. Daren R. Wilcox Southern Polytechnic State University Marietta, Georgia

Embedded Software Development: Spottbillige Hardware + OSS = Zum Spielen zu Schade!

Automatic Street Light Control System Using Microcontroller

Display Board Pulse Width Modulation (PWM) Power/Speed Controller Module

User Manual. AS-Interface Programmer

Lab 3 Microcontroller programming Interfacing to Sensors and Actuators with irobot

Programming PIC Microcontrollers in PicBasic Pro Lesson 1 Cornerstone Electronics Technology and Robotics II

Arduino project. Arduino board. Serial transmission

PolyBot Board. User's Guide V1.11 9/20/08

If an occupancy of room is zero, i.e. room is empty then light source will be switched off automatically

Balun Parameter Definitions & Measurement May 2004

LED board datasheet EB

QT1 Xplained Pro. Preface. Atmel QTouch USER GUIDE

MIDECO 64-outputs MIDI note decoder USER MANUAL. Roman Sowa 2012

Transcription:

Controlling a Dot Matrix LED Display with a Microcontroller By Matt Stabile and programming will be explained in general terms as well to allow for adaptation to any comparable microcontroller or LED matrix. University of California Santa Barbara Media Arts and Technology MAT 200C Winter 2008 Abstract A tutorial on the basics of choosing and setting up a microcontroller to control an LED matrix is provided. Fundamentals of LED matrices and microcontrollers are first covered, followed by tips on making the necessary interconnections between the two. Relevant software for development is surveyed and finally some example code is provided for testing the LED matrix. Introduction This paper will provide a comprehensive tutorial on how to drive and control a dot matrix Light Emitting Diode (LED) display with a microcontroller. The display used is a commercially available PCB mount 8 x 8 dot matrix RGB LED display, with a total of 192 individual LEDs that are controlled by 32 control signals. The microcontroller used is an Atmel ATMega128; however, the control Figure 1: 8x8 Dot Matrix LED Display The Dot Matrix LED Display An LED Matrix consists of an array of LED s which are interconnected such that the positive terminal (anode) of each LED in the same column are connected together and the negative terminal (cathode) of each LED in the same row are connected together. Note that this could be the other way around as well, with the positive terminals connected to the rows and the negative terminals connected to the columns. Figure 2 shows a schematic for a typical 8 x 8 matrix with single color LEDs.

in each row and column, it is not possible to control each individual LED at the same time. Instead, the matrix is controlled by cycling through each row very quickly while triggering the correct column pins to light the desired LED s for that particular row. If the switching is done at a quick enough rate, there will be no visible flicker and the LED matrix display will appear to have each Figure 2: 8x8 LED Matrix Schematic An LED dot matrix display ( dot refers to the circular lenses in front of the LEDs) can also come with multiple LEDs of varying colors behind each dot in the matrix. For example, the matrix used in this project has a Red, Green and Blue LED behind each dot in the 8x8 grid. A configuration with multiple LEDs behind each dot adds another control pin to every column (positive terminal) for each additional color of LED, while the rows (negative terminals) are still all connected together. Therefore an RGB matrix has 32 control pins compared to the 16 pins seen in Figure 2. Controlling the LED Matrix Since all of the individual LED s in a matrix share their negative and positive terminals LED turned on at the same time. This works because of the principle known as Persistence of Vision, which is the theory that the retina of the human eye retains an image for about a tenth of a second. Thus an LED matrix must be very precisely controlled, with the Rows being scanned through sequentially at a rate greater than about 40Hz (to be safe) while sending out the column data at the exact same rate. This kind of control is most easily accomplished with the aid of a microcontroller, plus some additional components. Choosing a microcontroller When choosing a microcontroller that will meet the requirements necessary for controlling an LED matrix, the specifications that must be met are those of the number

of I/O pins available, the amount of current that each pin can source and sink and the speed at which the microcontroller can send out control signals. Another option that one might desire is that of an onboard Analog to Digital Converter for sampling an input signal (such as an audio waveform) which can then influence the control signals being sent to the LEDs. Modern day microcontroller technology has made the issue of control signal speed and available I/O pins almost trivial for this application. Almost every chip on the market now has upwards of 32 I/O pins available and almost all operate at speeds greater than 10MHz, which allows for control signals to be sent at rates much greater than the 40Hz that is required to satisfy the Persistence of Vision principle. For example, the microprocessor that I chose ran at an operating speed of 16MHz and in the loop of code that cycled through the rows I was still able to put a 2ms delay between each iteration, meaning that there was a guaranteed 16ms of delay in my code (excluding the actual code execution time) and still no visible flicker on the matrix display. Up until recent years, 1 8 decoder chips (which allow the 8 rows pins to be controlled by just 3 I/O pins) were almost always used to minimize the number of I/O pins required on the microcontroller; however, with the large amount of I/O pins available on almost all micros now, these chips seem like an unnecessary complication to the design. The final specification that must be met is that of current consumption, meaning that the amount of current that each I/O pin can source and sink is greater than the amount of current needed to illuminate a row of LEDs. These numbers must be determined from the specifications sheet of the LED matrix in conjunction with the microcontroller s maximum current values. This specification is also easily met in most situations though, due to the way in which we are switching the LEDs off and on in such a rapid manner. When a typical current specification is given on the LED matrix data sheet (usually around 20mA per LED), the spec is for steady state consumption (continuously on ). Since the LEDs are being switched on and off so quickly, our current consumption is actually much lower due to the current draw s continuously transient state. With the LED s fully switching, I observed there to be only

about a third of the current being drawn as compared to the LEDs consumption at a steady state. To be safe, a Darlington transistor array is almost always used in between the cathodes of the LEDs and the microcontroller I/O Pins. The Darlington transistor array is an IC that is an array of 8 grounded NPN transistors which serve as a current sink, enabling more current to be drawn through the LEDs safely. The array has a dual purpose in that it also inverts the signal on the pins, so when we send a positive control signal, it is actually completing the Ground connection as is needed to turn on the LEDs. Bias resistors must also be calculated and inserted in between each I/O pin on the microcontroller and the anode pins on the LED matrix. Bias resistors are calculated by referring to the Electrical Characteristics table on the LED matrix s data sheet. Each differently colored LED has a voltage that it prefers to be biased at for correct operation, somewhere usually between 2 5 Volts. The voltage on the I/O pins of most microcontrollers is a standard 5 Volts, so using Ohms law with the desired voltage and current specs will yield a correct bias resistor value for each column of LEDs. Putting it all together With all of the specifications met, now comes the fun part of wiring the whole matrix up. This involves fabricating many cables as the RGB matrix requires 32 control signals, which first have to go from the microcontroller to a board with the bias resistors and Darlington transistor array, and then from there to the 32 pins on the back of the matrix. Figure 3: Block Diagram of Connections The Atmel microcontroller used in this project has its I/O pins grouped in Ports with 8 I/O pins each plus a Vcc pin and Ground pin. Thus I chose to assign one port for controlling the switching of the 8 row pins, one port for the 8 Red Column pins, one for the 8 Green pins and one for the 8 Blue pins. This separation of colors, rows, and columns also makes the programming

more simple and intuitive. The most time consuming part of wiring up the matrix is mapping the pins from the microcontroller ports to the PCB mount pins on the back of the matrix. This turns out to be quite complex because the 32 pins on the matrix are in a seemingly completely random order and must be correctly assigned to pins 0 7 on each port of the microcontroller. Table 1 provides the pin mappings with the matrix pin numbers in bold and the corresponding microcontroller port letter and number directly below. 1 2 3 4 5 6 7 8 A0 F0 E1 A2 F2 E3 B7 B6 9 10 11 12 13 14 15 16 B5 B4 A4 E4 F5 A6 E6 F7 17 18 19 20 21 22 23 24 E7 A7 F6 E5 A5 F4 B3 B2 25 26 27 28 29 30 31 32 B1 B0 F3 A3 E2 F1 A1 E0 Table 1: Matrix Pin Numbers in Bold, corresponding microcontroller Port Letter and number directly below. These can be used in conjunction with the matrix data sheet information (links to this found in the References section), which shows the pin orientation on the actual matrix and which pins correspond to which LEDs in each row and column. After correctly making all of the connections, we are then ready to write a test program and begin testing the board. Programming the Microcontroller The Atmel ATMEGA128 can be programmed using BASIC, C, or Assembly language. After the code is written, it is compiled using the WinAVR compiler which outputs a Hex file that can then be directly downloaded to the microcontroller. The Hex file is downloaded via an In Circuit Programmer that connects the microcontroller to the parallel port of a PC. Figure 4: In Circuit program download tool The Hex file must be downloaded through use of special Serial Device Programming software such as the freeware program PonyProg2000. The Atmel evaluation board I purchased from futurlec.com came with extremely easy to follow tutorials and example programs that showed step by step how to compile and download the files

to the microcontroller. Any series of microcontrollers no doubt comes with extensive documents on setting up and programming one for the first time, so I will not into further detail of those processes. There are a variety of IDEs available for developing microcontroller programs depending on the language that is desired and the chip architecture being used. For Atmel s AVR family of chips, Atmel provides a free Assembly Language IDE called AVR Studio 4 which can be downloaded from www.atmel.com. For programming in BASIC, a demo version of BASCOM AVR is available from MCS Electronics at www.mcselec.com. The demo version s only limitation is that of a 4kB maximum source code file size. For programming in C there is CodeVisionAVR, available in a demo version with a 2kB file size limitation at www.codevision.be. A good free C/C++ IDE is called Code::Blocks and is available at www.codeblocks.org. Code::Blocks already has preconfigured settings for using the WinAVR compiler, so it is a very good choice for a free, fully functional IDE. The first program used to test the setup should be very simple and test every LED in the array. Figure 5 shows an example program that demonstrates how to turn on every LED in the matrix, changing which color LEDs are lit at even intervals. Note the infinite while loop, since we just want the microcontroller to run this routine for as long as it is powered up. This section of code would appear in the main() of your C source file. The only other code that would be necessary would be the #include libraries for your specific microcontroller and whatever lines of initialization may be required depending on the application. The code is extrememly simple, with the main for loop simply iterating down the rows of the matrix while simultaneously updating the column data on the Ports of the microcontroller. The delay in between each row must be calibrated depending on the speed of the microcontroller being used. The target value is to use the longest delay possible without being able to see any flickering of the LEDs. The delay is desired to ensure that the LEDs are getting enough current each time to achieve full brightness. The counter variable outside of the for loop allows states to change according to the length of the duration variable.

Figure 5: Example Control Program in C Conclusion As is apparent, there are many different options when it comes to choosing a microcontroller and LED matrix to work with. It is easiest to choose an LED matrix first and then to select a microcontroller that meets the demands of the LEDs to be controlled. Once the basic setup is complete, the real challenge lies in programming the LED matrix to display interesting patterns. A good expansion is to capture an input signal using an ADC and then modify the display based on the input signal information. With a digitized input signal, the FFT could then be taken and DSP algorithms could be used to map the data to the LED matrix in interesting ways.

On Line References Arduino www.arduino.cc Open source microcontroller project based on Atmel AVR family of chips Atmel www.atmel.com Manufacturer of the AVR series of microcontrollers RGB LED Dot Matrix Display www.foryard.com FYM-23881ABxxx Manufactured by Foryard Optoelectronics Data Sheet http://www.sparkfun.com/datasheets/com ponents/fym 23881ABxxx.pdf Best Microcontroller Projects www.best microcontroller projects.com Many example projects with PIC micros Code::Blocks www.codeblocks.org Free C++ IDE with built in support for many different compilers Futurlec www.futurlec.com Sells microcontroller evaluation boards and starter kits, as well as LED matrices Microchip www.microchip.com Manufacturer of PIC family of microprocessors Parallax www.parallax.com Sells microcontroller starter and advanced kits SparkFun Electronics www.sparkfun.com Sells microcontrollers and LED matrices The LED Light www.theledlight.com Sells all types of LEDs, has good beginner tutorials on setting up LEDs.