Shop OBEX P1 Docs P2 Docs Learn Events
LED Bar Graph Controls — Parallax Forums

LED Bar Graph Controls

tigershark35tigershark35 Posts: 60
edited 2006-09-19 02:21 in BASIC Stamp
Hi.. I have a project where two stamps will talk to each other - control in one direction and telemetry back.· I want to take voltage readings from the remote unit (possibly 2-3 batteries) and send that back to the control panel. I can get the voltage digitized to feed serially back to the control unit, but I want to use separate bar graph LEDs to show the status of the voltage. I will need to take the digital value and use it to drive the LED Bar graph. I need a source for info on where I can get some LEDs as well as how to drive them.

Thanks.
JG

Post Edited (tigershark35) : 9/8/2006 2:25:57 AM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-08 02:32
    Best is to look at the on-line catalogs of companies like Jameco, Mouser, and Digi-Key. They all carry a wide range of electronics parts, have a web-based order system, take small orders, and give good service. Their on-line catalogs have pretty good descriptions and links to datasheets with details. There are certainly 10 LED bar graph devices in various colors. These can be driven directly by a Stamp or indirectly via a shift register if you want to save on I/O pins. What information specifically do you need about driving the LEDs?
  • tigershark35tigershark35 Posts: 60
    edited 2006-09-08 02:54
    \Thanks. If I read an analog voltage on the remote unit I think I have seen enough to build a ciruit to A/D the info for the stamp to send serially to the control end. At the control end, how do I convert that to drive the bar graph (segmented) LED. Basically there would be a decimal number from the remote end that I want to represent on the control end. What is that process, what driver or converter is needed, etc.

    JG
  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-08 04:28
    You probably would use a LOOKDOWN statement using the decimal value for the lookup. Read the description in the PBasic manual to see how to use this to find a match to the closest value in the value list. The LOOKDOWN statement would provide an index that you'd use to indicate the last LED to be lit. You can use this index in a LOOKUP statement to give a bitmask showing which LEDs to light. This way, you can even do a logarithmic bar graph if you want. For example, if you have a value from 0 to 32767, you could do a power of 2 bar graph (10 LED) like this:
      LOOKDOWN value, <[noparse][[/noparse]32,64,128,256,512,1024,2048,4096,8192,16384,32768],index
      LOOKUP index,[noparse][[/noparse]$000,$001,$003,$007,$00F,$01F,$03F,$07F,$0FF,$1FF,$3FF],result
      OUTL = result.lowbyte
      OUT8 = result.bit8
      OUT9 = result.bit9
    
    


    This assumes that "value" and "result" are both words and "index" is a byte (or nibble). "value" and "result" can be the same
    word if you don't need the input value for anything else. Pins 0 through 9 are connected to the anodes of the bar graph LEDS through appropriate current limiting resistors and the cathodes are connected to ground. This assumes that setting pins 0 through 9 high will turn on the LEDs. If not, you can change the values in the LOOKUP statement. Pin 0 is the lowest value LED. Pins 0 through 9 are set to OUTPUT during the program initialization.

    Post Edited (Mike Green) : 9/8/2006 4:34:15 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-09-08 17:35
    Hello,

    ·· There is code in the Stamp Works 2 manual for driving·a DOT/BAR Graph directly from the BASIC Stamp (Experiment #5).· This manual is available as a free download from our website in PDF format.· I hope this helps.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • tigershark35tigershark35 Posts: 60
    edited 2006-09-09 01:39
    Thanks Chris. I have seen that.· Do you know of any "driver chips" that I could us so as not to have to use so many pins on the stamp - as I may have up to 3 bargraphs to drive separately.



    Jim
  • KatyBriKatyBri Posts: 171
    edited 2006-09-09 02:12
    When ordering from JAMECO and DIGIKEY- a couple of things to keep in mind.

    JAMECO now charges for shippig depending on where your parts are shiped from. If all comes from one place-one shipping charge. If from several distribution locations- you will receive individual shiping charges for each-check carefully before committing.

    DIGIKEY has a larger selection and good on-line chat; whereas, JAMECO might be less expensive on some items. Best to do comarative shopping. Hope this helps.
  • willthiswork89willthiswork89 Posts: 359
    edited 2006-09-09 03:36
    I Have a 10 Segment bar graph from radio shack Item Number 276-081 its a 20 pin DIP Package go ahead and look at it on thier store i think i payed a dollar somthing for it?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Learn somthing about everything, and Everthing about somthing-
  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-09 05:33
    The Microchip MCP23S17 is a 16 bit I/O expander that's easy to use and can drive 20ma per pin. It uses an SPI serial interface which uses 3 Stamp I/O pins and the SHIFTIN/SHIFTOUT commands for communication. Two devices require a total of 4 pins (2 are shared). There's an I2C version (MCP23017) that only needs 2 I/O pins and works with the I2C commands of the BS2p/pe/px if you have that. Another I2C version (MCP23016) is a little simpler to use, but doesn't come in an SPI version.

    I thought of some other solutions like a plain shift register, but those don't usually have the ability to drive an LED at more than 6-10ma. If that's enough for you, that would be a cheaper, simpler solution (like the 74HC595).
  • RDL2004RDL2004 Posts: 2,554
    edited 2006-09-09 10:59
    KatyBri said...
    When ordering from JAMECO and DIGIKEY- a couple of things to keep in mind.

    JAMECO now charges for shippig depending on where your parts are shiped from. If all comes from one place-one shipping charge. If from several distribution locations- you will receive individual shiping charges for each-check carefully before committing.

    DIGIKEY has a larger selection and good on-line chat; whereas, JAMECO might be less expensive on some items. Best to do comarative shopping. Hope this helps.

    Yes, a lot of what Jameco now "stocks" is actually shipped direct from the manufacturer. A small order could easily have multiple shipping charges that exceed the actual value of the items ordered. Shipping charges for online purchases can be a killer.

    I would like to add Mouser as a recommended place to buy parts. You only pay actual shipping costs, and there is no handling charge and no minimum order. They are very hobbyist friendly in this regard. They ship same day almost every time and there is no additional shipping charge if an item is back-ordered and ships at a later date. Also, if you make a purchase from them, you will start to receive their free 2 inch thick catalog in the mail, every 90 days [noparse]:)[/noparse]

    - Rick
  • KatyBriKatyBri Posts: 171
    edited 2006-09-09 13:42
    Thanks Rick. I'll definately check out Mouser.

    One point I failed to mention in my original note is we should always check the Parallax web site. They often times have competative pricing on items and we should support them first if possible. They provide us with so much free support, we should support them whenever possible.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-09-09 23:24
    The 74HC595 is what I use on my Binary clocks...That would be what I would recommend...even 3 of them only use 3 I/O pins from the BASIC Stamp.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • tigershark35tigershark35 Posts: 60
    edited 2006-09-10 00:22
    Thanks Chris. That looks like it would work. I assume that this would control an 8 segment led just fine.



    JG
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-09-10 01:33
    Yes, the 74HC595 will control 8 outputs...Daisy chaining them doesn't require anymore I/O pins, only one byte of variable space for each value.· The interesting thing is you can daisy chain 3 or 4 of these on the same I/O pins, but none of them need to even have related functions.· In the case of my Binary Clocks, they're serving different functions, but I just change the values in the variables I want to update and shift them all out.· The only ones you "see" change are the ones that have different values.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • tigershark35tigershark35 Posts: 60
    edited 2006-09-19 02:01
    Hi Chris.

    Do you have some sample circuits using the 74HC595 or the expander that you mentioned earlier in this thread?

    Thanks
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-09-19 02:21
    Hello,

    ·· The Binary Digital Clock can be found at the first link...A PDF copy of the Stamp Works 2 manual can be found at the bottom of the second link.· Take care.

    http://forums.parallax.com/showthread.php?p=552892

    http://www.parallax.com/detail.asp?product_id=27220

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.