Step 1: Skill Level and Basic Tools
The most challenging part is soldering the 100 pin Atmega2560 to the Schmartboard daughterboard. Using the Schmartboard makes it a lot easier that soldering it directly to a PCB. These guys have made several YouTube videos to show you how it works – more on that later.
You should be proficient at soldering and have a decent solder station with a couple of different tips. You will get lots of practice assembling the matrix! You will need a couple of different tips for your iron - a normal 1.6mm or similar for the LEDs and a .2mm tip for the Atmega and the SMCs.
You should know how to use a Digital VOM to help diagnose problems.
Programming – The source code for the project is C++. C was not my native language - I am an old school FORTRAN and PL/1 programmer – the C++ routines are probably not the most efficient or well-designed programs, but they work. The development environment was AVR Studio 5. The hex, source and makefile files are in the download section. You can load the hex file and not need to do any programming!
Step 2: Components List
1x Voltage Regulator - IC REG LDO 3A 5.0V TO220-3
2x 10uf Capacitor
2x 20pf Capacitor
1x 0.1uF Capacitor
10x 0.1uF SMC Capacitor
4x MIC2981 Source Array Driver
4x ULN2803 Darlington Array - Sink
1x 16MHz Crystal
33x 220 Ohm Carbon Film (use 1 for the red Power LED indicator)
3x 100 Ohm Carbon Film
1x 5 pin 2.54mm Receptacle for DS1307 Module
1x 5mm LED – Red (power indicator)
3x 5mm LED – Status (your choice)
1200x 5mm LED - Choice of Color (may change the value of the 220 ohm resistors)
16' Ribbon Cable -10 conductor
1x ABS - Black 1/8" 14x14" either this one or next
1x ABS - Black 1/8" 24x24"
1x Power Supply 5V / 3A of wall wart
1x Straight Double Row Male Headers
8x 18 Pin IC Socket
10x PCB Connector - Male
10x Ribbon Cable Connector - Female
1x Molex connector for power - Male
1x Molex connector for power - Female
2x Molex Pin - Pin - Crimp
1x Schmartboard - SMC Prototype Board
5x Mounting Header for Schmartboard -Female
3x Mounting Header for Schmartboard - Male
1x Mounting for Switch - Screw Terminal
1x RTC Module - DS1307
You probably already have your favorite vendors for components. In the downloads Step, I have included the BOM with part numbers from my favorites - Digikey, Sparkfun and Adafruit.
The cost range for building this project is $250 - $300. If there is enough demand, I can order the PCBs in quantity and resell them for $75 each instead of the $211 for from Dorkbot (for 3 boards). Send me a PM if interested.
Step 3: The Circuit
On first glance the Atmega seems to have more than enough digital outputs to make the circuit design work. However, I ran into a few obstacles and challenges once I started the actual design and software. After lots of head scratching, reading and different approaches, I came up with the following:
PORT E/G - Can only use bits 0-5 on PORTE. Last 2 bits are from the 2 high order bits PORTG
PORT B is used for programming interface for the AVR.
PORT D is used for the RTC Interface
PORT G is Split - the 3 low order bits are for the 3 Status LEDs - Heartbeat, Soothing Mode and DS 1307 Error
The only part I really don't like is having to split PORTs E/G - this made the interrupt routing a little less 'streamlined'. I considered giving up the RTC, but in the end I kept it and settled for using two ports to control a block of 8 outputs.
The current limiting resistors worked out to be 220 Ohms for the LEDs I chose. They have a forward current of 20mA and forward voltage of 1.7 to 2.0. Using the formula to calculate the correct resistor - (Supply V - LED V) / LED Current you get something in the 150 - 165 ohm range. I chose 220 Ohm to reduce the current load on the circuit due to the number of LEDs. The 220 Ohm resistors work well - I have not tried a 150 Ohm, although I suspect it will work as well.
The input power offers two options - 5V regulated or 7-12V unregulated from a wall wart. The jumper in the power section is just a precaution. It bypasses the Voltage Regulator.
The external crystal clocks the CPU at 16MHz.
Step 4: LEDs
Colors and Current - Red and Yellow LED frequently have a 20mA Forward Current and 1.9 to 2.1V Forward Voltage. You can see from the chart that the Green, Orange and Blue have a higher Forward Voltage. Many LEDs also have 30mA of Forward Current. Keeping within the recommended Forward Voltage and Current is important so you don't overload the Source and Sink ICs.
Step 5: Power Supply
Step 6: Project Organization
- Assembling the LED Matrix
- Assembling the PCB
- Loading / Modifying the Software
Files for Downloading:
- BOM – Excel format
- PCB - Eagle Files
- hex files – 32x32.hex and 32x32_Test.hex (and .eep files)
- C++ Source
Step 7: Part 1: Building the LED Matrix
LED Spacing – This is personal preference. My prototype was built using ½” centers. After I finished it, I thought it was a little too much space so I changed to 3/8” spacing. The outside dimensions of the board are 14”x14” for 3/8” spacing and 17 ½”x17 ½” for ½” spacing. The holes are 13/64” or 5mm on both boards. Using either ½” or 3/8” centers, the legs serve as the connecting wires.
Drilling the holes…
Drilling 1024 holes takes a while. Keeping them in straight rows and columns is also a challenge. For my prototype I used a piece of pegboard (1/4” holes on 1” centers) as a guide. I also had printed a sheet paper with small dots on 1/2” centers. Using the pegboard and the paper as a guide, I used 4 bolts to secure the pegboard to the ABS sheet. The paper was between the two. I drilled all of the holes using the pegboard’s holes. Then I moved the pegboard ½” along the rows and drilled another set. Then twice more for the columns – again a lot of holes! I thought this was a good guide – especially since I drilled the holes with a small drill press. I was disappointed with the results. You can see from the pictures that the alignment is not great. The difference between the 13/64” and the ¼” pegboard holes accounted for the problems.
I went back to my plastics supplier (Regal Plastics) and they used their CNC machine to drill the holes for this build.
You can see from the pictures the improvement.
Step 8: Understanding the Matrix
Step 9: Inserting the LEDs
First - label the board – on the back side – add either tape or labels along the x and y axis as shown below. This is especially helpful if you plan on developing any additional software animations.
Step 10: Insert the LEDs
You can save some time by cutting the cathode lead before you insert it. It needs to be at least 1/2" long. Inserting the LEDs with needle nose pliers is the best way I have found. Just be sure you push against the plastic case and not the leads.
After each course, I use a hot glue gun to make sure the LEDs do not come loose from the plastic sheet. It does not take a lot of glue – just a row down one side of the LED. Try to keep the glue away from the leads as this makes it more difficult (and makes more fumes) during soldering. There are alternatives to using a hot glue gun such as plastic model cement or epoxy.
Next bend the the cathode legs 90 degrees towards the RIGHT using your finger. They should be flat and on top of the cathode lead to the right. Do not cut the right-most lead. The others can be cut as shown below for soldering. The leads can be either on top of or beside the adjoining cathode lead. Bending them until they touch makes soldering them lot easier. Leave the anode (longer leg) standing for now.
Step 11: Solder the Cathode Leads Together
Step 12: Testing the LEDs
There are a couple ways to test them – I discovered by accident that my digital VOM will actually light the LEDs! I set it to test impedance – I use either the 200 or the 2K ohm setting. Touching the red (+) VOM lead to the anode (standing lead or ‘+’) and the black lead to the cathode lead you may see the LED light up. By touching the black lead to the right-most cathode lead and touching each anode lead, you check both the LED and your soldering. I had some solder joints that were open and had to be re-soldered.
If your VOM does not light the LED, just use it to check the continuity of each course – you should see zero resistance if all of the solder connections are good. To test the LEDs using a 5V power supply, put a 100 to 200 ohm resistor in line with the ‘+’ side using a bread board or alligator clips and test across each LED. Be sure to use the resistor! Make sure ‘+’ goes to the anode (standing lead) and ‘-‘goes to the cathode (bent lead).
It is time consuming to test the LEDs here, but it is a lot easier to replace a bad LED here than after the matrix is fully wired.
Step 13: Anode Leads
Anode leads – bend the leads of the first and second courses of anodes as shown in the pictures below using needle nose pliers to give them enough clearance to pass over the cathode leads that we have already bent and soldered. Bend each of the 32 anode leads and then solder each to the anode lead of the LED on the next row. This will make the ‘rows’ of our matrix.
Repeat and repeat......
Insert the next course 'column' of LEDs, glue and solder the cathodes. Then trim and bend the anode leads of the previous course and solder them.
Continue until the board is complete.
On the last course of LEDs, do not cut the anode leads, but extend them like you have with the cathode leads.
Step 14: Almost Finished Matrix
Step 15: Connector Cables
After you have cut the 8 cables to length, add the connector and strain reliefs to one end. If you have done this before you can skip the following narrative.
The red wire is the index conductor. In this project it is always connected to the '0' LED of a row or column and to pln number 1 on the board connector (there is no pin 0). If you are using the rainbow type ribbon cable, just be consistent with your index wire.
Using scissors, make sure you have a 90 degree cut on each end. Insert one end of the ribbon cable into the connector matching the arrow on the connector with the index conductor. It should be flush or extend slightly on the other side. Be sure it is inserted straight. Pinch the cable with your fingers to keep the end on the cable. Next insert the connector into a vice or pliers to crimp the connector to the cable. I like a vice because it is easy to apply even pressure. You should hear one or two clicks as the connector locks to the cable. I sometimes hear 1, sometimes none, but usually 2. Don't over squeeze the connector.
Next fold the ribbon cable back over the connector and insert the strain relief as shown in the pictures. These can easily be locked using just your fingers.
Step 16: Solder the Ribbon Cables to the LED Matrix
Be sure to solder the Index (Red) wire to the '0' LED of each port as shown. Also, don't forget to separate 2 conductors from the 10 conductor ribbon cable - these can be cut and discarded.
This completes the assembly of the LED Matrix. Now, on to the PCB!
Step 17: Building the DS1307 RTC Module
Here is the link to the Kit - https://www.adafruit.com/products/264
Here is the link to the assembly - http://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit
If you have an Arduino - http://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/wiring-it-up
To set the Date and Time - http://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/understanding-the-code
Step 18: Assemble the PCB
Step 19: Schmartboard Assembly
Apply liquid solder to the pads on the Schmartboard and then position the Atmega as shown. The pads are actually small troughs and the chip will 'lock' in place when properly aligned. Apply more liquid flux to the pins being very careful not to bend them - stroke with the pins not across them. Tape the IC in place covering approximately 1/2 of the chip. Inspect the position with a loupe before you start soldering.
Exactly like the video, using a .20 mm tip and setting your solder iron to 700F, start on the outside end of each pad / trough and move the tip toward the pin until the iron touches the pin. You should see the solder melt and flow toward the IC pin. Repeat 99 more times!
You do not need to apply any solder - it is already on the Schmartboard!
Inspect the solder connections with the loupe.
The rest is easy!
Step 20: Connect the Processor to the Main PCB
Using either approach, cut the rows of pins to fit the holes on the main PCB (not the Schmartboard – there are more holes on that than we need). Both the inner and outer rows must be filled. If you are using the male and female pins, it does not matter which end is up – as long as you are consistent. After you have cut the rows of pins, squeeze the male and female parts together and put them into the holes on the main PCB.
Don’t solder yet.
Making sure the main PCB and Schmartboard are aligned correctly (the lettering is facing 'up' on both boards), work the pins into the Schmartboard. Also be sure to align the pins correctly to the Schmartboard. They should be in the outer row of holes and the inner rows of holes. It is easy to get the off by a row - see pictures.
Using a wider solder tip (1.6mm or similar), solder the pins to the Schmartboard. Keeping the two boards together, flip the boards and solder the 100 pins to the main PCB.
Step 21: Remaining Components on the PCB
Add the 16MHz Crystal. It can be mounted flat or bent 90 degrees. The Eagle template was for a larger (taller) device.
Add the (2) 20pF disk capacitors and the .1uF disk capacitor.
Add the Power Regulator and then the 10uF electrolytic capacitors to the power section. Note the white line/bar on the capacitors indicated the negative lead. The positive (+) leads are labeled on the PCB.
Add the (3) 100 ohm resistors for the indicator LEDs (Heartbeat, Soothing Mode and DS1307 Error) and the 220 ohm resistor for the power Indicator. Note the resistor for the power LED is in the row of resistors for the LED Matrix. I changed it to a 220 ohm at the last minute – it was too bright with a 100 ohm.
The bending tool I found was a handy addition for doing lots of resistors in a very consistent manner - I found it at Evil Mad Scientist (http://shop.evilmadscientist.com/) for $5.00.
Add the (32) 220 ohm resistors.
Add the AVR ISP port (2x3 pins), the power selector jumper (1x3) and the RTC connector. Note you will have to cut (1) of the pins from the board side of the connector of the RTC connector - only (4) pins are used.
Input Power Jumper - if you are powering the PCB with a regulated 5V supply, add a jumper across the top (2) pins (indicated by 'Use 5V' on the PCB). This bypasses the Power Regulator. If you are using a wall wart or other power supply above 5V move the jumper to the lower (2) pins to use the Power Regulator.
Add the Power and Indicator LEDs. Use Red for Power. The color of the Indicator LEDs is your choice. Here is how they are used by the software - Heartbeat is flashed every 500 interrupts - just shows the microcontroller is running. Soothing Mode - Indicates the program has been running for an extended time period - the program adjust to display only the soothing patterns. RTC Error - indicates the RTC module is either missing, the battery is dead or there is another problem getting the date and time. I used Green for the Heartbeat; Blue for Soothing Mode and Yellow for any RTC Error.
Add the (2) Molex plugs for power and the screw terminal for the switch. If you do not want to use a separate switch, just add a wire jumper or solder a wire across the pads on the PCB.
Add the (8) IC sockets - be sure to align the notches to match the PCB.
Add the (10) pin cable connector sockets - be sure to align them according to the PCB - they are polarized.
Finally press the ICs into the correct sockets:
ULN2803As go in PORT H, PORT J, PORT K, and PORT L
MIC2981s go in PORT A, PORTC, PORT E/G and PORT F
Be sure to align the index mark on the IC with the indention on the socket.
This completes the second major part of the project!
Step 22: Power Up!
Step 23: Programming the Atmega2560
We need a way to communicate with the Atmega2560 so we can configure and program it. My favorite programmer is the USBTiny from AdatFruit. The application that works with this programmer is AVRDude.
Link for USBTiny - http://www.adafruit.com/products/46
Download AVRDude - http://www.ladyada.net/learn/avr/setup-win.html
Tutorial for AVRDude - http://www.ladyada.net/learn/avr/avrdude.html
Before we are showing off our new LED Matrix, we need to do two things to the Atmega2560. First, we need to configure the chip by setting a 2 Fuses. Then we need to load our software program into the Atmega's memory. The USBTiny and AVRDude can handle both of these tasks.
Step 24: Connecting the USBTiny to the PCB
These are Windows-style instructions, you may have to adjust to your environment. In a CMD window enter:
avrdude -p m2560 -c usbtiny
If things are working correctly, you should see a brief response with a Device Signature that indicates the Atmega is the correct one and the initial fuses are good.
If you get the rc=-1 error code, you may need to pull the USB cable from the PC, wait a couple seconds and reconnect it. Try the command again.
If you are still having problems, try the Ladyada USBTiny FAQ / Troubleshooting site:
Step 25: Setting the Fuses
If you want to cut to the chase here are the commands to set lower (lfuse) and upper (hfuse) fuses:
avrdude -p m2560 -c usbtiny -U lfuse:w:0xff:m
avrdude -p m2560 -c usbtiny -U hfuse:w:0x99:m
The ATmega2560 has (3) fuse bytes - Low, High and Extended. We are only making changes to the Low and High bytes. These fuses configure various parameters that determine how the Atmega will perform. For example, we have to set a bit to allow the Atmega to use an external high speed crystal oscillator.
If you set these wrong in some cases, you cannot recover. For example, if you disable the reset button, you can't re-program it. If you select the wrong clock source, it might not boot at all.
For further reading - here is the datasheet on the Atmega2560: http://www.atmel.com/images/doc2549.pdf
Here is another good explanation on fuses: http://www.ladyada.net/learn/avr/fuses.html
Step 26: Testing the Matrix and Loading the Animations
It also checks the DS 1307 and the Heartbeat LED on the PCB. If the RTC is not working, the RTC Status LED will be turned ON. The Heartbeat LED should blink.
Use the AVRDude for programming:
avrdude -p m2560 -c usbtiny -B 1 -U flash:w:32x32_test.hex
If everything is correct, your LED matrix should start displaying the test patterns immediately. My first attempt showed (3) errors - I had a partial row of LEDs that would not light. This turned out to be a bad / broken solder joint on the LED matrix. The other two were a little more difficult to track down and fix. I had a cold solder connections on the pins in the Schmartboard. Not the Atmega chip legs but the pins connecting it to the main PCB.
When you have a working matrix, it is time for the real fun - loading the animations. The firmware is programmed using the same procedure as with the test code.
avrdude -p m2560 -c usbtiny -B 1 -U flash:w:32x32.hex
Since the program also uses EEPROM memory, we also need to load that code segment.
avrdude -c usbtiny -p m32 -B 1 -U eeprom:w:32x32.eep
Your 32x32 Matrix should start running through the animations as soon as the firmware is loaded.
Step 27: Software Annimations
All On – Mostly used for test routines
All Off – Used between animations
Horiz 1 – Run LEDs from Left to Right then Top to Bottom
Horiz 2 – Run LEDs from Right to Left then Top to Bottom
Horiz 3 – Run LEDs from Top to Bottom then Left to Right
Horiz 4 – Run LEDs from Bottom to Top then Left to Right
Lissajous – Mathematical formulas for the Lissajous patterns. Generates 8 sub patterns based on parameters
Spriograph - Mathematical formulas for different Spirograph patterns. Generates 21 sub patterns based on parameters.
Rain – LEDs ‘raining’ down – starts slow, then builds to heavy rain then slows
Snake – Pattern running through the matrix
In Out – Patterns running in and out in rings of LEDs. Combinations on leaving the LEDs and progressing in and out.
Random1 – Slowly turn on more and more LEDs until all are on, they slowly turn them all off.
Random2 – Turn LEDs on and off in a random fashion
Random3 – Turn on a few LEDs, then using a ‘sweep’ action, turn them off
Text Writer – Routines to create and scroll text across the matrix. Random messages are displayed
Scroll clock – Routines to interact with DS1307 RTC and display the current date and time
Diagnal1 – Turn LEDs on and off in a diagonal fashion – Top Left to Bottom Right – half panel
Diagnal2 - Turn LEDs on and off in a diagonal fashion – Top Right to Bottom Left – half panel
Diagnal3 - Turn LEDs on and off filling full matrix. Full panel
Sweeper – Rotating line of LEDs from corner to corner
Sweeper2 – Rotation starting in center moving clockwise for 360 degrees
Arrow1 – Solid arrows of LEDs moving Up, Down, Left and Right – in then out
Arrow2 – Random spaced arrows of LEDs moving Up, Down, Left and Right.
Spinner – Math function using sin and cos functions
Circles – Generate circles of progressive radiuses.
Fireworks – Randomly generate fireworks that include the launch, explosion and showers of sparks.
Block Fill - Squares of either 2x2 or 4x4 that move about the matrix in a random pattern filling the Matrix. The progression continues until the Matrix is completely ‘on’ or no more moves are possible.
Blocks – Blocks of 4x4 LEDs that move around the Matrix but only to an ‘open’ (LEDs are off) space.
Fingers - create a finger-like pattern followed by a checker-board like pattern