Hi every one:
Does any one have any ideas as to how I can measure negative voltages accurately using the pic's internal ADC or an external ADC. The voltage would be between -2 to 12 V.
thanx
sam
Hi every one:
Does any one have any ideas as to how I can measure negative voltages accurately using the pic's internal ADC or an external ADC. The voltage would be between -2 to 12 V.
thanx
sam
One idea might be to use an op-amp, like LMC662, and raise the negative voltage with the offset fed into the op-amp. But since the span is |-2-12|=14 volts you will need a divider too. So I would use a divide first to down scale the voltage range with a 2 resistor divider and obtain maximum 3 volts when the input will reach 12. That is because the op-amp would have an offset of 2 volts,so the output would be raise to 5Volts.
The divider should be a divide by 4, like 3K from input to common node and 1K down to earth.
The common node is going to feed the +input of the op-amp and the - input of the op-amp would get -2 offset voltage (with a low Z source). The output should be connected to the -input (follower). Now the power supply should be +/- 5 volt at least (sorry...).
Ioannis
thanx for the idea but is there any way you can give me a diagram.
thanx
sam
What part you don't understand?
I do not ussually draw schematics on screen...
Ioannis
Hi Sam,
Attached is a schematic of an inputstage I've designed and used succesfully with the internal ADC. It's an OP-based rectifier with adjustable gain.
Apply your -12V signal to the input and adjust P1 untill you get your desired output (+5V or +4.096 or whatever). (Do this before you connect the output to the ADC)
The sign output will be high or low dependig on if the input voltage is positive or negative and you can use a digital input to read the sign and 'add' one bit of resoultion to the ADC resulting in +/- 10bit. Since your voltage is always negative you can leave that part out if you don't need it.
There's one drawback though. You need to feed the OP-amp with +/-15V.
Hope it helps.
/Henrik Olsson.
On the schetch of Henrik please consider the voltage drop on the output resistor of 1K that is going to be in series with the ADC input resistor of your PIC (about 10K). That will give a ratio of about 1/10th.
Ioannis
Ioannis, Sam,
Valid concern that MAY need attention!
If the voltage drop over the output resistor does present a problem it can easily be adjusted for by changing the gain of the amplifier/attenuator with P1.
BUT.....
The datasheet for the 16F877 (which is the PIC I used and I suspect others are similar), table 15-12 says that the recommended impedance of the voltage *source* is max 10k. So the 1k shouldn't make that large impact on the result. I couldn't find any info on the actual input impedance of the ADC. Where did you find that?
Further on, I belive that if the input impedance was 10k the ratio would be ~9/10 with a 1k source impedance.
Thanks!
/Henrik Olsson.
Well, actually the input resistance of the ADC will change relative to the Vcc. For 5 volts would be 7K according to the diagram in Fig.11-2 of 16F877 DS and ading the interconnect resistance of 1K, makes for a total 8K. So this is a factor to concern when sampling the input. So, I would suggest to skip the maths and do a longer sampling just to be sure.
Ioannis
Ioannis,
You're right, ~7k @ 5V Vdd - I totally missed that graph!
As you say, a longer sampling period may be needed. Trying will tell. Also, the PIC Mid Range Manual sugests a 0.1uF capacitor on the input if the signal isn't changing to quickly, may be worth a try if Sam decides to use the circuit.
Thanks for the heads up on that graph!
/Henrik Olsson.
thank you all for all your responses. I think i have all the info that i need and now have to do some experiments.
sam
I measure negative voltages accurately without any external active components.
All you have to do is connect a resistor from Vref to the A/D input pin, and another resistor from that A/D pin to the voltage to be measured.
For example: To measure -12V, I use a National 4.096V reference on RA3 and a 2K resistor from that pin to the A/D input I want to use. From there, I use a 7.5K resistor to the voltage to be measured.
The code then loops 19 times and adds the results of the conversions (for averaging). The result is then subtracted from 15360. The answer is in tens of millivolts.
I have used this technique for years with good results.
Charles Linquist
Hi Charles. Yeap, this is the superposition theorem. I really forgot about it. Too many years ago...
Clever though.
Ioannis
Hi Charles:
That is exacly what i was looking for. do you have any formulas as to how to calculated different resistor values and to know how much offset you have and what not.
thank you
sam
You build a voltage divider from Vref. For example:
If you are trying to measure a -5V (full-scale) voltage and you have a 5V reference:
Build a voltage divider with a 4K resistor from Vref to the input of the A/D and another 4k from that pin to the voltage to be measured (the INPUT).
If the INPUT voltage is at "0" volts, the A/D pin will be at 2.5V (or 512 counts if you are using a 10-bit A/D).
At -5V input, the voltage at the A/D pin will be at "0" volts.
So, to obtain a reading, run the converter and SUBTRACT the count from the "0" voltage input reading (512) and scale the result.
If you still need more help, I can show you some more.
Charles Linquist
Bookmarks