2

I am working with ADC on MCU SH7147 (Renesas).

I have a problem with a sensor as outlined below. How do I detect a disconnect of the sensor cable on the analog input pin on the MCU?

I tried to check it by cutting the the wire and seeing the analog data display in LCD, but it is random data, it is difficult to make a rule to detect disconnect.

David
  • 4,504
  • 2
  • 25
  • 44
  • You might benefit from searching for "lead off detection", which involves sending and detecting a signal through a reference lead for the measurement of biopotentials. – Scott Seidman Dec 03 '15 at 14:01

3 Answers3

2

Add a pull down or pull up resistor on the A2D input - it will then always read full scale or zero when the sensor is disconnected.

A value of about 100K should do the trick, A2D input impedance is typically 1M ohm or so. and sensor output is typically less than 100 ohm.

Icy
  • 2,253
  • 9
  • 16
  • but the requirement request don't fix hardware, so i can not add a resistor to the board, – Nguyen van sy Dec 03 '15 at 09:39
  • How is your sensor connected to the board? Through a connector? where do you want to detect disconnection; connector not plugged in, or a break in the cable to the sensor? if you are looking for a break / fault in the sensor add the resistor to the connector. – Icy Dec 03 '15 at 09:44
1

Set the pin to digital output, set it to 1, set it to ADC input, capture value.
Set the pin to digital output, set it to 0, set it to ADC input, capture value.

If the pin is not connected to anything, you should get a high/low ADC value, since the pin has a small capacitance, which stores the voltage level. A connected sensor will set the voltage level back to 'his' value. You may have to play around with delays between setting and measurement to get reliable results.

Of course, this only works when the ADC input itself is floating and not, when there's e.g. an opamp connected to the input. And you have to check if a connected sensor tolerates this at its output.

sweber
  • 8,580
  • 1
  • 15
  • 35
1

What type of sensor is it?

One approach is to switch the MCU pin to be a digital output, then drive a 0 or a 1 on it for a while. Then switch it to be an ADC input and read the value. If it's still close to 0 or Vcc, the input could be disconnected. This works because there is usually enough stray capacitance on your board to hold 0V or 3.3V/5V on the pin for a few microseconds while you switch over from digital output to analog in.

However you need to be careful that driving a 0 or 1 output when the sensor is connected won't damage it, or the SH7147. This depends a lot on what the sensor circuit looks like.

Ian H
  • 186
  • 1