• AVR Freaks

Hot!HW question - circuit to detect connection of an 12 V LED lamp

Author
02GF74
Senior Member
  • Total Posts : 143
  • Reward points : 0
  • Joined: 2006/11/29 08:25:28
  • Location: 0
  • Status: online
2020/06/30 03:07:54 (permalink)
0

HW question - circuit to detect connection of an 12 V LED lamp

Apologies if not posted in correct section but I have a hardware related question for use with a PIC 12F device.
I need to detect if a 12 volt LED indicator bulb is connected.  I do not know the internal configuration of the bulb but it will have drop resistor and one ore more LED in series.
 
The LED bulb is connected to the base of a PNP transistor, the small current is amplified so that there is a voltage drop across the resistor R, the value of R chosen so that the output is more or less 0.  That's the easy part.
 
When the bulb is connected, it's positive end can be connected to 12 V.
 
The output (emitter of the PNP transistor) is connected to a PIC device but needs to be limited to 5 V which right now I do not know how to do - I have tried using a zener diode from the output to 0 V as well as a NPN transistor but without success.
Instead of using a 12 V supply, I have tried using 5 V but it did to work due to the forward bias voltage of the LEDs.
 
The board space is very restricted.  I need to use the smallest components (through hole T092/resistors) and the minimal amount of them (2 transistors max).
 
Alternative ideas much appreciated.

 
 
#1

16 Replies Related Threads

    ric
    Super Member
    • Total Posts : 27657
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/06/30 03:14:21 (permalink)
    0
    Does the detection have to be on the 12V side, or can it be on the ground side?
    Do you have to detect both when the lamp is lit, and not lit, or is it ok to just detect when it's lit?

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    02GF74
    Senior Member
    • Total Posts : 143
    • Reward points : 0
    • Joined: 2006/11/29 08:25:28
    • Location: 0
    • Status: online
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/06/30 04:08:38 (permalink)
    0
    The purpose of the circuit is to flash indicator bulbs at a constant rate that is independent of load e.g. use 2 x 10 W bulbs, 2 x 23 W bulbs or LED indicator bulbs.  The PIC counts a periodic interrupt to turn on or off a relay.  One end of the relay is connected to the 12 V supply (as stated above it can be more that 12 V).
    The other end of the relay is connected to a switch as shown in the circuit above and below.  When both the switch and relay are closed, power supplied to the bulbs makes them flash.
     
    There is a 'start' signal, a 0 V pulse, that the PIC uses to start the flashing sequence.
     
    The flashing is stopped when the switch is open, i.e. bulbs are disconnected.
     
    The circuit above is to detect when the switch is closed and the bulbs are connected to the circuit.
     
    The 'bulb detect' input to the PIC needs to be is high (5 v) when bulbs are not connected, low (0V) when they are connected.  Note that the signal is also high when bulbs are connected and powered up as it is connected between the relay and the switch.
     
    The PIC controls the relay so reads the 'bulb detect' state only when the relay is open.
    Relevant part of circuit is below (there is a diode to prevent the input to the PIC connecting to 12 V when the relay is closed)

     
     
     
     
     
     
     
     
     
    #3
    ric
    Super Member
    • Total Posts : 27657
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/06/30 04:53:55 (permalink)
    0
    So you have confirmed you don't have access to the ground side of the bulbs.
    Previously, bulb flashers were designed to blink faster with less load, so you could tell if an incandescent bulb had blown. That's all more complicated now LED bulbs are common.
    Also, incandescent bulbs are a nice low resistance when they are cold, so your "WPU" signal would be pulled down close to ground.
    A few high brightness LEDs in series won't pull anywhere near ground, which is why you need to measure a small current from the full 12V supply.
    Does your relay really have an "NC" pin? If yes, you can use that to connect to the LED in the de-energised state to simplify your circuit a bit.
    Looking back at the circuit in your first post, why not add two resistors (in series) from the transistor collector down to ground, and pick values so there will be 5V across the lower resistor when the transistor is on.
    (and zero V when it is off)

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    pcbbc
    Super Member
    • Total Posts : 1700
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: online
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/06/30 05:01:18 (permalink)
    0
    So you are hoping that when the relay is open, and the switch is closed, the weak pull up and the bulbs will form a potential divider?
     
    But with insufficient current through the bulbs (as determined by only a 5V supply and weak WPU) to cause them to illuminate.
     
    Are we expecting that the LED indicator bulbs have built in resistors such that they provide an equivalent load to an incandescent bulb (1.6A to 3.8A @ 12V), or are just plain leds?
     
    I would have thought a P-Channel FET should work?  Source to 5V, Gate to "to PIC", Drain to pic input and pull down?
     
    I might be wrong but I think detecting LED bulbs (without load resistors) may be problematic at 5v.
    post edited by pcbbc - 2020/06/30 05:02:52
    #5
    02GF74
    Senior Member
    • Total Posts : 143
    • Reward points : 0
    • Joined: 2006/11/29 08:25:28
    • Location: 0
    • Status: online
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/06/30 07:30:38 (permalink)
    0
    thanks for heopful suggestion so far.
     
    @ric
    * correct; no access to ground side of bulbs
    * in olden days, the resistance of the bulbs would determine the current for a bimetallic strip so as either one or more bulbs blow, the flasher would stop or flash at a different rate to indicate bulb failure.  For LED bulbs, a different type of relay is required.
    * yes, wire filament bulbs have a much lower resistance so will pull the WPU down - as proven with the circuit already built.  I thought it would also work with LED but when I tried it, it didn't, due to a smaller current being drawn (or look at it in a different way, much higher resistance) largely due to the LEDs hardly conducting any current when voltage across them is below Vf; typically 2.5 V.
    * re voltage divider, I would need to fine tune the values for each circuit, something I'd rather not do.
     
    @pcbbc
    * I don't expect the bulbs to illuminate, when connected they will allow current from the PNP transistor base to flow to ground and depending on its gain, will pull the voltage across the resistor down.
    * the LED bulbs will have current limiting resistors fitted inside them and will provide a lower load when connected to 12 V but I am not connecting them to 12 V.
    * I have some P channel FETs on order. :)
     
    I am aware that the current flowing through is small but it should be possible to detect the different with bulbs connected or not connected; well I am doing that just that I need to 2 levels to be 0 v (got this) and 5 v (not got this)
     
    My current line of thinking is to have a second PNOP transistor like a Darlington pair but connected to 5 V supply.
    #6
    pcbbc
    Super Member
    • Total Posts : 1700
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: online
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/06/30 07:51:40 (permalink)
    0
    02GF74
    * the LED bulbs will have current limiting resistors fitted inside them and will provide a lower load when connected to 12 V but I am not connecting them to 12 V.

    Not current limiting resistors, although they will have them too.  Load resistors directly across the bulb terminals to present a roughly equivalent load to the 12V incandescent.
     
    If they are just LEDs then most likely they are one (or more) string of series LEDs.  If the sum forward voltage of the series LEDs is > 5v (which it almost certainly will be since the design will be to drop the maximum of the available 12v across the LED string) there won't be ANY path to ground with a 5V supply from the WPU.
     
    I'm not familiar enough with LED car bulbs to know if they all include load resistors (for example to prevent mis-named "CANBUS errors").  I suspect probably they do, in which case you may be okay.  However you'd do well to investigate.
     
    #7
    02GF74
    Senior Member
    • Total Posts : 143
    • Reward points : 0
    • Joined: 2006/11/29 08:25:28
    • Location: 0
    • Status: online
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/06/30 09:13:34 (permalink)
    0
    The LEDS will have current limiting resistors but generally do not have resistors across the bulbs which is why they won't flash at the same rate; it is common to fit those resistors to fix the flash rate.
     
    I am certain there will be a path to ground when the bulbs are fitted but they are operating well to the left of the Vf when they turn on, graph below shows where I expect them to be operating, so the current will in the region of uA.
     

    #8
    Bob White
    Super Member
    • Total Posts : 326
    • Reward points : 0
    • Joined: 2010/11/06 19:52:38
    • Location: Denver, Colorado
    • Status: offline
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/06/30 12:11:58 (permalink)
    0
     
     
    #9
    Bob White
    Super Member
    • Total Posts : 326
    • Reward points : 0
    • Joined: 2010/11/06 19:52:38
    • Location: Denver, Colorado
    • Status: offline
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/06/30 12:12:50 (permalink)
    0
    Try this.

    Attached Image(s)

    #10
    PStechPaul
    Super Member
    • Total Posts : 2727
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/06/30 13:39:38 (permalink)
    0
    It's a bit difficult to determine just how to do this without a more complete circuit diagram. I assume that the PIC provides the signal to a relay which flashes the bulbs, and there is an external switch that connects the bulbs to a +12V supply, although it appears that it actually may connect to the relay. And I also assume that there is no way to power the flasher circuit from the switch, so it must remain always powered. Otherwise, the PIC could simply start the flashing sequence as soon as it's powered up, and could easily check to see if current is being drawn. Also, using a relay is very "old school", and a MOSFET would probably be cheaper and more reliable.
     
    Anyway, here's a simulation of one way to see if bulbs are connected:
     

     

     
    #11
    PStechPaul
    Super Member
    • Total Posts : 2727
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/06/30 13:40:45 (permalink)
    0

    Attached Image(s)


     
    #12
    02GF74
    Senior Member
    • Total Posts : 143
    • Reward points : 0
    • Joined: 2006/11/29 08:25:28
    • Location: 0
    • Status: online
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/07/01 03:49:03 (permalink)
    0
    Relevant part of circuit diagram is below.  The green wire needs to be high (5 V) to indicate SW is open and low when SW closed.  The low resistance of filament bulbs compared to the WPU means input goes low but with LED bulbs, due to the small current drawn, when connecting a 12 V bulb to 5 V means it does not, hence a simple circuit required.
     
    Agreed that a relay is "old school" but was chosen deliberately to give an audible indication that bulbs are flashing.

    #13
    ric
    Super Member
    • Total Posts : 27657
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/07/01 04:34:22 (permalink)
    0
    Try this


    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #14
    02GF74
    Senior Member
    • Total Posts : 143
    • Reward points : 0
    • Joined: 2006/11/29 08:25:28
    • Location: 0
    • Status: online
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/07/01 08:11:51 (permalink)
    0
    Nicewink: wink - that looks promising albeit the logic is reversed but that is minor software change.  By trying to keep the same logic made it difficult.
     
    NC = low
    Connected = high
    Connected + power = low (don't care as program controls power)
    #15
    davea
    Super Member
    • Total Posts : 243
    • Reward points : 0
    • Joined: 2016/01/28 13:12:13
    • Location: Tampa Bay FL USA
    • Status: offline
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/07/02 21:42:16 (permalink)
    0
    ric
    Try this

    you should put a 10k or so across the relay contacts so the base is not floating
    #16
    ric
    Super Member
    • Total Posts : 27657
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: HW question - circuit to detect connection of an 12 V LED lamp 2020/07/02 21:45:18 (permalink)
    0
    The base is held at most 0.65V below the emitter.
    If you're not requiring the transistor to shut off in microseconds, there's no need for an extra resistor.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #17
    Jump to:
    © 2020 APG vNext Commercial Version 4.5