Author Topic: ATMega328 powered 40x16 LED Matrix project - input wanted  (Read 2071 times)

0 Members and 1 Guest are viewing this topic.

Offline -stewart-Topic starter

  • Newbie
  • Posts: 6
  • Country: no
ATMega328 powered 40x16 LED Matrix project - input wanted
« on: September 09, 2018, 10:06:14 am »
Hi everybody!

I realise I might be a bit cheeky asking for input or help in my first post ever on the EEVBlog Forum, but in my defence I have been following this community for a long time, without taking an active part. First now I am taking the plunge to become an active member. I hope it is OK with you guys and gals!

First a little backstory, I am an electronics engineer, or what in the olden days was called a radio/tv repair guy. (Waaay back in the CRT-times). Hence I got electronics repair experience, but not so much design experience. The project I am taking on now, might be a bit to big, but I think I will be able to cope, someone is helping me with the code for the ATMega, thankfully.

So, to the meat of things;
I am planning to make a box with ten 8x8 LED matrices, configured in a way so they form a 40x16 LED "display". Ie. 2 rows of 5 on top of each other.
I would like the display to show a clock, maybe some "random" patterns, and most important a custom message which can be entered by using a rotary encoder with a built in switch function.
This whole thing is a gift for a 3-year old who loves buttons and already wants to write his, and his mothers, name all over. Hence the custom message bit :)

I come to you, and your collective genius, to hopefully get some good input on my progress with this project. I have come to the stage that I have designed a schematic and drawn up a board with everything I think I'll need, in the order I think it aught to be. Everything is wired according to reference designs in the relevant data-sheets. But before I press go and get a board made up and everything I would like someone to have a look and maybe see some obvious mistakes I have made.
I have drawn the design in Eagle, and can provide the files to people who wish to help. I'll attach images of the schematic here as well as a board layout. I'll also attach the relevant data-sheets.

The circuit consists of a bunch of passives (obviously) but the major players are:
1x ATMega328P - as the brain of things
10x 8x8 LED Matrix (3mm diodes) - making up the display
10x Max7219 - to drive the LEDs
1x DS3231 - RTC to keep time
1x Rotary encoder - to enter messages to be displayed
2x POTs - to control scroll speed and brightness of LED
3x Switches - to toggle a "save" function, switch modes (clock/message/pattern), toggle CAPITAL letters.

I hope to power this off a typical 5V USB adapter/charger. I aim to keep the amp draw low (below 2A at least).
My experience with an microcontroller is low, so I hope I have understood the documentation correctly and wired things sensibly. I am not using the ADC, so I have left the ADC and AREF floating, manybe that is a mistake?
I have used a 40k resistor on the ISET of the Max-chip to limit the current of the output to the LED matrix to around 10-15mA. Is this to conservative? I do not want this to be to bright, and those LEDs at their rated current and FV are bright! Also I am not sure if I have done the layout in a sensible way. The first LED matrix is at the top right of the screen, the last is at the bottom left.

Okay, so it might be easier if I answer questions from this point on, I think..

Hopefully someone can give me some tips and tricks!

Cheerio and thank you for your time!
-Stewart
 


Online djacobow

  • Super Contributor
  • ***
  • Posts: 1151
  • Country: us
  • takin' it apart since the 70's
Re: ATMega328 powered 40x16 LED Matrix project - input wanted
« Reply #2 on: September 09, 2018, 05:12:49 pm »
I think you're not getting much response because this is a pretty straightforward and classic "early board project" and really, any mistakes you make will result in you having to cut traces and add bodge wires rather than, death, explosion, fire. That is, your mistakes will be mostly harmless.

Also, by using the 7219, you're really making the hard part easy.

I did not notice a six pin programming header on this board. If you're going to program an avr, use the standard pinout -- your life will be easier. Make sure you have decoupling caps on power pins, and maybe have some distributed bulk capacitance to help the 7219s. But it will probably work even if you leave it out.

I did a 16x16 clock a couple of years ago, using 74hx595's for rows and columns, with transistors for drive strength. Worked ok, but the isr to scan the display was a bit tricky. With your driver chips you won't have that issue.
 
The following users thanked this post: -stewart-

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: ATMega328 powered 40x16 LED Matrix project - input wanted
« Reply #3 on: September 09, 2018, 05:53:37 pm »
Assuming the LED matrixes can fit flush side by side, it may be worth going up to 12 of them, as that gives 48 columns of LEDs per row and if you use a 5x8 font with one column between characters for spacing, that allows a total of 16 characters.

You are unlikely to get into trouble with the supply current unless you include an inverse mode, due to the low proportion of LEDs that are on.  Worst case each display will draw 8*15mA = 0.12A, which for 10 displays  is 1.2A and 12, 1.44A.   However the inrush current into the large reservoir caps the displays require is likely to be excessive for any USB charger, so you may have to add a soft start circuit.

 
The following users thanked this post: -stewart-

Offline -stewart-Topic starter

  • Newbie
  • Posts: 6
  • Country: no
Re: ATMega328 powered 40x16 LED Matrix project - input wanted
« Reply #4 on: September 09, 2018, 06:28:47 pm »
Thank you djacobow.

What would a standard avr pinout look like? As I said, I have never worked with them before, and to be honest, the datasheet for the 328 is like reading a book :P
I'll add in more decoupling caps. I have some, but I'll add more.

My concern is that I am, say, placing the displays on the board in the wrong order, or maybe that does not matter? Software can fix it?
 

Offline -stewart-Topic starter

  • Newbie
  • Posts: 6
  • Country: no
Re: ATMega328 powered 40x16 LED Matrix project - input wanted
« Reply #5 on: September 09, 2018, 06:33:34 pm »
@ Ian.M.

Yes they can fit side by side, but I do not have room for a 6 of them in a row. It is a tempting thing tho, so I'll look in to if I can fit 6 in a row.
I am not planning to have an inverse mode, so that would not be a problem.

Cheers!
 

Online Siwastaja

  • Super Contributor
  • ***
  • Posts: 8168
  • Country: fi
Re: ATMega328 powered 40x16 LED Matrix project - input wanted
« Reply #6 on: September 09, 2018, 06:37:26 pm »
Thank you djacobow.

What would a standard avr pinout look like? As I said, I have never worked with them before, and to be honest, the datasheet for the 328 is like reading a book :P

https://www.google.com/search?q=avr+isp+6-pin+pinout

It's not in any datasheet - it's just the most common, almost de-facto standard most programming devices happen to use.
 
The following users thanked this post: -stewart-

Offline -stewart-Topic starter

  • Newbie
  • Posts: 6
  • Country: no
Re: ATMega328 powered 40x16 LED Matrix project - input wanted
« Reply #7 on: September 09, 2018, 06:54:27 pm »
Ahh, that explains things..

Would I be able to program the bootloader as well with this 6-pin connection?
I have been following a sort of tutorial on youtube on how to make an Arduino stand-alone, and I copied the system he uses. I can not find the tutorial now tho..
 

Offline Mr. Scram

  • Super Contributor
  • ***
  • Posts: 9810
  • Country: 00
  • Display aficionado
Re: ATMega328 powered 40x16 LED Matrix project - input wanted
« Reply #8 on: September 09, 2018, 07:52:12 pm »
Ahh, that explains things..

Would I be able to program the bootloader as well with this 6-pin connection?
I have been following a sort of tutorial on youtube on how to make an Arduino stand-alone, and I copied the system he uses. I can not find the tutorial now tho..
Yes, you should be able to program the bootloader with an ISP header. Working the pins out is a good way of getting yourself started with the datasheets and available schematics. Programming a chip on your own board the first time is a great feeling.
 

Offline Mr. Scram

  • Super Contributor
  • ***
  • Posts: 9810
  • Country: 00
  • Display aficionado
Re: ATMega328 powered 40x16 LED Matrix project - input wanted
« Reply #9 on: September 09, 2018, 07:53:55 pm »
Assuming the LED matrixes can fit flush side by side, it may be worth going up to 12 of them, as that gives 48 columns of LEDs per row and if you use a 5x8 font with one column between characters for spacing, that allows a total of 16 characters.

You are unlikely to get into trouble with the supply current unless you include an inverse mode, due to the low proportion of LEDs that are on.  Worst case each display will draw 8*15mA = 0.12A, which for 10 displays  is 1.2A and 12, 1.44A.   However the inrush current into the large reservoir caps the displays require is likely to be excessive for any USB charger, so you may have to add a soft start circuit.
What does a soft start circuit entail? Current limiting? Staggered startup? Or can it generically be whatever is suitable?
 

Offline -stewart-Topic starter

  • Newbie
  • Posts: 6
  • Country: no
Re: ATMega328 powered 40x16 LED Matrix project - input wanted
« Reply #10 on: September 09, 2018, 08:59:17 pm »
Cool, I'll look into having a 6-pin header. Now I have one for writing the bootloader, and one for general programming. Easier to just use one.

I would guess a current limiting solution would be the best in this case. No?
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: ATMega328 powered 40x16 LED Matrix project - input wanted
« Reply #11 on: September 09, 2018, 10:11:58 pm »
For this application a soft start circuit to allow capacitors on the board to charge without an excessive current surge or sparking at the USB power connector could be a 3.3 ohm resistor in series with the +5V from the USB Vbus pin, with a P-MOSFET good for at least 3A in parallel with it, source to Vbus, + a 10K pullup from its gate to its source, and a small N-MOSFET controlled by the MCU to pull its gate down to turn it on and bypass the resistor.   The ATmega328P fuse bits for BODLEVEL should be programmed to hold it in reset below 4.3V, so when the MCU comes out of RESET the first thing you code does is wait a short time for the caps to fully charge, then turn on the MOSFET to bypass the 3.3 ohm resistor.  The result is an initial surge limited to 1.5A, with no effect on normal operation once the resistor is bypassed. 

N.B. You *MUST* bypass the resistor before programming any of the MAX7219 chips, (which power up in Shutdown mode) as otherwise the combined LED current would burn-out the resistor and brown-out the MCU.
 
The following users thanked this post: Mr. Scram

Online djacobow

  • Super Contributor
  • ***
  • Posts: 1151
  • Country: us
  • takin' it apart since the 70's
Re: ATMega328 powered 40x16 LED Matrix project - input wanted
« Reply #12 on: September 09, 2018, 10:42:32 pm »
Yes, you should be able to program the bootloader with an ISP header. Working the pins out is a good way of getting yourself started with the datasheets and available schematics. Programming a chip on your own board the first time is a great feeling.

As Scram hints, not being able to program your device at all will ruin your day, so definitely double do-deca-tuple check that you have done the programming header right. Speaking of, do I see that your have a capacitor between the reset pin (PC6) and the reset pullup? That doesn't seem right to me. You want a pullup on reset (actually, it seems to work without it, but) and you might want a capacitor between that and some kind of DTR signal if you want to do Ard style serial programming.

You can program an Arduino bootloader but once you are programming chips using the programming header, you don't need the bootloader, so you can skip it. I can't remember the last time I flashed an Ard bootloader -- and I use AVRs a lot.

As for the order of the 7219's, yes, I guess that's worth a little thought. You can deal with it in SW, but it's nice when things happen neatly. For example, instead of one chain of 10 items, maybe you want 2 chains of 5. That only costs you one more 328 pin and you can update all the 7219's twice as fast -- which may or may not be important to you depending on what sorts of animations you want to do.

Also, unless you really need 16 MHz operation you can leave the xtal and caps out entirely and just use the internal 8 MHz oscillator. Only have as fast and not very accurate, but you're paying for a TCXO in the DS3231 so you've got timekeeping taken care of. The accuracy for the atmega is less important. And you get to use those pins for something.

Just my $0.02.


 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5015
  • Country: ro
  • .
Re: ATMega328 powered 40x16 LED Matrix project - input wanted
« Reply #13 on: September 10, 2018, 02:16:02 am »
My advice would be to experiment a bit with the led drivers .. for example MAX7219 is kinda expensive at around 9$ each (cheaper in quantity), while you can get for example 48 channel led driver chips for around 5$ each, see TLC5955 for example : https://www.digikey.com/product-detail/en/texas-instruments/TLC5955DCAR/296-41090-1-ND/5181351

With 48 channels, you can shift data into the chip and light up 48 leds at one point, and you can use multiplexing to control multiple sets of 48 leds with a single chip

You could have 2 led drivers only, so in total these two would control 2 x 48 = 96 leds , basically a whole horizontal line of your display. Then you simply have to turn on and off whole lines of your display, basically shift 96 bits into your led driver chips (the behave like shift registers), send power to the leds (through a npn transistor or mosfet), wait a few ms, turn off power to the line, shift new data into the led driver chips (next 96 bits), turn power for next line of leds , wait a few ms , repeat until you start with first line.

If you have money or interest, you can of course increase the number of led driver chips, for example use 4 such chips, and light up 2 whole lines at any point...  , or use 6 or 8 chips to light up 3-4 lines at a time....  just keep in mind the total power all your leds will consume (say each led eats 3mA then a single line of your display could consume up to  96 x 3 = ~ 288mA , so with just two whole lines turned on completely  you may hit the 500mA limit of your usb port, if you decide to power it strictly from computer usb ports.
 
shifting whole lines would make more sense, since you'd probably keep in microcontroller memory an array of chars / bytes and just push a bunch of bytes into the led drivers and you're done.

There's also i2c based led drivers like PCA9626b with 24 channels for 4$ each : https://www.digikey.com/product-detail/en/nxp-usa-inc/PCA9626B118/568-4774-1-ND/2076015

You can get 4 or 8 of these or more (up to 126 unique addresses on single i2c bus), set a unique address for each chip and then again you can do multiplexing to your heart's contents ...

ps. for some reason i wrote the whole post above with the idea that you wanted a 80 x 16 led display .. hence why suggesting 2 led driver chips to get 96 leds in a line.  With just 40 x 16, it's even easier.. you could either go with a single 48 led chip per line, or 2 x 24 channel , or 3 x 16 channel drivers per line.... 16 channel drivers are under 1$, like this one for example: https://www.digikey.com/product-detail/en/stmicroelectronics/STP16CPC26XTR/497-11986-1-ND/2772291
« Last Edit: September 10, 2018, 02:21:01 am by mariush »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf