Maker Pro
Maker Pro

Amateur Question About Digital I/O

MidAmTech

Sep 9, 2011
7
Joined
Sep 9, 2011
Messages
7
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.
 

MidAmTech

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

daddles

Jun 10, 2011
443
Joined
Jun 10, 2011
Messages
443
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.
 

MidAmTech

Sep 9, 2011
7
Joined
Sep 9, 2011
Messages
7
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.
 

daddles

Jun 10, 2011
443
Joined
Jun 10, 2011
Messages
443
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.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
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.
 

MidAmTech

Sep 9, 2011
7
Joined
Sep 9, 2011
Messages
7
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.
 

Attachments

  • circuit.png
    circuit.png
    26.5 KB · Views: 136

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
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.
 

MidAmTech

Sep 9, 2011
7
Joined
Sep 9, 2011
Messages
7
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.
 

Resqueline

Jul 31, 2009
2,848
Joined
Jul 31, 2009
Messages
2,848
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)?
 

MidAmTech

Sep 9, 2011
7
Joined
Sep 9, 2011
Messages
7
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.
 

Resqueline

Jul 31, 2009
2,848
Joined
Jul 31, 2009
Messages
2,848
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.
 

Attachments

  • circuit a.GIF
    circuit a.GIF
    7.1 KB · Views: 94
  • circuit b.GIF
    circuit b.GIF
    7.2 KB · Views: 107
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
That circuit won't work no matter what. It's seriously flawed and may even fry your controller

You are so right...

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

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

MidAmTech

Sep 9, 2011
7
Joined
Sep 9, 2011
Messages
7
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.
 
Top