Shop OBEX P1 Docs P2 Docs Learn Events
Pins and LEDs (hopefully this is a stupid question) — Parallax Forums

Pins and LEDs (hopefully this is a stupid question)

firestorm.v1firestorm.v1 Posts: 94
edited 2007-05-20 05:03 in BASIC Stamp
One more post, then I promise I'll shut up.

I am going to be designing a series of circuits for my BS2 that i can plug into the breadboard and have it show me via LEDs what the pin states are. If this works, I'll post a schematic and pictures as this might be really useful for some, myself included. :P


I'm thinking that something like this should work:

Vdd
(resistor)--LED--(data pin)---(LED)---resistor---Vss
+
^v^v^--|>|
()
|<|
^v^v^v----Vss
LED 0 LED 1

The idea being if the pin is HIGH, that the LED 1 will light, LED0 will be off, and that if the pin is LOW, the LED0 will light, and LED1 will be off. If the pin is floating or not bound, both LEDs will be off.

Does anyone else see a problem with this, assuming that the resistors are of correct value to prohibit blowing the IO pin or the LEDs?

Thanks yet again!
«1

Comments

  • WynandWynand Posts: 39
    edited 2007-05-15 19:21
    I think it will work. Looks like something nifty to have around if you do not have an osciloscope or logic probe.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Why didn't I think of THAT!!!!
  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-15 19:37
    The only problem with this is that the LEDs draw power, perhaps as much as 10-20ma depending on the value of the series resistors and there's a limit on the amount of total I/O current that the Stamp can handle. If you're going to be using more than a couple of these, you should get some quad, hex, or octal buffers to drive the LEDs and use a separate +5V regulator for the LEDs.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-05-15 20:55
    You have the low side LED pointing the wrong direction, for the LED to illuminate the pin would have to be < -Vf of the LED which is impossible, but to reverse it would mean both would be illuminated with pin set to input. Here is an article of a circuit which does work: http://www.elecdesign.com/Articles/Index.cfm?AD=1&ArticleID=1683·and another which has 3 circuits: http://www.edn.com/index.asp?layout=article&articleid=CA6262537

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-15 21:46
    Well nuts, it was a good idea at the time.. :P So now I have 10 red and 10 green SMD LEDs along with a bag of goodies from electronics goldmine. At the least I can build half the circuit for detecting pulses out or pins HIGH..

    Thanks again for your help, Back to the ol' drawing board and rolling pennies for parts.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-05-15 23:06
    If you look at the first article I posted, it shows how to do it with only an additional resistor.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-16 01:53
    That's weird, when I initially pulled the figures up in the first article, it was loading an ad about some kind of test tool. I looked a seccond time a few minutes ago and everything came up. That's exactly what I was looking for! Thanks a million for the point in the right direction and the swift kick to get me there.. Now to calculate some resistor values and find some resistors.

    I have been wanting to learn more about TTL and electronics components in general. I'm also thinking about getting an SX development kit so I can start learning assembly as well.

    One concern is that the formulas involved ask a lot about the SMD LEDs I don't know, like minimum and maximum voltages for visible light/no visible light. Am I correct in guessing that the forward voltage for both LEDs would be +5v? What do yall recommend as far as electronics online courses that I could pursue for learning circuit design?
  • metron9metron9 Posts: 1,100
    edited 2007-05-16 05:15
    "What do yall recommend as far as electronics online courses that I could pursue for learning circuit design?"
    I would recommend doing the projects page by page in the "What is a micro controller" book available free in the downloads section.
    I started with a radio shack electronics kit and made circuits from the manuals using all of the major components you would typically use in a circuit.
    Learn hands on what each of the components can do.
    Buy "The Art of Electronics"

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-05-16 17:49
    Those adds you see are frequently done by free online electronics magazines, it's thier way of paying for thier service.

    V1 through V4 are typically pulled from datasheets, since you bought them surplus this may not be an option for you, in which case you will need to test this yourself.

    Since they are surface mount you will need to make contact with each side to do the test, you can dead bug it (solder bits of wire to each side), or if it is large enough you could solder it between a couple header pins.

    If you have a bench top supply, you can use it in current mode and adjust it's current where it is just off (for V1 and V2 measurement) then increase it until it reaches a reasonable brightness (for V3 and V4 measurement). If you bench top is digital you can grab these measurements straight from the Voltage display, else use a multimenter to record the voltage across the LED.

    If you dont have a bench top supply you'll need to get a 10K linear potentiometer, preferably the multi-turn screw adjust kind and place it in series with the LED and a voltage supply (like the VDD output of the Stamp). Start off with the highest setting for the potentiometer and adjust it down until the LED just starts to light then back down to just off. Now use a multimeter to record the voltage across the LED this is your V1/V2 measurement. Now continue to adjust the potentioment until it iluminates to a reasonable brightness and record the voltage across the LED again, this is your V3/V4 measurement (also called Vf or forward voltage drop).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 5/16/2007 5:54:22 PM GMT
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-16 18:12
    I bow before you oh great master of the electron!

    It just so happens that Fortune has smiled at me, I ordered a bunch of 10K pots for LCD displays that I already have. Unfortunately, I don't have a digital benchtop supply like you describe, but I do have a lot of regulated computer power supplies. I am hoping that will work just as well. If not, then I will use the stamp's Vdd per your suggestion.

    If I am understanding you correctly, (thanks for your patience BTW) the V1, V3 measurements are in front of the LED, and V2, V4 are after the LED?

    Ex: (Vdd)
    10kpot---(V1/V3)---|>|----(V2/V4)
    (Vss)

    I'm also going to re-do some of the exercises in the WAM book, apparently it's been longer than I remember since I've done some of the exercises. Specifically ohm's law, etc.. :P


    Thanks again!!
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-05-16 18:17
    The voltages are all with the node between the pot and diode·ane your·negative probe at Vss. V1 and V3 are for the first diode you are going to use in the circuit and V2 and V4 are for the second. If you are using the same type of diode for both V1=V2 and V3=V4. V1 is the highest voltage across the first diode with it still being off and V3 is the voltage across it while its on, V2 and V4 have the same relationship with the second diode.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-16 23:19
    Oh, duh.. :P I misread that at the same time I was re-doing the Ohm's Law section in the WAM book. That makes a lot of sense after I re-read the articles. I printed them out, as soon as I get the parts I hope to have a working model soon. [noparse]:)[/noparse] I'll post schematics and details once I get the thing tested and built.

    The 20mA sink / 25mA source limitation on the IO pins, is that per pin or across the entire device?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-05-17 00:15
    Per pin, but you cant do that on every pin. There is a per pin limit and a entire chip limit and the number of I/Os times the first is much much greater than the later. Use a buffer or inverter if you need more current capability.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-17 01:26
    My plan was to build a bank of 8 of these LED devices (for working with LCD displays). Since I don't have the LEDs yet, I don't know what the resistor values will be. I did the Ohm's Law section of the book, and understand now how to figure out how many mA a single LED tester will draw. Do you know where I could find the device limitations to ensure I don't damage the BS? If I use an inverter instead, will the inverter be supplying the current or will the BS2 still be doing it?

    I do have a couple of questions about the Ohm's law section of the book, but it's probably more common sense that hasn't just clicked in yet and would appreciate clarification (assuming I haven't chased you away with my odd questions)

    1: on Page 320: it says that if I have multiple LEDs on P0-P7 that I need to use "bigger resistors" so that I don't draw too much current, I am assuming that means higher in ohms rating, like 1k instead of 440, etc...

    2:On page 321, the book mentions "Diode Forward Voltage". The value associated with that term is "1.6V" Was that value obtained from the LED manufacturer or is that a known constant? I tried this on my homework board using the green LED and a 470 ohm resistor and got some different values. My Vdd shows as 4.97VDC, when I put the meter on each side of the resistor, it shows 2.988VDC and on the LED shows 2.005VDC. Is that correct?

    3: On page 325 figure F4, it says that the total current for this device is 14.5mA, Doesn't the LED also draw current?

    Thank you for your insight and suggestions, It's definately making more sense. [noparse]:)[/noparse]
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-05-17 05:08
    Yes, each setof 8 pins can source 20mA, that can be a single pin or split among them. A higher resistor value reduces the current on any particular pin.

    Each color of LED is a different semiconductor, each semiconductor has a different band gap value. For Gallium Arsenide (red) it's 1.6V, for green it's a different value, as you've noted its around 2V, blues have even higher band gap voltage. The diode forward voltage is the band gap value when it starts to conduct and will raise slightly higher at higher currents.

    A current of 7.23 mA is flowing through each LED, hence 14.5 mA is flowing from the I/O pin since it must supply 7.23 mA to each LED (the currents add).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-17 11:43
    Ok, so it would appear that I'm understanding this more than I'm giving myself credit for.. [noparse]:)[/noparse]

    Given that information about the LEDs, it sounds like with 4 LEDs would be over the 20mA limit, and that would be disasterous. [noparse]:([/noparse] If I used an inverter would the inverter supply the current for one of the LEDs? Would using a pair of transistors or an optoisolator work for moving where the current is supplied from?

    If push comes to shove, at the very least, it looks like I can make a poor man's logic probe and use that for one or two pins at a time. I guess we will find out when the parts get here in a few days..

    Thanks again for the information, I'm learning a ton more than I initially thought I would and I'm getting more and more excited about making other projects with the BS2.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-05-17 16:29
    Yes the inverter would provide the supply to the LEDs, transistors and optoisolators are overkill for this situation.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-17 17:09
    Excellent, now I just got to get my hands on an 8 channel inverter chip and I can proceed without fear of damaging my BS2. I guess I can make some 2-lead 2-color LEDs by taking the two SMD LEDS and turning one backwards. Speaking of volts and stuff, where can I find the max limit of the regulator that is built into the BS2 homework board? I want to make sure I'm not in jeopardy of blowing that too.

    On another note, I just checked the electronics goldmine site, and they shipped my order. So it's only a matter of time now. Now to find an inverter or 2.. [noparse]:)[/noparse]
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-05-17 22:20
    Just use a couple 74HC04. Which variety of stamp do you have, the vanilla BS2? What board are you using and what is the value of your Vin?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-18 07:57
    I have the BS2 homework board, It saya Rev "B" in the upper right hand corner, (serial port facing away from you, component side up. No parts today, but I'm hopeful for tomorrow. [noparse]:)[/noparse]
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-05-18 21:54
    Hmm that's not good, you only have a margin of 45mA to do anything with the on-board regulator, which is about 2 LEDs worth of current. You'll need to supply a second supply or get another board capable of supplying more current to added circuitry.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-19 01:46
    well nuts.. Hmm, for the time being, does it matter if the +5v comes from a computer power supply vs a 9v battery w/a 5v regulator (which is what I'm eventually going with.

    Looks like I'm going way above and beyond here with what was initially a simple circuit. What I might do then is have a self-contained 9V power supply that goes into a regulator, then to the inverters/LEDs, etc. Do you think that this is still a cool project to merit this work?

    So checklist for this project: 74HC04 inverter (2) some manner of 5v regulator with a 9vdc input.. I already have the LEDs and the PCB headers for plugging into the breadboard.

    Does Dallas or fairchild make regulators?
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-19 02:23
    Stupid question, using the inverter circuit if the IO pin goes high, won't the LED be directly driven off that?

    My concern is that if I create a tester 8 pin or 10 pin wide and all pins go high, the inverters won't kick in because they aren't turned on and the BS2 will then be driving all 10 leds and poof!....

    On the upside I'm looking for a good 5v output voltage regulator that I can use where I don't have to make a monster-sized heatsink.. [noparse]:)[/noparse]
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-05-19 02:42
    You could use this: http://www.parallax.com/detail.asp?product_id=601-00506

    So are you using different colors or the same color for the 2 LEDs of each circuit?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 5/19/2007 2:47:17 AM GMT
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-19 03:42
    The search has begun looking for an inverter and I think I found one however it says it's CMOS, not TTL. Does that matter? I thought that the TTL was 0-5vDC and that CMOS was a lot less. The DC output current per pin is 25mA and should be more than adequate for my needs, wouldn't you agree? This is the link for the inverter: http://www.fairchildsemi.com/pf/MM/MM74HC04.html

    As far as a regulator goes, shouldn't a 1A regulator definately have enough current available to drive the LEDs? I found this one: http://www.fairchildsemi.com/pf/KA/KA7805E.html The only question is output voltage. I know that +5v is the ideal voltage, but the regulator puts out between 4.5 and 5.5, Would that be a problem or is that still within the +5v tolerance?

    This is getting even more exciting with every post! I can't wait to get the parts and start putting this together!
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-19 04:06
    I have green LEDs for logic high, and red LEDs for logic low.

    Now for a really stupid question, does Parallax have a minimum order? I thought they had $100 minimum but it would appear that is for PO orders only. Are you aware of a minimum for single-person orders? I might be able to get fairchild to send me some samples for the inverter, but the regulator is made by Nat Semi and they don't do samples. I would rather Parallax get my money if I have to pay for it rather than Nat Semi charging me a monster fee for a single regulator.. Although, if a lot of people like this idea, I might start building kits.. [noparse]:)[/noparse]
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-05-19 05:18
    OK ive put some more thought into this and the circuit won't work with the inverters because they aren't tri-state and there would never be the off condition.

    There is no minimum order w/ Parallax.

    I haven't fully grasped what you are attempting, are you creating an I/O indicator for BS2 applications under development?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 5/19/2007 5:30:16 AM GMT
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-19 05:50
    What would I need to do to get that "off condition"? Would adding a "sense" I/O lead help? (like if that IO pin isn't set high by the BS2 then the tester waits to take its measurments?) It would add a line of code to whatever program is being written, but if that's all it takes than that sounds like a simple addition (a single AND gate or transistor located just after the regulator?)

    That's pretty much the gist of what I was hoping to achieve. If I had the money I would replace teh homework board with a BOE-Bot along with the USB Logic Analyzer and the USB o-scope for debugging and learning more. I had the bizarre desire to take a Netburner and figure out how to do some home automation with that and some BS2s, but that's some high-dollar stuff that might be better off being done with a SX chip. I think my next major purchase will be the Programming SX Plus kit on the website.

    Heh, stating that there's no minimum order with Parallax is a very dangerous thing.. I wonder if I can convince my wife that we don't need a grocery budget for the next four months.. :P J/K, I have been seriously considering biting the bullet and enrolling in some EE courses at the local college here in town. It's more than just a fascination with me I want to be able to do both ends of the electronic jungle, build hardware to perform certain tasks, then write the software that makes the hardware do that task.

    You have helped me so much with this project and I was hoping that we could have gotten this to work. I genuinely appreciate the efforts that you and the other commenters have put into this. Thank you.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-05-19 06:05
    How important is the off state to you, was your intent with the off state to show when the line is set to input?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-19 06:30
    I'm not concerned with the off state to be honest, I intended only to be using this device to test IO pins that are set for output only (for working with LCDs, or making a SEROUT command is going to the correct pin, etc...) Ideally, I won't be connecting this device to any pin that I'm not actively working with. Would the off-state damage the BS2 if this device is connected to a pin that is in INPUT mode?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-05-19 23:10
    No it wouldn't be damaging. Ok I have another circuit for you which would work:
                  Inverter            |\
    I/O pin -+--| >O-----+
             |  |/       |
             |   D1  R1  |
             +--|<|-^v^--+
             |           |
             +--|>|-^v^--+
                 D2  R2
     
     
     
     
    

    Again the inverter will be powered by a seperate regulator, D1 will light when the I/O pin is low and D2 will light when the I/O pin is high. R1 sets the brightness of D1 and R2 sets the·brightness of D2. I looked at the·74HC04 and it cant provide enough current for all six, let me look at other logic·families to see whats better at delivering power (likely LS or ACT).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.