## detect a floating input.

34 posts / 0 new
Author
Message

Hi

I realise that this thread is very old. I'm trying to do exactly this to detect a floating input.

I am trying to understand your calculations but I just don't seem to be getting anywhere.

I understand the 5*0.6 = 3V as minimum input high for the chip. How do you figure hat a 300k ohm pull-down will give 3.5V? I assume the circuit looks like this with internal pull-up enabled:

--- +5V

|

/

\

/   20-100k internal pull-up

\

|

|

input ----->+--(PIN)----

|

/

\

/   300k

\

|

|

----

--

GND

best case internal pull up of 100K would result in the pin voltage being:

5V* 300/(300+100) = 3.75V

best case internal pull up of 20K would result in the pin voltage being:

5V* 300/(300+20) = 4.68V

How did you get 3.5V on the pin?

Last Edited: Mon. Apr 5, 2021 - 08:08 PM

Yes... only 18 years old. "Colin" has not been here since 2008. You really are asking a lot for him to return just for you.

Moderator

Ross McKenzie ValuSoft Melbourne Australia

Don't forget, that as well as the internal pull-up resistor, you also have to figure these currents into your calculations...

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

You want a pull down resistor small enough to pull a floating pin low (ie. below low threshold), while also large enough so the internal pull up (when activated) will pull the pin high (ie. above the high threshold).

Any external device should be able to drive the pin high/low regardless of either resistor affecting the outcome.

If pin is floating (ie. no external drive) then the pull down will result in the pin reading low, and then testing again with the pull up enabled will read high, this confirms the pin is floating.

Any questions?

Jim

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

ki0bk wrote:
Any questions?

I think the question was specifically about the derivation (18 years ago) of the 3.5V value in #7.

Top Tips:

1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...

awneil wrote:
I think the question was specifically about the derivation (18 years ago) of the 3.5V value in #7.

And I answered that, it does not matter the exact voltage level as long as it's below the low threshold, and above the high threshold. (see DS for threshold levels).

Jim

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

but the calculation in #7 does seem to be wrong - or am I and  duracell911 missing something?

Top Tips:

1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...

Unless I am missing something, the calculation in the original thread is indicating the "minimum high voltage" required for the AVR is 3V for 5V VCC power:

dwb240 wrote:
Assuming 5v VCC, minimum high voltage will be 3 volts (5 * 0.6).

Anything over 3V would be acceptable for the high-level input (up to VCC).

Edit: If the pull-up is active and at maximum resistance (100K) then the input (with a 300K pulldown) would be about 3.75V which would be above the 3V threshold.

I am not sure why he said 3.5V unless just rounding down.

David

Last Edited: Mon. Apr 5, 2021 - 08:44 PM

frog_jr wrote:
I am not sure why he said 3.5V

That is the question!

Top Tips:

1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...

I'm trying to do exactly this to detect a floating input.

Welcome to the Forum.

Certainly not related to the question of HOW to do this, but I wondered if you would share the reason WHY you wish to do this?

It is an interesting quesiton, and I can speculate on why this would be of interest, but I'd be interesting in hearing your motivation to do this.

Thanks,

JC

I do something like this:

Input---/\/\/\---UCPin|

~1k

This way, if you set the pin is floating, you will read back (after switching the pin to input) whatever you just wrote to the pin, due to pin capacitance.  But if the input is driven, you'll always read the value it's connected to.

If you want to live dangerously, you can omit the resistor and hope that the UC withstands having an output connected directly to power/gnd (at least momentarily.)

In digital world only 0 and 1 count.
Floating is unpredictable.

I don't know why I'm still doing this hobby

Last Edited: Tue. Apr 6, 2021 - 05:28 AM

duracell911 has left the building.

John Samperi

Ampertronics Pty. Ltd.

https://www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

MicroGyro wrote:
In digital world only 0 and 1 count.
Floating is unpredictable.

Not at all.

It is quite common to use an input pin like this to be able to select one of three options:

1. tied high
2. tied low
3. open

And how it can be reliably detected has been explained.

Top Tips:

1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...

Where the "open" go?

I don't know why I'm still doing this hobby

MicroGyro wrote:
Where the "open" go?

Nowhere - that's what "open" means; not connected to anything.

Top Tips:

1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...

Trinary encoding.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

In #1, duracell911 wrote:
I realise that this thread is very old

#1 was originally a reply to this: https://www.avrfreaks.net/commen... -   Dec 30, 2002

The context of the question is:

The application is strictly limited to setting a configuration via jumpers ...

A bunch of newer I2C parts that I've seen have this ability, thus letting you get by with fewer pins dedicated to configuration.

Top Tips:

1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Tue. Apr 6, 2021 - 09:00 AM

See this, it's much more reliable than letting a pin float...

## Attachment(s):

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

It's still the same principle:

The point 'X' is High (jumper 'H' fitted) or Low (jumper 'L' fitted) or Open (neither jumper fitted).

Top Tips:

1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...

awneil wrote:

It's still the same principle:...

It is, but the important difference is the 10nF capacitor. Trust me, without it you run the risk of incorrect values being read in the real world.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

.

Last Edited: Fri. Apr 9, 2021 - 08:07 AM

Last Edited: Fri. Apr 9, 2021 - 08:05 AM

valusoft wrote:

Yes... only 18 years old. "Colin" has not been here since 2008. You really are asking a lot for him to return just for you.

Moderator

if you don't ask you don't get . A truly amazing response from everyone else though. Thank you all for your support

Brian Fairchild wrote:

Don't forget, that as well as the internal pull-up resistor, you also have to figure these currents into your calculations...

Thank you and good point. 1uA through a 100k resistor would be about 0.001V which is negligible compared to the other voltage drop.

awneil wrote:

frog_jr wrote:
I am not sure why he said 3.5V

That is the question!

Precisely... glad someone understood the exact question. I was starting to question my command of the English language.

Based on the other comments, it seems that this was a mistake... There has been so much valuable input though and I certainly have learnt a lot.

duracell911 wrote:

Brian Fairchild wrote:

Don't forget, that as well as the internal pull-up resistor, you also have to figure these currents into your calculations...

Thank you and good point. 1uA through a 100k resistor would be about 0.001V which is negligible compared to the other voltage drop.

I think you need to re-do your calculation!

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

DocJC wrote:

I'm trying to do exactly this to detect a floating input.

Welcome to the Forum.

Certainly not related to the question of HOW to do this, but I wondered if you would share the reason WHY you wish to do this?

It is an interesting quesiton, and I can speculate on why this would be of interest, but I'd be interesting in hearing your motivation to do this.

Thanks,

JC

Hi JC

I am working for a start-up AKA we don't have huge budgets to develop expensive production test tools - ideally bed of nails in an automated test jig. Hence the need for some cheap and cheerful test equipment that catches manufacturing problems - thinking 20% development time to catch 80% of the issues.

The specific issue that we were seeing was on a backplane design that performed automatic address allocation to other backplane segments. This would sometimes get through test with the current test jig as it only tested one address location on the backplane. When installed in another segment location in-field, the addressing would fail. A short to gnd or +V (or even a high impedance) would be ok in the first location if we were lucky but not so lucky in another addressing position. So an Arduino based automated address tester was developed. It sets the top address (sequencing through the various segment addresses/locations) and then checks the resulting addresses generated. It was noted that backplanes would fail on the tester but the results (bit patterns) would not always be consistent when testing. This is because I had focused on finding shorts and failed to consider floating inputs - this is equally important during the production process as poor/broken solder joints are possibly as likely as shorts. Hence, the reason why I was researching this topic.

Probably not the most glamourous project

MicroGyro wrote:
In digital world only 0 and 1 count. Floating is unpredictable. Going analog like ADC?

Indeed, floating is unpredicatable but by biasing it with a pull up/down, it becomes predictably detectable which is necessary in the real world. Using an ADC would also require some biasing or detection over a period of time requiring an interesting algorithm. Just trying to keep it simple and I certainly don't have that many ADCs on the chip.

js wrote:

duracell911 has left the building.

No, I just threw the grenade and ran only to return when the smoke had dissipated

Brian Fairchild wrote:

awneil wrote:

It's still the same principle:...

It is, but the important difference is the 10nF capacitor. Trust me, without it you run the risk of incorrect values being read in the real world.

"The capacitor to ground reduces spurious noise pick-up especially if your tracks are long or you've got high currents being switched nearby or on the same ground." - might not be needed but I appreciate your reference to the real world.

Brian Fairchild wrote:

duracell911 wrote:

Brian Fairchild wrote:

Don't forget, that as well as the internal pull-up resistor, you also have to figure these currents into your calculations...

Thank you and good point. 1uA through a 100k resistor would be about 0.001V which is negligible compared to the other voltage drop.

I think you need to re-do your calculation!

sorry, you are right - 0.1V which does get us down from 3.75V but not all the way to 3.5V. Anyway, as I said, you raised a good point and this is easily forgotten. Thanks

westfw wrote:

I do something like this:

Input---/\/\/\---UCPin|

~1k

This way, if you set the pin is floating, you will read back (after switching the pin to input) whatever you just wrote to the pin, due to pin capacitance.  But if the input is driven, you'll always read the value it's connected to.

If you want to live dangerously, you can omit the resistor and hope that the UC withstands having an output connected directly to power/gnd (at least momentarily.)

This is interesting. I never would have thought of that. From what I read, the capacitance is typically in the region of 7pF. Is this sufficient and would it vary sufficiently in the manufacturing process to result in erroneous behaviour from one IC production batch to another?

duracell911 wrote:
I just threw the grenade and ran only to return when the smoke had dissipated

Now that the smoke has dissipated, is it time to mark the solution?

See Tip #5 in my signature, below:

Top Tips:

1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...