Author Topic: Detecting floating/unconnected ADC pins  (Read 4832 times)

0 Members and 1 Guest are viewing this topic.

Offline RoadRunnerTopic starter

  • Frequent Contributor
  • **
  • Posts: 378
  • Country: de
Detecting floating/unconnected ADC pins
« on: September 11, 2015, 12:44:49 pm »
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 
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9961
  • Country: nz
Re: Detecting floating/unconnected ADC pins
« Reply #1 on: September 11, 2015, 12:56:40 pm »
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

« Last Edit: September 11, 2015, 01:08:30 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline matseng

  • Frequent Contributor
  • **
  • Posts: 563
  • Country: se
    • My Github
Re: Detecting floating/unconnected ADC pins
« Reply #2 on: September 11, 2015, 01:01:00 pm »
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 .
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9961
  • Country: nz
Re: Detecting floating/unconnected ADC pins
« Reply #3 on: September 11, 2015, 01:08:38 pm »
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 
« Last Edit: September 11, 2015, 01:12:35 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline matseng

  • Frequent Contributor
  • **
  • Posts: 563
  • Country: se
    • My Github
Re: Detecting floating/unconnected ADC pins
« Reply #4 on: September 11, 2015, 01:12:02 pm »
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
-Check what ADC pins are at max.
-Cycle the polarity of the two outputs between 0V 5V and 5V 0V while checking the ADC values on all inputs. The inputs that stay at max are unconnected.

No matter what position the pots are set to, if you swap the polarity on the pots you will cause a non-zero ADC reading in one of the two polarities
That'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.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9961
  • Country: nz
Re: Detecting floating/unconnected ADC pins
« Reply #5 on: September 11, 2015, 01:13:09 pm »
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.
« Last Edit: September 11, 2015, 01:23:52 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline matseng

  • Frequent Contributor
  • **
  • Posts: 563
  • Country: se
    • My Github
Re: Detecting floating/unconnected ADC pins
« Reply #6 on: September 11, 2015, 01:24:18 pm »
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 pins that are ADC only (no i/o feature).

Well, 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 to http://tuomasnylund.fi/drupal6/content/capacitive-touch-sensing-avr-and-single-adc-pin it is indeed possible to have the pullup enabled when doing adc readings, so your are right.
 

Offline RoadRunnerTopic starter

  • Frequent Contributor
  • **
  • Posts: 378
  • Country: de
Re: Detecting floating/unconnected ADC pins
« Reply #7 on: September 12, 2015, 07:13:13 am »
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 

its 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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf