Is there a logic IC that detects floating?

Thread Starter

s_mack

Joined Dec 17, 2011
198
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?
 

Thread Starter

s_mack

Joined Dec 17, 2011
198
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.
 

Attachments

Thread Starter

s_mack

Joined Dec 17, 2011
198
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.
 

MrChips

Joined Oct 2, 2009
30,712
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.
 

Thread Starter

s_mack

Joined Dec 17, 2011
198
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.
 

MrChips

Joined Oct 2, 2009
30,712
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.
 

MrChips

Joined Oct 2, 2009
30,712
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

Joined Nov 30, 2010
18,224
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.
 

Thread Starter

s_mack

Joined Dec 17, 2011
198
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.
Can you help me understand the math on that?
 

MrChips

Joined Oct 2, 2009
30,712
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.
 

Thread Starter

s_mack

Joined Dec 17, 2011
198
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
 

Attachments

Last edited:

Thread Starter

s_mack

Joined Dec 17, 2011
198
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
 
Top