Building a Scrolling Marquee Stock Ticker - Page 1
Forum section: electronics / beginners

author: gohangasalamimalasagnahog
author_rank: Newbie
timestamp: June 08, 2011, 06:45:30 pm
content: I am starting a new project making an LED matrix scrolling marquee Stock Ticker for my house. I plan on using pegboard and about 250 bi-color (red-green) LEDs to make a marquee that is 5 x 50 (not 100% set on the dimensions). I already wrote most of the code that scrapes the internet for stock prices for stocks in my portfolio every 10 min, converts the string of text I want to display into a matrix of 1’s and 0’s, and sends that to an arduino that will be controlling this display. I want stock symbols to be displayed in orange (red+green), stocks that are down for the day to be displayed in red, and stocks that are up displayed in green. Hopefully it will look something like this:(the finished display will scroll through many stocks and start back at the beginning when it goes through all of them on an infinite loop)My problem is that I am new to electronics engineering and I’m not sure what the best way is to build the hardware. Below is my current idea with some questions in square braces. Any help or advice I could get from the community would be great.The 5 x 50 matrix will be broken up into about 5 different segments. each 5 x 10 segment will be run by an ATtiny88. Because these micros are cheap and have 24 IO pins, i can buy many of them and each can use 4 pins for SPI communication with the arduino (to update what it will be displaying) and the other 20 pins can be used to run the 5 x 10 bi-color matrix. 10 pins will be used to ground the columns, 5 pins for the Red rows, and 5 pins for the Green rows. The arduino will take care of shifting the displayed message down one pixel every 10th of a second (or however long i decide) and sending out the new matrix to be displayed to each individual ATtiny88.[will this work? is it a problem using all of the i/o pins? do i have to worry about the speed of SPI and how long it takes to update each ATtiny88? The micro runs at 8Mhz, but can run at 12Mhz with an external crystal because i'm running it at 5v. is it worth buying external crystals? do i need them?]Each smaller matrix will be a self contained unit consisting of an ATtiny88, an LM7805 for +5v and 50 bi-color LEDs. there will be a +12v power rail and ground rail along the top of the pegboard so each 5x10 matrix unit will only need 6 wires coming into it: 2 wires for power to the rails and 4 wires for SPI communication.[with the exception of some caps, resistors, and wire to connect the LED matrix, am i missing anything needed?]Lastly, I'm asking for your opinions:[Is there anything you would do differently? i'm trying to make this as cheap as possible, any suggestions for keeping costs down? the only bi-color LEDs i could find are water clear. what should i use as a diffuser? i can use i2c instead of SPI. Which is better? why? what are the differences? what other advice do you have for a newcomer to the hobby?]Thanks,Adam

author: sacherjj
author_rank: Frequent Contributor
timestamp: June 08, 2011, 07:24:22 pm
content: For $2 a pop for the ATTiny48s, I would just go for 1 ATMega640 with 84 IO pins. That would make polling much easier and cost about the same as all the ATTiny48s. I would also change the board to 48 wide, so you can pack it in to an even 30 bytes per color. This will probably have enough time left over to do all the processing you need.I would make sure all the characters you will want fit into 5 dots high. Look at existing displays. You won't lose any speed for the display update until you get past 8 bits high. As you will most likely store the display in bytes aligned with the LED columns, so you can just push those to a single port. So realistically, you will have 96 bytes for each board state. You can then use a rolling memory. Have a pointer to the start of memory and then overwrite the old row getting pushed off the end of the board with the new column of data. Your pointer will just be a counter that goes back to 0 after 47 and is added to the base memory location for the data.

author: Time
author_rank: Frequent Contributor
timestamp: June 08, 2011, 07:30:19 pm
content: lol is that forum name for real?

author: gohangasalamimalasagnahog
author_rank: Newbie
timestamp: June 08, 2011, 07:40:34 pm
content: the ATMega640 doesn't come in a DIP package. i guess i could make a breakout board to make wiring easy. is there some sort of pre-made solution to this? also, i'm not sure what the power ratings are for the ATmega640, but it's possible for my display to have 100 (or 96) LEDs on at one time (all Red and Green in one row) theoretically... at 20mA/LED that's 2 Amps going through the Vcc pin... i'm pretty sure it can't handle that.[Or can it? it would be great if it could]And as for my forum name, it's a palindrome. "Go Hang A Salami, I'm A Lasagna Hog." without spaces, it's one letter too long, so i got rid of one of the "i" in the middle, this way it's still a palindrome.

author: gohangasalamimalasagnahog
author_rank: Newbie
timestamp: June 08, 2011, 08:01:17 pm
content: the ATmega640 Vcc and GND pins are only rated to 200mA. i think the 2A theoretical maximum is overkill, but 1A is almost possible and that's 5 times the limit of this microcontroller.

author: gohangasalamimalasagnahog
author_rank: Newbie
timestamp: June 08, 2011, 08:09:49 pm
content: Just gave this some more thought: If i pulse the columns on instead of the rows, the maximum number of LEDs on at once is only 10 (5 Red and 5 Green) which falls just within the 200mA max of the ATMega640. My concern with this is that now instead of flashing 5 rows on and off, i would be flashing 50 (or 48) columns. would persistence of vision become an issue at that point? would the display look too dim if it did work?

author: sacherjj
author_rank: Frequent Contributor
timestamp: June 08, 2011, 08:21:18 pm
content: You will be powering a maximum of 5 LED elements at a time. You will have to set the correct bit for the columns then do a write for RED and a write for GREEN, 48 times. I doubt you would have a persistence problem on a 20 MHz chip.The advantage of a block design is easier expandability. In fact, I bet you can find modules pre made that do this sort of thing. If you limit this to marquee and never want other animation, you can limit the data update to serial shifting in 2 bytes for the next column. These would just populate your rolling array.As far as the breakout board. Learn Eagle and jump on the DorkBotPDX order. You will thank yourself for it. You can also design a board for the LEDs and get 10 made from iTeadstudios for $45. I assume under 4" wide per unit is good enough. It is worth the money not having to hand wire up hundreds of LEDs. I've done that once and never will again.

author: Rufus
author_rank: Super Contributor
timestamp: June 09, 2011, 12:55:11 am
content: You should search ebay for LED MATRIX.You will be able to buy an LED matrix with drivers, shift registers and column decode for probably less than you can buy the parts. An arduino (which I know nothing about) will likely be able to drive the matrix directly, all you need is to do is connect it up, provide a power supply and package it.If you insist on DIY you should look at what you can buy anyway to see how it is done.An 8:1 or 16:1 multiplexed drive for rows and long shift register with latches for driving columns is pretty much standard.

author: sacherjj
author_rank: Frequent Contributor
timestamp: June 09, 2011, 01:25:41 am
content: That is a great idea. Something like this might be the thing:http://cgi.ebay.com/LED-Display-panel-dot-matrix-64x16-LDP-6416-/220727186834?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item33645d9592

author: gohangasalamimalasagnahog
author_rank: Newbie
timestamp: June 09, 2011, 07:27:22 pm
content: Thanks for all the replysSome of the reasons i want to do this myself instead of buying pre-made displays include:1) I'm still trying to learn about electronics. I'm okay with this taking me a little longer, or not being as polished if i learn a lot from the process.2) I want this display to be pretty big. i planned on using pegboard, which at 48 LEDs wide, will be 4 feet long (holes are 1 inch apart).sorry measurements are imperial, i live in the US and we haven't yet seen the light that is the metric system. i think it's about 1.25 meters.I was only planning on the display being 5 LEDs high because i already wrote come C++ code to convert plain text into a font 5 pixels high. i could always write another program with a larger font. Also, if i'm using ATtiny 48/88 chips then it works out well that they can drive a 5x10 matrix each.my origan plan was to drive everything with an arduino, a bunch of shift registers daisy-chained for the columns, and 5 transistors to sink the rows. I don't think an ATMega168 could fill 12 or 14 shift registers (half for the Red matrix, half for the Green), pulse the row on, and repeat fast enough though.Can someone address some of the other questions i posed in my original post as well?

author: tsmz
author_rank: Contributor
timestamp: June 10, 2011, 03:39:02 am
content: QuoteThat's quit easy. Just do a quick calculation to see if it's totally unrealistic or do-able.We're setting flicker-free to 100 Hz here, you could probably do with much less than that, though. With 100 Hz refresh rate for the whole display, rows need to be loaded with 500 Hz. Pushing 384 values into shift registers in 2 ms or less is no big deal for an AVR running at 16 MHz and could even be done with really slow hand-written code. Clever usage of peripherals will speed this up immensely.If you want more flexibility, you could go for SPI or I2C-connected port expanders. They're more expensive than shift registers, but can be controlled individually and thus offer a much more flexible design. However, you do have lots and lots of performance to burn, so if cost is of primary concern, go for shift registers.

author: gohangasalamimalasagnahog
author_rank: Newbie
timestamp: June 10, 2011, 08:24:11 pm
content: If i do go the shift register route, does anyone have suggestions for what transistors to use to sink the rows? i'm not very familiar with the differences between types of transistors, i just know it will have to be able to sink at least 1A.

author: sacherjj
author_rank: Frequent Contributor
timestamp: June 10, 2011, 11:24:42 pm
content: Just search for logic level MOSFETs. You will fine many that can handle an amp quite easily. Don't get too powerful as the higher power the MOSFET, the more the gate capacitance will be. This will require slower switching or more power to switch.

author: tsmz
author_rank: Contributor
timestamp: June 11, 2011, 12:07:31 am
content: I think it's best to first make some rough calculations and then start selecting components. Interesting aspects here include:1) How many LEDs per row are there?2) How much current can a shift register supply a) on each pin b) for all pins together?3) How quick do you need to switch?4) What voltage are you using for running the thing (most likely 3 or 5 Volts)?5) Are there other special requirements?Depending on your requirements, you could start with some nice and cheap logic level MOSFETs or even "normal" transistors. But maybe it's better to use a dedicated driver IC, which depends on your needs. Another option would be to use one transistor per column per shift register, so you'd only have to switch a maximum of 8 LEDs at a time, but I don't know about the effects on the circuit such a scheme can have. I guess it shouldn't be a problem at low frequencies, but if you really want to know it, try to decipher it from the datasheets (I can't) or ask someone who knows.

author: gohangasalamimalasagnahog
author_rank: Newbie
timestamp: June 16, 2011, 06:20:13 pm
content: Ok, i have decided to go the modular route using ATtiny 48/88 micros. daisy-chaining 12 shift registers just doesn't sound as much fun and i like the future flexibility of it being modular... I do plan on ending up with a practical, aesthetically pleasing, awesomely cool project, but designing and building it will be half the fun.I don't mind writing new code if my display is going to be taller, but because the ATtiny chips only have 24 IO pins (and i need 4 for data transmission), it will reduce the number of columns each can control. at 5 pixels high, each can run 10 columns which was a nice round number... Then I realized that they also are capable of i2c, so that would give me an extra 2 pins to work with. Here is a maximum number of columns that can be run as a function of matrix height (for a bi-color matrix on 22 IO pins):Height Columns/micro5 126 107 88 79 610 6I know 8 high is common, so it should be easy to find a font to use for that. Is there a real benefit to making the display 6 or 8 pixels high? what would you recommend seeing as i would need an extra 20% - 40% more micro controllers (and power regulators, resistor, caps, etc) which adds to cost and repetitiveness of the build (albeit not that much)?Also, should i get external crystals to run the micro controllers at 16Mhz?

author: sacherjj
author_rank: Frequent Contributor
timestamp: June 16, 2011, 07:06:26 pm
content: The biggest thing with making your modules multiples of 8 is just the structure of data in the micros. 50 is not a round number. You will be wasting 6 bits for each color per module. You are using 15 pins for a 10x5 with 50 LEDs. For 15 pins, you could use an 8x7, making 56 LEDs and not wasting any bits. This makes display coding MUCH easier.Think of how you will have to output the 10x5. This is pretty messy when calculating which pixel is on:Code:B1 B2 B3 B4 B6B1 B2 B3 B4 B6B1 B2 B3 B5 B6B1 B2 B3 B5 B6B1 B2 B4 B5 B6B1 B2 B4 B5 B6B1 B3 B4 B5 B6B1 B3 B4 B5 B6B2 B3 B4 B5 B7B2 B3 B4 B5 B7Compared to:Code:B1 B2 B3 B4 B5 B6 B7B1 B2 B3 B4 B5 B6 B7B1 B2 B3 B4 B5 B6 B7B1 B2 B3 B4 B5 B6 B7B1 B2 B3 B4 B5 B6 B7B1 B2 B3 B4 B5 B6 B7B1 B2 B3 B4 B5 B6 B7B1 B2 B3 B4 B5 B6 B7Now your I2C code can be "Shift once to the left and replace with these two bytes." Viola, your scrolling is done.

author: gohangasalamimalasagnahog
author_rank: Newbie
timestamp: June 17, 2011, 02:42:59 pm
content: Okay, I've been convinced, 8 high it is. After playing around with it, I actually like the way it looks. This is just going to be much larger than i originally planned. Using 9 ATtiny88's, it will be 8 x 63:Using pegboard, which has holes spaced 1 inch apart, this will be about 8.5" x 5' 4.5" (0.21m x 1.6m)Does anybody know: do i need the external crystals for the micro controllers?

author: sacherjj
author_rank: Frequent Contributor
timestamp: June 17, 2011, 03:07:17 pm
content: You would probably be fine using the internal 8 MHz calibrated oscillator on the ATTiny88.

author: Tony R
author_rank: Regular Contributor
timestamp: June 18, 2011, 11:50:17 pm
content: I have just finished doing a very similar project.my project used an C8051f340 from Silicon Labs our array was 7 by 50 of only one color (green) LEDswe where able to use 2 I/O ports for the display using scanning. each column was on for a very brief period of time as it scanned across. which is how the dot matrix units work. we where able to do this with only one MCU.we used 1 I/O port to control what column was on we used the other IO to control what LED's where on in that column. The MCU outputted a column number (0-49) which caused the demultiplexers turn on only one column, which went into some octal inverting buffer drivers and then into some NPN transistors and finally to the columns of the display.next the rows where controlled using another port which outputted a pattern that needed to be lit for the column. but not before going into some open collector logic. we initial tried it with non open collector logic but it caused our display to do some wired stuff.each letter was 7 by 5 on our display.Often times external crystals are needed when communicating to other devices by serial but not always.

author: Rufus
author_rank: Super Contributor
timestamp: June 19, 2011, 05:03:41 am
content: Quote from: Tony R on June 18, 2011, 11:50:17 pmI finished a similar project about 15 years ago. It used a Dallas DS80C320 at 25MHz (6.25 MIPS) and multiplexed an 8 x 960 bi-color LED array at 2ms per row (62.5Hz refresh) and did 4 way scrolling and some other fancy transitional effects.It multiplexed rows and used shift registers to drive columns. That was the way to do it 15 years ago and it still is except now you can buy chips like the MAX6979 designed for the job.