ADC 5v range

16 May 2010

I thought that the mbed supports a 5v ADC range, am I right?

I hooked up a gyro that outputs a 5v range. When the gyro is not moving, it outputs 2.5v (confirmed with O-scope), yet my mbed reads .72, or 3.6v. Why is this happening? This is also happening with the temperature output, where the voltage is 2.5v at 25C.

The sensor is a ADXRS613.

Code:

#include "mbed.h"
#include "TextLCD.h"


TextLCD lcdd(p21, p22, p23, p24, p25, p26, p29,16,2);
AnalogIn gyro(p20);
AnalogIn temp(p19);
int main() {
while(1){
lcdd.cls();
lcdd.printf("%f \n%f",gyro.read()*5,temp.read()*5);
wait(.1);
}
}

16 May 2010

Hi

The ADC range is 0 to 3.3 V (the reference voltage available on VOUT pin 40). That would explain .72 for 2.5 V (or 0.76 by my calculation).

Regards
Daniel

16 May 2010

Oh, hope I didn't damage it. How should I go about shifting the voltage?

16 May 2010

mbed I/Os are 5V tolerant so it's unlikely to be damaged. To reduce the range, use a voltage divider.

16 May 2010

Hi

The mbed is tolerant of 5 V so there is no problem there. The simplest way to shift the voltage is to use a voltage divider with a couple of resistors. A 22K and 12K resistor would drop just under 2/3 of the 5V across the mbed input.

Regards
Daniel

16 May 2010 . Edited: 16 May 2010

Thanks, got it now. Right now, i am using 3 identical resistors, with 1 resistor as R1 and 2 resistors in series as R2. This is just a little of, will try and get better resistors later. Or see if i can figure out an accurate adjustment factor.

 

BTW, I suggest putting that the ADC voltage is 3.3v on the AnalogIn page of the handbook.

13 Nov 2010 . Edited: 13 Nov 2010

This may or may not explain the problem you were seeing but is a common pitfall none the less...

CMOS transmission gates suffer from not being able to block an input voltage higher or lower than it's supply.  In this situation deselected inputs will leak into the selected input.  So in this case, you will not have damaged the input but an over voltage input that you are not using will cause your other inputs to appear to clip.   So don't be surprised if one input appears to mess all the other ones up when they go outside of the ADC's voltage.  Precision measurements of high impedance signals are sometimes even affected by inputs even close to the supply voltage.  Datasheets sometimes only spec mux's with all inputs well within their supply limits in an attempt to sweep this under the rug.

To avoid this (and really protect their inputs) you can use this type of circuit:

 

.                               |

.                 1k         ^         10k

Input>-----^^^-----+-----^^^-------->pin

.                               |

.                              ^

.                               |

sorry the ASCII art is not the best...  In the middle are diodes from ground and to the positive supply.  This guarantees that the bulk of the current is dumped to the supplies by the external diode.     Adding a resistor to ground at the  pin to divide the signal would also further protect you from this problem.  This circuit also really helps protect from ESD.