# Opamp to pic a/d

Discussion in 'General Electronics Discussion' started by Rajinder, Dec 21, 2017.

1. ### Rajinder

445
7
Jan 30, 2016
Hi
I just wanted some advice. I have a signal of 25mV. This i want to feed to a PIC A/D pin. However i eant to amplify this to say 2.5V. Would it be ok for me to use a non inverting opamp and suitable resistors to provide the gain/amplification? Do i need any care in selecting the resistor values?
Raj

2. ### Audioguru

2,999
672
Sep 24, 2016
Your opamp output must not exceed the maximum allowed input voltage of the PIC, it must not go negative and it must not go above the positive supply voltage of the PIC. Few opamps operate at such low power supply voltages (maybe 5V powered rail-to-rail opamp will be fine) so you will probably use a higher supply voltage for the opamp and a resistor attenuater to feed the PIC.

3. ### Rajinder

445
7
Jan 30, 2016
Hi
I was going to use a 5V single sided op amp. The gain i need is roughly 100.
I am now confused when you mention resistor attenuator?
If i did have a negative signal for example (say -0.7 to 1V), how could i use it with the PIC? What techniwue voukd i use to bring the signal up sonit stsrts from 0V? Would that mean using a inverting op amp.
Raj

4. ### Harald KappModeratorModerator

10,588
2,360
Nov 17, 2011
You'd then bring that within the range of allowed input voltage of the PIC by using e.g. an adder circuit.

5. ### Rajinder

445
7
Jan 30, 2016
I was thinking in the lines of diode clipper circuit fed into the A/D so the negative part of the signal is nit tajen into account.
Does that sound reasonable?

5,164
1,081
Dec 18, 2013
I thought you could measure negative voltages if your PIC has a -Vref pin. As long as you don't exceed the voltage range of the A/D then it should be fine. You will have to do some math in the software because if you have a reference supply of say +/- 1.5 V then at 0 V in the A/D will read half the full range of the A/D which is set by the reference used.
Thanks

Harald Kapp likes this.
7. ### Rajinder

445
7
Jan 30, 2016
Oh thanks for this. I thoughtbthst you cant exceed the levels of the pic by +/-0.3V of Vdd and Vss. So you cant go to 5.3V or -0.3V

5,164
1,081
Dec 18, 2013
You can't exceed any of the limits on any ports. You need to read the data sheet to find out what you are allowed to do with each port.

9. ### BobK

7,682
1,686
Jan 5, 2010
If you use a 5V rail to rail op amp, Microchip makes some good ones, then you have no worries, the output signal of the opamp will be between 0 and 5V. The PIC inputs also have clamping diodes to Vss and Vdd, so, if you put a resistor, say 1K between the output and PIC you are well protected against even noise spikes.

Bob

10. ### Audioguru

2,999
672
Sep 24, 2016
Is the A/D on the PIC measuring AC? Does it matter if maximum signal levels of the AC are clipping?
Is it OK to rectify the signal so that no signal produces 0V, medium signal produces +2V and maximum signal produces +4V?

11. ### Rajinder

445
7
Jan 30, 2016
Thanks for the replies. I have just learned that the signal is DC only after doing some work.
So my question is the bedt rechniques to bring 7V down to a readable input of the PIC A/D?
1. Is it ok to use a potential divider and the centre pin of the resistors straight to the PIC A/D?
2. The PIC A/D has source inpedance of 10K. Should my impedance of resistors be less than this. For example if i used a voltage divider of 2 x 3K9 resistors, my impedance would be 3K9 x 2, which is less than 10K of the PIC. Does thst seem correct? Or is the impedance calculated by 2 x 3K9 in parallel?
3. Would i need a voltage follower circuit using a opamp (rail to rail 5V) after the potential divider?
Raj

12. ### (*steve*)¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥdModerator

25,418
2,788
Jan 21, 2010
Depending on what you want to so, you might want to amplify the signal and then feed it into a peak and hold circuit.

This then gives you a DC voltage to read which corresponds to the peak voltage on one half of the waveform.

5,164
1,081
Dec 18, 2013
It would be better to divide the voltage down with a potential divider as you mention and then buffer the voltage with an op-amp into the A-D..
Thanks

14. ### Rajinder

445
7
Jan 30, 2016
Yes i was going to divide using voltage divider then feed into a voltage follower.
If i choose my impedance (voltage divider resistors in parallel) to be less than 10K. Then would that seem reasonable?

5,164
1,081
Dec 18, 2013
You don't have to worry about the resistor values too much because you are using a buffer. In the region of 10 K will be fine. Add a small capacitor across the lower resistor to help stabilise the divider. A 1 uF should be fine.

16. ### Rajinder

445
7
Jan 30, 2016
Thanks. Is he reason i dont have to worry because the op amp has low output impedance?

17. ### BobK

7,682
1,686
Jan 5, 2010
Yes, very low compared ti the 10K max that the PIC specifies.

BTW: you are the second person to state here recently that the PIC has an input impedance of 10K. That is incorrect. The datasheet specifies that the output impedance of the driving signal should be less than 10K, which is quite different.

Bob

Arouse1973 likes this.
18. ### Rajinder

445
7
Jan 30, 2016
Thanks for correcting me Bob.
Thanks for your help

Arouse1973 likes this.