# MCU measuring voltage and resistance on the same inputs

Status
Not open for further replies.

#### zolispa

##### Newbie level 1
Software guy trying to play with HW...

I have a pair of inputs, on which I would like to measure a differential voltage with a microcontroller.
If there is no voltage present, I would like to measure any resistance between the two inputs.

Parameters:
- Input voltage can be 0-100V DC, any polarity
- Supply voltage is a single 3.3V
- Battery operated, hence no ground reference to any of the inputs
- Microcontroller (ATSAM3) has a 12-bit differential/single-ended ADC, and works fine with high source impedances
- Voltage measurement should have an accuracy of 1V, resistance about 1K, max 100hz sampling rate

I was doing an attempt with this:
Code:
------------|     R1
GPIO 1      |----<100k>-----------  Input A     --|          --|
|              |                      |            |
|            <680k> R4                |            \
|     R2       |                    -----          /
AD+ / GPIO2 |---<100k>-----+                     ---  ?V or    \ ?R
|              |                    -----          /
|            <20k>  R5               ---           \
|     R3       |                      |            |
AD- / GPIO3 |---<100k>-----+------  Input B     --|          --|
------------|

Theory:
- The 100k series resistors should protect against up to 200V inputs and ESD
- The R4-R5 voltage divider scales the input voltage to the ADCs range
- During voltage measurement GPIO1 is set as an input with pull-up/downs disabled, differential voltage is measured on AD+ and AD-
- If there is no voltage present, GPIO1 and GPIO2 are set as an output (3.3V and 0V), and the AD- pin measures in single-ended mode,
the voltage that is created by the voltage divider formed by R1 + ?R and R5 + R2 (with R4 being accounted for)

Practice:
- If R1 is not connected, differential voltage measurement is just fine
- If R1 is connected, voltage measurement doesn't work (reads full 0 or max values)

I guess this has to do with internal clamping diodes, and injection currents, but at say, 10V, these should be negligable (50uA). What is the problem ?

Also, the divider for the voltage measurements limits the resolution of the resistance measurements, so I would be happy for even completely alternative approaches on this.

Thanks!

Status
Not open for further replies.