Connect with us

Amateur Question About Digital I/O

Discussion in 'General Electronics Discussion' started by MidAmTech, Sep 9, 2011.

Scroll to continue with content
  1. MidAmTech

    MidAmTech

    7
    0
    Sep 9, 2011
    I have a pretty amateur question about Digital I/O. If I have a device that contains so many digitial I/O pins, say 32, it is relatively easy to get this device to control simple circuits. For example, how difficult would it be to get this device to control so many LED's using the digital i/o?

    EDIT: Side note, the LED's will use an outside power source so I am simply wanting the device to act as the switch through the DIO.
     
  2. MidAmTech

    MidAmTech

    7
    0
    Sep 9, 2011
    Not meaning to double post but I believe I just answered my own question. Mods can delete this thread if they would like.
     
  3. daddles

    daddles

    443
    3
    Jun 10, 2011
    In general, it's probably very easy. For example, with a PIC microprocessor, you'd just connect one of the digital output pins to an LED directly (with a suitable resistor). The only issue is that you have to worry about sourcing or sinking a finite amount of current up to the specified value for the chip. For example, if you decide to run each LED at 10 mA, you probably couldn't run 30 LEDs that way from the microcontroller because that would require sourcing or sinking 300 mA of current, which would probably exceed the allowed current level for the whole chip. Since you have an external source for the LEDs' power, then you'd just use the digital IO outputs to e.g. switch a small signal transistor to turn the LED on and off.
     
  4. MidAmTech

    MidAmTech

    7
    0
    Sep 9, 2011
    Thanks for the reply. That's what I was thinking I would do. Use the digital IO to control either transistor or a mechanical relay.
     
  5. daddles

    daddles

    443
    3
    Jun 10, 2011
    Just remember that typical microcontroller IO pins can source or sink around 20 mA of current (read the data sheet for the actual number). If you use a relay, you'll have to find one that operates within that current bound.
     
  6. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,359
    2,755
    Jan 21, 2010
    Or use a transistor to switch the heavier load (the coil of the relay)

    Also, don't forget the need to place a reverse biased diode across the relay coil to absorb the inductive spike generated when the power to the relay coil is removed.
     
  7. MidAmTech

    MidAmTech

    7
    0
    Sep 9, 2011
    Thank you guys for all of your help. I have actually found that the IC's digital I/O isn't powerful enough to drive a cost-effective relay. I have decided to try to stick with transistors to drive the larger load. Cost is a major factor because each individual circuit could have upwards of thirty individual transistors. So I have started building a prototype and I am running into an issue. I have uploaded a circuit diagram for you guys to look at, I apologize if its a little difficult to read, the design and theory portions aren't my strong suits.

    For a simple explanation, the larger power source is to drive the individual LEDs and the microcontroller will be sending signals to the transistors to get the LEDs to flash at any interval and in any order. The issue I am running into is that I am getting errant current in the circuit that causes the other LED's to flash dimly with the target LED flashing at full brightness. Again, I can build them but I'm not an expert at the theory so can anyone tell me either a) whats causing this or b) how to fix it or both?

    Again, thanks for all of your help thus far.
     

    Attached Files:

  8. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,359
    2,755
    Jan 21, 2010
    Why is that diode there? It effectively means that the transistors are never turned hard off.

    Removing it is the obvious solution unless it's there for some purpose.
     
  9. MidAmTech

    MidAmTech

    7
    0
    Sep 9, 2011
    It was there as a preliminary precaution because I have to use both the 12V and the Controllers Ground as Common. I mean, I am not confident enough to build a circuit like this on my own without that precaution, but I suppose it does make sense. I'll try removing it and see where that gets me.
     
  10. Resqueline

    Resqueline

    2,848
    2
    Jul 31, 2009
    That circuit won't work no matter what. It's seriously flawed and may even fry your controller. Are the outputs of the "open collector" type?
    How is the 12V supply relative to the 3.3V supply, are they independent or do they share a common "ground" (0V)?
     
  11. MidAmTech

    MidAmTech

    7
    0
    Sep 9, 2011
    Yes, I am worried that the circuit is flawed which is why I am looking on this forum for some advice as to how it can be fixed....

    The 12V and the 3.3V have independent grounds which is why I am worried I cant use a transistor because it appears the transistor has to share a common ground between the load and the base. I think I am getting the errant current on the other LEDs because I am trying to override this.

    Maybe the best thing for me now is to describe my situation and the desired outcome and maybe you guys can give me some ideas as to how I can connect the two. I have a controller that has 3.3 volt digital outputs and I need these outputs to control a 12-24V circuit. Keeping in mind that this is only a momentary pulse, whats the best way to get the controller's digital output to act as a switch for this 12-24V circuit?

    I understand I may not have the expertise in this subject to accomplish what I want on my own, which is why I came here. With that said, any help is appreciated and any criticism is taken rather humbly... But help is more appreciated.
     
  12. Resqueline

    Resqueline

    2,848
    2
    Jul 31, 2009
    Just didn't want you to increase the risk of damage to your controller.
    Since the power supplies are completely independent (floating) you are at liberty of connecting them however you like.
    What is too often referenced to as "ground" is often nothing more than 0V (or the negative), which is something entirely else than real ground.
    Provided mains ground is not connected through to their negative outputs - you can connect the +3.3V and the +12V together, and leave their "grounds" separate, .
    Alternatively, if you were to use NPN transistors instead of PNP's then the power supply negatives would be connected together instead.
    Notice how the circuits are identical except for power supply and semiconductor polarities.
     

    Attached Files:

    Last edited: Oct 1, 2011
  13. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,359
    2,755
    Jan 21, 2010
    You are so right...

    I saw what I expected to see, not what was there.

    (which doesn't make the diode any less wrong...)
     
  14. MidAmTech

    MidAmTech

    7
    0
    Sep 9, 2011
    Resqueline, thanks a lot for the help. That's my biggest fear is burning up the controller. I'll try working with the NPN transistors and go from there.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-