Shop OBEX P1 Docs P2 Docs Learn Events
Controlling a Common Anode 7-segment LED display using a Stamp? — Parallax Forums

Controlling a Common Anode 7-segment LED display using a Stamp?

conceptconcept Posts: 12
edited 2010-02-14 12:49 in BASIC Stamp
Is it possible to control a Common Anode 7-segment LED display using a Stamp? I guess more specifically, how would I go about doing this? Would sending LOW signals to each pin that is connected to a corresponding LED mimic the effect of grounding that specific LED?

Curious about this, thanks.

Comments

  • $WMc%$WMc% Posts: 1,884
    edited 2010-02-13 02:42
    concept

    Take a look in the StampWorks Manuel. Pg. 60 Experiment #8. Its on the Parallax web site, Store page, And then StampWorks.

    I'll go and find the link and post here. This new found love for the 7seg display has become quiet a topic.

    http://www.parallax.com/Portals/0/Downloads/docs/books/sw/Web-SW-v2.1.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA

    Post Edited ($WMc%) : 2/13/2010 2:50:16 AM GMT
  • conceptconcept Posts: 12
    edited 2010-02-13 18:40
    That's intended for a Common Cathode 7-segment LED. I've already tried reversing the input/output values with that code with no effect. The segments I have connected already are lighted, and when it loops through the code it just makes them brighter. They do not turn off.

    Post Edited (concept) : 2/13/2010 6:49:32 PM GMT
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-02-13 18:48
    Yes, concept, your assumption is correct.· Don't forget a resistor for each LED and that "0" (LOW)·= On and "1" (HIGH) = Off.
  • $WMc%$WMc% Posts: 1,884
    edited 2010-02-13 18:49
    concept

    You need to invert the DATA statments for common anode.

    "Digit0 DATA %11000000" instead of "Digit0 DATA %00111111"

    don't forget to invert the commons as well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
  • conceptconcept Posts: 12
    edited 2010-02-13 18:50
    PJ Allen said...
    Yes, concept, your assumption is correct. Don't forget a resistor for each LED and that "0" (LOW) = On and "1" (HIGH) = Off.

    This does not work for me.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-13 18:52
    The only difference between a common cathode and a common anode display is that the diodes' polarity is reversed. Whatever part of the display would be connected to ground gets connected to Vdd and vice versa. Whatever I/O pins get set high with the common cathode version get set low with the common anode version and vice versa. Any tables of 0/1 values for turning on/off segments get inverted so zeros become ones and vice versa. The code and schematics in the StampWorks manual should work fine with these changes.
  • conceptconcept Posts: 12
    edited 2010-02-13 18:52
    $WMc% said...
    concept

    You need to invert the DATA statments for common anode.

    "Digit0 DATA %11000000" instead of "Digit0 DATA %00111111"

    don't forget to invert the commons as well.

    Like I've said, I've tried this already with no effect. I'm a bit stumped.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-13 18:55
    Draw a schematic of what you have (not what you think you have ... check the drawing against the wiring) and attach it to a message. Attach your current program's source file to the message as well. You get the attachment manager by clicking on the Post Reply button.

    What all of us have described does work. Without a schematic and a source file, we can't tell where what you have differs from what we've described.
  • conceptconcept Posts: 12
    edited 2010-02-13 19:07
    ' {$stamp bs2}
    ' {$pbasic 2.5}
    
    do
    low 0
    pause 500
    high 0
    pause 500
    loop
    
  • conceptconcept Posts: 12
    edited 2010-02-13 19:08
    The 1k resistor will definitely cut the current a lot more than what the suggested resistor would, but it shouldn't be producing the problems I am having, should it?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-13 19:21
    Part of your problem is that you have one end of the LED connected to Vin. If you want to use Vin, you will need a switching transistor driven by the Stamp. If you don't want to bother with a switching transistor, use Vdd to power the LED(s) and use a smaller resistor value (like 470 Ohms).

    When the Stamp pin goes high, it gets set to roughly 4.7V. Depending on the Vin voltage, that won't turn off the LED. When the Stamp pin goes low, it gets set to roughly 0.3V and that will turn on the LED brighter than when it's high. That's the behavior you're describing.

    For a discussion of the use of switching transistors, go to the main Parallax webpage and click on the Resources tab. You'll see a link to the Nuts and Volts Columns index. Go there and select column #6.
  • $WMc%$WMc% Posts: 1,884
    edited 2010-02-13 19:29
    concept

    Use the Vdd PIN.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
  • conceptconcept Posts: 12
    edited 2010-02-13 19:34
    Thanks Mike. I'll need to pick up some smaller resistors. The reason I used VIN was because I only had 1k resistors lying around.
  • $WMc%$WMc% Posts: 1,884
    edited 2010-02-13 20:24
    concept

    Take a look at ohms law. If you parallel 2 - 1K resisters You Will have 500 ohms, close enough to 470 ohms for this project.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
  • conceptconcept Posts: 12
    edited 2010-02-13 23:57
    Thanks $WMc%, I did not think of that. I have a new problem, however... with a 500 ohm resistance and 5v supply I cannot get any LED in any portion of the segments to light up.
  • $WMc%$WMc% Posts: 1,884
    edited 2010-02-14 00:15
    concept

    Disconnect the display from the stamp. Next connect the common anode to Vdd. Now through the 500 ohm resister connect the Vss to A,B,C,D,E,F,G,and DP pins on the display one at a time.

    Buy this I mean apply power to "A" on the display with a 500ohm resister to limit current. Does it light. If so try pin "B" on the display.

    If some light and some don't ,You have some burnt-out leds. If none will light You may have a 7seg.display with built-in resisters. These displays are rare but their out there.

    Can You find a part#on the displays?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
  • conceptconcept Posts: 12
    edited 2010-02-14 00:17
    I've tried this but it only works through VIN. I've also tried connected 5v directly to the cathodes with no resistors without any result, and trying again with resistors with 5v, and resistors with VIN.

    Through VIN it works, but any 5v supply to the anodes it does not want to light.


    Part # is a Lumex LDS - AD16RI. Good luck finding the Datasheet, I forgot how I found it.


    I also tested a regular LED through the 5v on my homework board with a resistor.. works perfectly, so I don't think it is an issue of a bad voltage regulator on the board or connection to VDD.


    The datasheet circuitry does not show any inboard resistors, there are apparently 4 LED's to each segment though.

    Post Edited (concept) : 2/14/2010 12:28:05 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-14 00:29
    DO NOT connect 5V directly across an LED unless you want to waste it. Without some kind of current limiting, you will burn out an LED that way.

    If things light when you connect the display to Vin (assuming Vin is 6V or higher ... you didn't say), then you don't have a standard common anode 7-segment LED display. Without a datasheet, I don't know what you have and there's no way to advise you how to make it work.
  • $WMc%$WMc% Posts: 1,884
    edited 2010-02-14 00:42
    concept

    I think You have a odd-ball display. I'll run down the part number and see what I can find.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
  • conceptconcept Posts: 12
    edited 2010-02-14 00:43
    Mike Green said...
    DO NOT connect 5V directly across an LED unless you want to waste it. Without some kind of current limiting, you will burn out an LED that way.

    I realize this, but I wanted to give it a shot anyway because I did not understand why it wouldn't light up under 5 volts with a resistor.



    VIN is 6-9 by the way.

    Post Edited (concept) : 2/14/2010 12:54:58 AM GMT
  • conceptconcept Posts: 12
    edited 2010-02-14 00:45
    Here's the datasheet I have, I don't think you're going to be able to find it by googling.
  • $WMc%$WMc% Posts: 1,884
    edited 2010-02-14 00:58
    concept

    ·Heres the spec sheet (below). Its not very helpful.

    It says 5volt and not 4.7 to drive the leds

    I think the level shifting transistors are needed for Your project like Mr. Green spoke of earlier to make your display work.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
  • conceptconcept Posts: 12
    edited 2010-02-14 01:01
    I thought that was the maximum voltage, not minimum? Either way I think you're right.. transistor time.
  • $WMc%$WMc% Posts: 1,884
    edited 2010-02-14 01:34
    concept

    The data sheet is as clear as Mud. Not very helpful

    Try running My test above but connected to Vin.
    Use a 1Kohm resister to limit current.

    Use a volt meter to read the voltages at the led display.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-14 02:04
    The datasheet actually answers the question of why this doesn't work. This display uses several series LEDs per segment. Four red LEDs in series require a forward voltage of 4 x 1.7V = 6.8V. There's no way this can be directly controlled by a Stamp. You have to use a switching transistor (per segment) to control this display and the minimum supply voltage to light the display would be 6.8V + 0.3V = 7.1V. You'll need some kind of current limiting resistor. The resistance would depend on the supply voltage and the current you want for the LED.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-02-14 12:49
    Agreed.· Yep, it is all (all) there in the datasheet.
    Again, it's another case of "I'm doing everything right and nothing wrong and it doesn't work" --·and then we get the details, the rest of the story.
Sign In or Register to comment.