Speeding up your SPI MAX7219 LED displays when using Arduino and LedControl Library
In preparation for the arrival of my GPSDO, I’m doing a quick build of an “Atomic Clock” display to have above my lab equipment. I’m using a cheap, small eight digit red LED SPI-controlled display. It uses the MAX7219 controller that I got from eBay for next to nothing. I plan to parse the RS232 information from the GPSDO unit and display the exact time. I’ll also post error messages if the GPS signal lock gets lost.
After doing some research, naturally, there was a library available to connect to my LED display called LedControl. It’s part of the standard Arduino libraries (in the download section). But when I checked the code, it uses the Arduino routines to shift out the SPI data to the display. It’s great if you want to be able to use any pins to connect to the screen, but using Arduino’s bit manipulation tools for “bit-banging” the display is slow.
How slow? Well, I modified the code for the library, so it uses hardware SPI instead. Here you can see the difference.
My uneducated guess is something like 40–100x the speed compared to the original code. So if you drive a lot of displays in series and are using the LedControl library, you can speed things up by using my library instead. The only downside is that you need to use the designated hardware SPI pins. You can find the modified hardware SPI version of LedControl here. I’m going to fiddle around a bit and add some more features when I get the time.
- GPS Disciplined Crystal Oscillator, in my case a Trimble with a dual ovenized crystal oscillator. ↩