Detecting floating/unconnected ADC pins - Page 1
Forum section: electronics / beginners

author: RoadRunner
author_rank: Frequent Contributor
timestamp: September 11, 2015, 12:44:49 pm
content: i am working on a little project which sense around 8 analog pot through ADC , i have used PIC microcontroller,it is a possibility that few out of 8 analog pot are not connected at all,i want to detect those unconnected pins.when pot is not connected pin is just floating. pot goes from 0 to 5v(Vcc). currently i have a little software solution , at start-up in software i sample the ADC lines for environment noise if noise is there then software consider them to be unconnected. is it reliable way to do this?is there any other way to detect floating adc pins with or without any extra component connected to the pin?any suggesting will be vary helpful.thank you

author: Psi
author_rank: Super Contributor
timestamp: September 11, 2015, 12:56:40 pm
content: You can add a resistor to each of your pots so it cannot go all the way to 5V. 0-4.9V for example.Then you can enable the internal pullups on the pins for a second at startup. Any input that is unconnected will instantly go to 5V.The resistors are there to make it impossible for a pot set to max to be mis-detected as a non connected input.Actually, you could do it without the resistors. Justs code it to keep rechecking any adc pin previously detected as unconnected. That way if it mis-detected a pot it would eventually get it correct when the pot was next adjusted down from maximum

author: matseng
author_rank: Frequent Contributor
timestamp: September 11, 2015, 01:01:00 pm
content: You could connect all 8 ADC inputs together via 8 high ohm resistors (>1M) to a single output pin that you set high/low and take adc readings on all 8 ports. Any port that swings almost full scale is unconnected.Unless the pots that you use are of very high resistance the leakage between the adc channels caused via two resistors will be negligible .

author: Psi
author_rank: Super Contributor
timestamp: September 11, 2015, 01:08:38 pm
content: Ive thought of a 3rd way. Use two spare output pins to produce the 0V and 5V for all the pots.-Enable pullups on all adc pins at startup to do the testing-Take a reading of all ADC channels with the polarity on the pots as 0-5V and then as 5-0V. The inputs that stay at max in both states are unconnected.It works because no matter what position the pots are set to, if you swap the polarity you will cause a non-max ADC reading in one of the two polarities

author: matseng
author_rank: Frequent Contributor
timestamp: September 11, 2015, 01:12:02 pm
content: Quote from: Psi on September 11, 2015, 01:08:38 pmThat's a nice method. But I don't think you can have a pullup enabled on an adc pin in most (if not all) microcontrollers. You method could probably work without it though.

author: Psi
author_rank: Super Contributor
timestamp: September 11, 2015, 01:13:09 pm
content: Fairly sure you can do it on all AVR's. I cant say ive tried but the diagrams are pretty clear that all i/o have pullups including all the ADC channels.You probably cant do it on the very few AVR's that have some ADC only pins.

author: matseng
author_rank: Frequent Contributor
timestamp: September 11, 2015, 01:24:18 pm
content: Quote from: Psi on September 11, 2015, 01:13:09 pmWell, the module diagram is not too clear as I see it. There are plenty of control signals that can disable the pullup driver. Anyone of them could be asserted/de-asserted automatically as a part of enabling the adc subsystem.But according tohttp://tuomasnylund.fi/drupal6/content/capacitive-touch-sensing-avr-and-single-adc-pinit is indeed possible to have the pullup enabled when doing adc readings, so your are right.

author: RoadRunner
author_rank: Frequent Contributor
timestamp: September 12, 2015, 07:13:13 am
content: Quote from: Psi on September 11, 2015, 01:08:38 pmits really a nice solution ,my PIC18F4550 does not have any pullup register on adc pins , so i will to use external pullup maybe.thank you for your support and time.