I am using a PIC micro with a 10bit ADC to take readings from an analog signal with a frequency less than 300 hz. However that analog signal is in the range of -2 V and +2 V. How can I condition the signal to get it into a usable range (assuming the input to the ADC has to be positive) Also I do not have a positive and negative power supply.
|
You'll have to scale the voltage with a resistor divider so that you get a voltage between -2.5V and +2.5V, and add 2.5V. (I'm presuming a 5V power supply for your PIC). The following calculation looks long, but that's only because I explain every step in detail. In reality it's so easy that you can do it in your head in no time. First this:
How many unknowns do we have? Three, R1, R2 and R3. Not quite, we can choose one value freely, and the other two are dependent on that one. Let's choose R3 = 1k. The mathematical way to find the other values is to create a set of two simultaneous equations from two (\$V_{IN}\$, \$V_{OUT}\$) pairs, and solve for the unknown resistor values. Any (\$V_{IN}\$, \$V_{OUT}\$) pairs will do, but we'll see that we can tremendously simplify things by carefully choosing those pairs, namely the extreme values: (\$+20V\$, \$+5V\$) and (\$-20V\$, \$0V\$). First case: \$V_{IN} = +20V\$, \$V_{OUT}=+5V\$ Second case: \$V_{IN} = -20V\$, \$V_{OUT}=0V\$
Like I said it's only the ratio between these values which is important, so I might as well pick \$R1 = 12k\Omega, R2 = 3k\Omega, R3 = 4k\Omega\$. The last thing to do is to connect \$V_{OUT}\$ to the PIC's ADC. ADCs often have rather low input resistances, so this may disturb our carefully calculated equilibrium. Nothing to worry about, however, we simply have to increase R3 so that \$R3 // R_{ADC} = 1k\Omega\$. Suppose \$R_{ADC} = 5k\Omega\$, then \$\dfrac{1}{1k\Omega}=\dfrac{1}{R3}+\dfrac{1}{R_{ADC}}=\dfrac{1}{R3}+\dfrac{1}{5k\Omega}\$ From this we find \$R3=1.25k\Omega\$. edit |
|||||||||||
|
|
The easiest way is to use a "resistor divider". You didn't say what voltage this PIC is running at and therefore the A/D input range is, so let's use 5V for the example. Your input voltage range is 40V, and the output 5V, so you need something that attenuates by at least 8. You also need the result to be centered on 1/2 Vdd, which is 2.5V, whereas your input voltage is centered on 0V. This can be accomplished with 3 resistors. One end of all three resistors are connected together and to the PIC A/D input pin. The other end of R1 goes to the input signal, R2 goes to Vdd, and R3 goes to ground. The resistor divider is formed by the R1 and the parallel combination of R2 and R3. You can adjust R2 and R3 to center the resulting range at 2.5V, but for simplicity explaining this we'll live with a little bit of assymetry and attenuate a little bit more to make sure both ends are limited to the Vss-Vdd range. Let's say the PIC wants the analog signal to have a impedance of 10 kΩ or less. Again for simplicity, let's make R2 and R3 20 kΩ. The impedance feeding the PIC will be no more than the parallel combination of those, which is 10 kΩ. To get attenuation of 8, R1 needs to be 7 times R2//R3, which is 70 kΩ. However, since the result won't be exactly symmetric, we need to attenuate a little more to make sure -20V in won't result in less than 0V into the PIC. That actually requires attenuation of 9, so R1 must be at least 8 times R2//R3, which is 80 kΩ. The standard value of 82 kΩ will allow for some slop and margin but you still get most of the A/D range to measure the original signal. Added:Here is a example of finding the exact solution to a similar problem. This has no assymetry and has a particular specified output impedance. This form of solution can always be used when the A/D range is wholly within the input voltage range. |
|||||||||||
|
|
This is the standard circuit for that. You need to scale the resistor values for your required impedance. |
|||||||||||
|
|
If the signal is not DC, or if a DC reference isn't important, the signal can be capacitively coupled to the input of the ADC. Alternatively, if your ground for the PIC is floating, you could tie your signal ground to 1/2 VDD of the PIC. |
|||||
|
|
The following circuit should do the job:
It's a potential divider. At -2V, the output will be 0.65V; at +2V, 2.65V. All noise on the 3.3V rail will get transferred to the input, so use a good voltage reference to reduce this problem. This will work with other supplies too, but the offset will shift. |
|||||||||||
|
|
Thomas' voltage adder with two identical resistors is indeed simple, but has the disadvantage that the input range to the ADC is reduced, which means that noise will have a bigger influence. Also the lower limit is at 0.65V. If your microcontroller doesn't have a \$V_{ADCREF-}\$ input (most controllers don't) that part of the input range will remain unused. If your \$V_{DD}\$ = 3.3V the input resistor should be 61% (\$\frac{2V}{3.3V}\$) of the pull-up. At +2V in \$V_{ADC}\$ will be 2.49V. |
||||
|
|