Go Down

Topic: Wrong analog input read! (Read 205 times) previous topic - next topic

Nongsai

Hi all,

I've an issue with reading voltage with an analog input.
I connect a known voltage to an analog input (A15, I also tried other analog inputs), read the amount and convert it to a voltage using the calibrated internal resistance which in my case equals V_ref_int=1.105V. I also measure the voltage with a multimeter in order to compare. I grounded the pin with a 1kOhm resistor as well in an attempt to reduce noise.

I get quite differing, but not completely random values. I measure every couple of seconds. Here is an example of a series of results:


analogread: 150.00  V=0.16
analogread: 759.00  V=0.82
analogread: 978.00  V=1.06
analogread: 150.00  V=0.16
analogread: 1023.00 V=1.10

I would usually post a code describing the problem, but in this case it is really just a question of reading the input and converting it to a voltage. The incoming voltage is connected to the input in through a 8kOhm resistor, and measured (thus expected) voltage with DMM is around 0.5.

Weird, right?? Anyone has an idea where I could look into?

Wawa

There might be something wrong with your code (that you didn't post).

Is this a DC voltage source (battery) you're measuring?
Leo..

Nongsai

Leo I think you pointed me to the right direction: the signal is the output of an amplifier. I think that what's happening is that with the multimeter I'm measuring DC votlage around 0.5B, but in reality I think there is an AC component. As soon as I get my hands on the system again I'll measure the AC voltage. To solve this I was thinking of adding a low-pass filter between the amplifier output and the analog input. I hope this solves the problem, i'll come back to confirm!

Wawa

A low pass filter won't change AC into DC.

Not sure what you want to do, but for AC (sound) you generally use a 1:1 voltage divider to bring the analogue input to mid-voltage, and inject the sound to the same point through a coupling cap.

e.g. 10k from 5volt to analogue input and 10k from analogue input to ground.
AC (sound) via a ~47uF cap and a 10k resistor in series (for input pin protection) to the same analogue input.

The analogue input should be sampled as often as you can (many times per second).
Code can calculate peak values, and so sound level.

Tell us what you want to do. There might be other solutions.
Leo..

Go Up