Shop OBEX P1 Docs P2 Docs Learn Events
Advice for control of 12V LED wiring — Parallax Forums

Advice for control of 12V LED wiring

Mark HMark H Posts: 3
edited 2005-07-24 16:30 in BASIC Stamp
I have an existing LED setup·in·my vehicle that is chassis grounded and I·only have access to the +12V power wire input.· There is approximately 20mA running through each wire.··I·am trying to use transistors·as switches for the·Stamp2p to control.· I have to just be missing something simple since it's been awhile since I've studied transistors, but I can't get·anything to work·correctly while trying different circuits on my breadboard.
I have been able to control·LEDs on/off if·I have access to the ground wire, but the chassis ground seems to complicate things.· And rewiring·the existing setup would be 2 days work.· Does anyone know of a solution using transistors?
Specs:
- Must be 12-14V input
- <20-30mA load
- Chassis ground
·
Thank you

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-20 23:07
    Mark,

    ·· I am unclear on your pre-existing wiring situation, but the BASIC Stamp could control an NPN transistor such as the 2N3904/2N2222.· You would simply tie a 1K resistor to the base, connect the emitter to ground, and the negative connection of the LED to the collector.· Is this possible in your setup?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Mark HMark H Posts: 3
    edited 2005-07-20 23:54
    Thank you, but my only problem is the ground. To be clearer, The LEDs are grounded to the chassis at a common point on the vehicle, and every LED is to be controlled separately. They all have separate power wires going into the anode, and then the cathodes are connected together. I would have to rewire the setup for separate ground wires, which would be very time consuming due to the location of them. That is why I'm wondering if I can control them with just the power wire.

    I have done this with transistors while staying at a 5V input, but I need 12V for this setup.
    Thank you
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-21 01:38
    Mark,

    ·· The typical transistor to use in this case would be a PNP transistor, however, for reasons I won't· go into here, that is not practical for TTL level control of the 12V system.· What would be more appropriate would be a MOSFET such as the IRL511.· It could easily handle that type of control, and there are circuits posted not only all over this forum using that device, but Google as well.· Hope that gets you started.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Mark HMark H Posts: 3
    edited 2005-07-21 01:51
    Thanks Chris

    And to correct my above post, I realize that the common ground point would work for the NPN if the LEDs were grounded independently of the chassis. My problem is that at the point where I have access to the ground without taking everything apart, is the chassis ground. This would be cake if I were just building the LED circuit, instead of upgrading it. Thanks
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-21 02:11
    Mark,

    ·· I generalized on the MOSFET use to make it easier...You would need to research that to use a standard N-Channel MOSFET (It could be done).· Typically you would use a P-Channel MOSFET to control a high-side voltage, however this device requires a LOW on the gate to turn it on (Much like a PNP transistor requires a LOW on it's base).· Typically the Gate on the P-Channel MOSFET would be pulled high through a 10K resistor and driven LOW by the BASIC Stamp Module.

    ·· As a side-note, Matt Gilliland's Microcontroller Application Cookbook (Which we sell) contain a lot of circuits like I mentioned above for this very thing.· I find them a good reference for different circuits that I build once in awhile that I have never done, or am looking for a different way to handle.

    ·· One last thing, although expensive, Opto22 makes DC control modules which can switch up to 60VDC from a TTL level control input.· The benefit here is that the Stamp Module is optically isolated from the load.· Personally I would probably use the P-Channel MOSFET or find a compatible circuit using the N-Channel MOSFET, since they're cheaper, more common, and use a high signal to turn them on.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • BobHBobH Posts: 33
    edited 2005-07-21 21:36
    Fairly new to this but for what it's worth you haven't mentioned what is powering the BS2. If it has a power supply seperate from the LED supply be sure to tie the ground wires of the two supplies together.
  • Vern GranerVern Graner Posts: 337
    edited 2005-07-22 00:29
    Mark H said...
    I have an existing LED setup in my vehicle that is chassis grounded and I only have access to the +12V power wire input <snip>

    Ok, it's around 7:30pm, and I'm pretty wiped out from working since 7:30am this am.. smile.gif but, wouldn't you be able to switch the power to the LEDs by running 12vdc to the Collector of the NPN, then running the Emitter to the LED positive, then through the resistor to chassis GND? (see attached schematic). Again, I'm not very alert right now.. in fact.. I think I'll go home after posting this..

    roll.gif

    Vern

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Vern Graner CNE/CNA/SSE    | "If the network is down, then you're
    Senior Systems Engineer    | obviously incompetent so why are we
    Texas Information Services | paying you? Of course,if the network
    http://www.txis.com        | is up, then we obviously don't need
    Austin Office 512 328-8947 | you, so why are we paying you?" ©VLG
    
    
    640 x 537 - 4K
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-22 01:31
    Vern,

    ·· That circuit will not work as listed,·due to the voltages involved.· Let's see if I can remember this correctly...The Base of the transistor needs to be .7V or more in relation to the Emitter on an NPN transistor to turn on.· In this case the voltage of the vehicle is at 12V, while the BS2 is at 5V.· So the output of the BS2 will not be able to attain sufficient voltage relative to the emitter to fully turn on the transistor.· I didn't do the math, so it might work dim, but definately not fully on, and not with 100K for a resistor.· 1K is usually used, but this configuration is incorrect in that sense.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • KenMKenM Posts: 657
    edited 2005-07-22 02:10
    Is the LED actually wired as shown?
    It will never turn on even if you bypassed the transistor and jumped 12 volts directly to the cathode of the LED....the LED is reverse biased.
    With the LED polarity reversed, the circuit will work. It is called an emitter follower.
    To be extra safe, you can install 220 ohms in series between the stamp and the base of the transistor even though it will work fine without the base resistor.....but good to be on the safe side.
    If you are using a 2n3904 and your LED circuit will consume 20 mA, the stamp pin will have to supply a mere fraction of the 20 mA, about 0.2 mA or even less !!



    Ok, it's around 7:30pm, and I'm pretty wiped out from working since 7:30am this am.. smile.gif but, wouldn't you be able to switch the power to the LEDs by running 12vdc to the Collector of the NPN, then running the Emitter to the LED positive, then through the resistor to chassis GND? (see attached schematic). Again, I'm not very alert right now.. in fact.. I think I'll go home after posting this..

    roll.gif

    Vern

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ken

    Post Edited (KenM) : 7/22/2005 2:24:34 AM GMT
  • Vern GranerVern Graner Posts: 337
    edited 2005-07-22 02:16
    KenM said...
    It will never turn on even if you bypassed the transistor and jumped 12 volts directly to the cathode of the LED....the LED is reverse biased.

    Heh.. You're right.. Told you I was tired... lol.gif SOoo, change the 100k to 220ohn, and switch the LED around and I think it should work.. smile.gif

    Vern

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Vern Graner CNE/CNA/SSE    | "If the network is down, then you're
    Senior Systems Engineer    | obviously incompetent so why are we
    Texas Information Services | paying you? Of course,if the network
    http://www.txis.com        | is up, then we obviously don't need
    Austin Office 512 328-8947 | you, so why are we paying you?" ©VLG
    
    
  • KenMKenM Posts: 657
    edited 2005-07-22 02:21
    Vern,

    That will work using a simple 2n3904.....the current limiting resistor should be calculated assuming approximately 4.3 volts total available across the series connection of the LED and Resistor.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ken
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-22 02:57
    Ken, Vern,

    ·· I believe you will find that will not work the way you suspect.· Just to see I just wired up the circuit as you describe...I even used a 220 ohm resistor on the base of the transistor, which I wouldn't normally do anyway, and the 12V LED barely lit.· However, when I wire the circuit as I described it should be, then it works.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • KenMKenM Posts: 657
    edited 2005-07-22 03:01
    Chris,

    What value current limiting resistor did you use? The configuration is common and is called an emitter follower.

    I have sucessfully used it many times.

    An example can be seen in the schematic portion of my SX contest entry ...Comfort Meter.

    http://www.parallax.com/sx/contest/comfort_meter/comfort%20meter%20schematic.bmp

    The 2n2222 is configured as an emitter follower and supplys positive voltage to a seven segment display.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ken

    Post Edited (KenM) : 7/22/2005 3:05:30 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-22 03:03
    Ken,

    ·· As in any typical automotive application, I used a part designed for such an application.· I used both a 12V LED, as well as a 12V automotive lamp.· The reason is that the voltage system in a car can vary greatly, so I tend to stick to devices rated for that application.· The LED has an internal resistor designed for automotive use.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • KenMKenM Posts: 657
    edited 2005-07-22 03:11
    Chris,
    I am not clear how an automotive 12 volt LED internal resistor is any different than an external current limiting resistor.
    An automotive LED with an integral resistor is subjected to the same variance in brightness (current)·as a function of voltage variance, the same as an external current limiting resistor.
    At least that is the way I understand it?
    Is there is some kind of regulator integral to the automotive LED to keep the voltage across the LED-Resistor constant?
    Chris Savage (Parallax) said...

    Ken,

    ·· As in any typical automotive application, I used a part designed for such an application.· I used both a 12V LED, as well as a 12V automotive lamp.· The reason is that the voltage system in a car can vary greatly, so I tend to stick to devices rated for that application.· The LED has an internal resistor designed for automotive use.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ken
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-22 03:15
    Ken,

    ·· The same results were observed with the 12V automotive bulb.· Let me ask you this, have you tried your circuit concept on a 12V system with a 5V system driving the transistor base?· I learned by trial and error at 10 years old that this setup wouldn't work, though it was a few years before it was explained why.· When in doubt on a circuit I wire it up and try it if possible.· This is no exception.· The LED and lamp work fine in the traditional configuration, but they're both dim when using your circuit.· I fail to see why/how it should work based on the voltages being used.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • KenMKenM Posts: 657
    edited 2005-07-22 03:54
    Yes, I have used the setup on a 12 volt system.
    The reason it will not work for you is that the LED/resistor combo is set up for 12 volts, not 4.3 volts.
    When the collector voltage is much higher than the emitter and depending on the load current you must also consider the power dissipation of the transistor.
    out
    Chris Savage (Parallax) said...

    Ken,

    · Let me ask you this, have you tried your circuit concept on a 12V system with a 5V system driving the transistor base?·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ken
  • SPENCESPENCE Posts: 204
    edited 2005-07-22 04:20
    Chris,

    is this not a place where a opto coupler would be appropriate.

    Maybe across emiter to base with a pull up resistor to 12vdc?


    73
    spence
    k4kep
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-22 05:58
    Spence,

    ·· The circuit design above was not my own.· I have actually used an opto-coupler in the past for several automotive applications, but not using an NPN transistor.· Instead we used a PNP transistor.· In that case the base of the PNP transistor was pulled high, and the output of the opto-coupler would pull it low to turn on the light.· Later the circuit was replaced with a MOSFET design, but I can't seem to find the exact part number we used.· I thought it was an IRF or IRL part, but I have so much junk piled around here, that if it weren't for PDF datasheets I'd be in trouble.

    Ken,

    ·· I would be interested in seeing an exact schematic of your circuit, resistor values and all so that I could try it.· You've certainly peaked my interest on this.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-22 14:47
    Ken,

    ·· After sleeping on this whole thing I think I see what point you're trying to make, or rather what you're trying to do.· I am treating the automotive electrical system exactly as I would any other time, as a ~12V system.· My assumption was that the OP was probably using something setup for 12V (Automotive LEDs).· So that's what I used.

    ·· Your circuit assumes using a standard LED with a ~2V forward voltage based on a 5V source (4.3V after the diode inside the transistor).· The OP specified 20mA - 30mA current already running through each wire, leading me to believe that the system was wired for 12V, and if that's the case, your circuit simply will not work, as it will not supply adequate voltage.· But I did want you to know that I do now understand what you're trying to do, but without clarification from the OP as to whether his leads require 12V, we won't know what exactly will work.· From his post he indicates 12-14V, but that may just be referring to the supply voltage, I've kind of gotten lost in translation somewhere.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • KenMKenM Posts: 657
    edited 2005-07-24 05:46
    Chris Savage (Parallax) said...

    Ken,

    ··· I would be interested in seeing an exact schematic of your circuit, resistor values and all so that I could try it.· You've certainly peaked my interest on this.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ken
    755 x 519 - 21K
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-24 16:30
    Ken,

    ·· Thanks for posting.· I do believe that circuit will work on a standard ~2V LED if this could be integrated into the OPs circuit.· Still no clarification from·him though if his LEDs are in fact 12-14V like his original post hints.· I'm still trying to find that schematic we had for automotive use, but still nothing.· I did find the printed ASM code for the controller though (Brings back memories).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.