2
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Scott Seidman Dec 3 '15 at 14:01
2
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ but the requirement request don't fix hardware, so i can not add a resistor to the board, \$\endgroup\$ – Nguyen van sy Dec 3 '15 at 9:39
  • \$\begingroup\$ 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. \$\endgroup\$ – Icy Dec 3 '15 at 9:44
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.