Is there a logic IC that detects floating?

Discussion in 'General Electronics Chat' started by s_mack, May 29, 2012.

  1. s_mack

    Thread Starter Member

    Dec 17, 2011
    187
    5
    I might be thinking about this wrong...

    I have a device that uses an Atmega64A and I'm hooking up an LED driver to one of its GPIO to control the enable pin of the driver. In some circumstances (that are beyond my control, as the Mega64 is an existing device that I don't have firmware control over) the pin is floating. Understandably, that results in unpredictable (and undesired) behavior by the LED driver.

    I'm wondering if there's a logic gate setup that I can use such that if EN is floating that output is either high or low (I don't really care which). To make things trickier, the output is sometimes PWM.

    So... High, Low, or PWM => A=Y
    but... floating => A = High (or low)

    Thoughts?
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,429
    3,360
    Install a 10kΩ pull-up resistor.
     
  3. s_mack

    Thread Starter Member

    Dec 17, 2011
    187
    5
    I guess I was looking for something much more complicated and expensive than that.

    Thanks :)
     
  4. s_mack

    Thread Starter Member

    Dec 17, 2011
    187
    5
    Is this about right then (see attached)?

    The AL5802 IC powers on when EN is LOW and powers off when EN is HIGH (opposite of most similar ICs) and accepts a PWM signal. My goal here is to have some sort of "expected" behavior for all possible PB7 states. Do I have this correct?

    If PB7 is output low, I expect the LED to be on.
    If PB7 is output high, I expect the LED to be off.
    If PB7 is floating, I expect the LED to be off because the pull-up is bringing it high.
    If PB7 is putting out a PWM signal, I expect the LED to be dimmed accordingly.
    If PB7 is somehow set to input... I'm not sure what to expect, but hope for no smoke and flames.

    The device is battery powered. What kind of impact can I expect the pull-up to have in the above states? Hmm... that gets me thinking too. The Mega runs on a regulated 5v source whereas the LED driver runs on battery voltage, which can be anywhere from 7v to 12v in this case. I don't have access to the 5v side of the regulator so perhaps a pull-up to a variable unregulated +Batt voltage isn't a great idea? Maybe a pull-down instead?

    Sorry - this stuff manages to confuse me.
     
  5. MrChips

    Moderator

    Oct 2, 2009
    12,429
    3,360
    If you wish, I can make it more expensive. I can send you a bill for consultation fees.
     
  6. MrChips

    Moderator

    Oct 2, 2009
    12,429
    3,360
    You can use a pull-down instead. It means that the AL5802 IC, whatever that is, will be enabled.
     
    Last edited: May 29, 2012
  7. s_mack

    Thread Starter Member

    Dec 17, 2011
    187
    5
    enabled when?

    Help me understand (then send the bill!)

    1) PB7 is floating so AL5802 (IC) is enabled via pull-down, yes? Pull-down power consumption is (not looking for finite mA, but how to calculate)?
    2) PB7 is output high. IC is disabled. Again, what is the extra power consumption from the resistor? Nothing in this case?
    3) PB7 is output low. IC is enabled. Power?
    4) PB7 is PWM. IC is dimmed as expected? Power?
    5) PB7 is input (this should never happen, but if it does... what happens?)

    Just trying to understand.
     
  8. MrChips

    Moderator

    Oct 2, 2009
    12,429
    3,360
    If you want the AL5802 to be off when PB7 is floating, try a weak pullup of 100k to 1MΩ to your battery source. Start off with the 1MΩ and see if that works.
     
  9. s_mack

    Thread Starter Member

    Dec 17, 2011
    187
    5
    On or off I don't really care - its just acting bizarre when floating. Sometimes it slowly fades to black while other times it oscillates between dim and bright.

    Isn't pulling up to battery voltage asking for trouble? The IC En pin has an absolute max of 6V.
     
  10. MrChips

    Moderator

    Oct 2, 2009
    12,429
    3,360
    You are not going to pull-up the EN pin. There is no risk to the AL5802. The pull-up goes on the PB7 output and the MOSFET gate input. With 1MΩ pull-up the current will be about 10μA. To be safe, you can put a 5.1V zener diode across the PB7 to GND.
     
  11. MrChips

    Moderator

    Oct 2, 2009
    12,429
    3,360
    The gate current on the 2N7002 is less than 1μA.
    You can even try both a pull-up of 1MΩ and a pull-down of 1MΩ to cut the voltage down to half of the battery voltage. The leakage current will be about 6μA.
     
  12. #12

    Expert

    Nov 30, 2010
    16,261
    6,768
    The theory seems to be that a wandering output pin does not have a strong current capability. Pull it whichever way you want, just pull it with something.

    From what I see of the conversation, using the 5V supply for the chip and a high ohm resistor is the right thing to do. Second best approch is to use a zener that is rated between whatever the 5 volt rail actually is and the chip limit of 6 volts.
     
  13. s_mack

    Thread Starter Member

    Dec 17, 2011
    187
    5
    Can you help me understand the math on that?
     
  14. MrChips

    Moderator

    Oct 2, 2009
    12,429
    3,360
    If we connect two 1MΩ resistors in series that creates a 2MΩ resistor.
    Next we connect this 2MΩ resistor across Vbat and GND.

    If Vbat is between 7V and 12V, the current through 2MΩ will be between 7/2 and 12/2 μA, i.e. between 3.5 and 6μA.

    The node between the two 1MΩ resistors will be between half of 7 and 12V, i.e. 3.5V and 6V. The 2N7002 needs only 2V to turn on.

    If you wish you can increase the value R1 of the resistor connected to Vbat or reduce the value R2 of the resistor connected to GND to bring the voltage to about 5V when Vbat = 12V.

    You can calculate the voltage at this voltage divider using

    V = Vbat x R2/(R1 + R2)

    or you can replace R2 with a 5.1V zener diode.
     
  15. s_mack

    Thread Starter Member

    Dec 17, 2011
    187
    5
    Thanks so much!
     
  16. s_mack

    Thread Starter Member

    Dec 17, 2011
    187
    5
    Mr. Chips (and others)... you were such a big help. Can I ask that you have a quick once over on my final design and tell me if it looks OK? I decided to go with a simple voltage divider to pull up the enable signal - between the controlling AVR (the solder pad marked "VBL") and the 2N7002 - but I admit I'm still a bit confused on this point. In my head I keep getting mixed up on where the power is coming from lol. And I get stuck on the battery being 7v to 12v. The gate of the FET is controlled by the 5v logic from the uC ("VBL") so it doesn't need to be divided. The problem is that I can't pull-up to the uC's +5VCC. My only source of power is the battery. So I'm really not clear on if I should be dividing as above (and if my values are OK) or if I should just be doing a simple pull-up from VBATT or? I realize I could use a voltage regulator, but that's an expense I'd rather avoid if its not necessary.


    Anyway... any input is appreciated, thanks.

    - Steven
     
    Last edited: Jun 1, 2012
  17. s_mack

    Thread Starter Member

    Dec 17, 2011
    187
    5
    I just noticed on my schematic that the notation regading the LED cathode/anode connection is confusing. The labels are just overlapped. One is marked "+" and "A" while the other is marked "-" and "K" and the overlapping makes it look like one is "- +" and the other is "K A" :) Its OK though... I know that part is fine lol

    - Steven
     
  18. MrChips

    Moderator

    Oct 2, 2009
    12,429
    3,360
    I think you'll be fine.
     
  19. s_mack

    Thread Starter Member

    Dec 17, 2011
    187
    5
    appreciate it!
     
Loading...