Shop OBEX P1 Docs P2 Docs Learn Events
Using BASIC Stamp To Control A Board with 215 LEDs — Parallax Forums

Using BASIC Stamp To Control A Board with 215 LEDs

Hobbes24Hobbes24 Posts: 2
edited 2009-12-01 17:41 in BASIC Stamp
Hello, I'm a complete beginner with micro controllers but I am more than willing to learn. This is the general gist of what I want to accomplish.

I run a campground with 215 sites. I want to build a project where an LED is tied to each of those sites and the map is connected directly to the computer. I will be running a program in the background that queries the database every few seconds and updates which LEDs should be turned on or off depending on whether a site is occupied or not. I have all the computer programming stuff down pat, but I have a lot to learn about how to tie in the hardware part.

My question revolves around just what I need to do for the hardware side of things. I want to use a USB cable to connect my map to my computer. I believe I need a micro controller to act as an interface between the computer and the LED's I want to turn on. The project needs to control about 215 LED lights, each one connected to a site.

I welcome any advice or links people will give me to help me achieve what I want to do. Please take it easy on me - I'm still learning my way around these things.

Thank you in advance for your assistance.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-13 18:14
    1) You could use the same USB connection that you would use for programming. A USB Board of Education has a USB socket on it. When it's plugged into a PC, that connection can be used for downloading a program to the Stamp and it can be used for data sent back and forth. On the PC end, it looks like any other serial port and you can use any programming language or tool that handles serial communications ports.

    2) In terms of controlling that many LEDs, it would probably be easiest to use either a string of TI TPIC6595 or a combination of a 74HC595 plus a ULN2803. In both cases, you get 8 bits of outputs plus a power driver to handle the current from all the LEDs. You can string these end to end (logically) to any length although you need to add some buffering if you have much more than 8-12 of these in a string. Each string requires 3 or 4 I/O pins to control. In your case, I'd suggest using 3 strings of 10. This would leave some room for expansion in the future. The PC would simply send to the Stamp the number of the LED to turn on or off or a code to turn them all off (for initialization). Since these would not be changed frequently, you could store the values of these 30 bytes (240 bits) in the EEPROM using the READ and WRITE statements (whenever the bits change) since there's not quite enough room in the Stamp's variables to store that much data. Every time there's a change, the Stamp would have to send out the bytes for the string that's changed and update the LEDs that way.

    I believe there are examples of the use of a 74HC595 (the TPIC6595 works the same) in the Basic Analog and Digital tutorial and I think in the StampWorks Manual. Both are downloadable from Parallax's website. There are also Nuts and Volts Columns on the subject of expanding Stamp I/O. Both are reachable by clicking on the Resources tab on the main Parallax webpage. For the tutorials, select Downloads, then Stamps in Class Downloads.
  • dandreaedandreae Posts: 1,375
    edited 2009-08-13 22:07
    There were some examples of using the MAX7219 or MAX7221 and they can control up to 60 discreet LEDs.· You may have to Google it for more information.

    Dave




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Parallax Tech Support·
  • maxx233maxx233 Posts: 11
    edited 2009-08-13 22:56
    Personally, I'd just program this in a high level PC language, and have it display fullscreen on a monitor as your map. Could make it look much nicer, probably easier, and you're already going to be using the computer element anyway because you'll have to have a DB involved as you've stated. But then, I'm new at this too and coming from a computer programming background [noparse];)[/noparse]
  • Steve2381Steve2381 Posts: 94
    edited 2009-08-15 21:21
    Hi. I used the Max7219 display driver for the keypad leds on my alarm clock project. Found it worked really well and you wouldn't need that many to run 215 leds - only 4 in theory.
    Had the advantage that you could also dim them from the software.
    All you need then is a decent aerial shot off google earth!!
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-08-16 02:34
    If you decide to use MAX7219 I can send you some basic code for it.
    Good luck.
  • dev/nulldev/null Posts: 381
    edited 2009-08-16 10:06
    vaclav please post the Basic code.

    Mike, I am just curious. If you use ULN2803, how would you connect it? It seems you would need a ULN23803 fore each 595?
    Wouldn't a single ULN2803 run a lot more than 215 LEDs with regards to current? A LED typically draws 3mA of current, and the UL8203 can source 500mA on each output.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-16 18:34
    dev/null
    Yes, you would need a ULN2803 for each 74HC595. I'm thinking more in terms of fairly bright LEDs drawing on the order of 20mA each. If you were just lighting a few of the 215 at a time, you could drive the LEDs directly from the 74HC595s, but there's a maximum total current capacity for the 74HC595. If you really were using only 3mA per LED, you could light several of them directly from the 74HC595. Sure the ULN2803 is "overkill", but the whole display could be lit up brightly and you'd still be ok. You could use discrete cheap switching transistors. You'd need two resistors, a 2N2222A or equivalent, and the LED for each of 215 places.

    The MAX7219 or MAX7221 is not a bad choice. You'd need 4 of them and the LEDs would be multiplexed, but it takes care of the details of that for you.
  • dev/nulldev/null Posts: 381
    edited 2009-08-16 19:51
    Ok, I was just wondering. The ULN is not a bad choice... they are about 30 cents each. I see that the 74HC595 has about 25mA max for each output, but the total for Vcc or Gnd is only 70 mA, so you are stuck, and need the driver unless you are running very dim LEDs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
  • Hobbes24Hobbes24 Posts: 2
    edited 2009-12-01 05:00
    Thank you everyone for your responses. I have actually printed out this thread and am doing some research in the matter.

    Personally, because I've never done anything like this before and I actually have a goal, I am enjoying the process.

    Being that this is for a campground, each LED will represent a site, so if the campground is full every light on the board will be turned on simulatneously.

    Mike, I like your idea of using a the 74HC595 with a chain of ULN2803, because of the reason I stated above. I'm not currently to the level where I can completely understand how to use those chips, but the more information I get, the more I start to understand what I'm trying to do.

    Currently I'm using the "What's A Microcontroller" book I picked up at Radioshack to learn the basics of the BASIC Stamp system. Because my background is in computer programming, I really enjoy the syntax that BASIC Stamp uses. It's much easier to comprehend than assembly instructions.

    After I finish the "What's A Microcontroller" lessons, I'm wondering what I should hit next, in order to learn what I need to achieve my goal. I'm considering buying the Stampworks Experiment Kit and going from there. I'm hoping by the time I'm done with those experiments, I should understand a lot more than I do now.

    Any advice or suggestions are welcome and encouraged.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-01 07:23
    TI has a nice chip that combines a 74HC595 and an MOSFET equivalent to the ULN2803. It's the TPIC6595. Look it up on TI's website for a datasheet.
  • allanlane5allanlane5 Posts: 3,815
    edited 2009-12-01 17:41
    The Max7219 will probably solve the problem for you while using less current. 215 LED's at about 15 mA each continuous is 3.225 amps -- you're going to need either one large 5 amp supply or several 1.5 amp wall-wart supplies.· Oh, wait -- you want both red AND green LED's?

    Personally, I'd build an initial prototype using 16 LED's, probably one prototype using the 595's with 2803's, then another prototype with a Max7219, just to make sure I have the concepts working. And yes, you'll probably want an external eeprom (26L32 or so) to store the bit-settings -- after a million writes an eeprom will wear out, and having it be external makes it easily replaceable.

    It's probably true that this would be more easily implemented as a GUI using Visual Basic .NET though.

    Oh, and a "typical" LED does take 10 to 15 mA to fully illuminate.· "Low-Current" LED's will work on 3 to 5 mA, but they can be hard to find.

    Post Edited (allanlane5) : 12/1/2009 5:46:29 PM GMT
Sign In or Register to comment.