View previous topic :: View next topic |
Author |
Message |
mictel
Joined: 24 May 2014 Posts: 14
|
Op Amps and ADCs using the same pin |
Posted: Sun Jun 15, 2014 5:59 am |
|
|
Can the same pin be assigned as Op Amp output and ADC input? Have not used PIC Op Amp function yet and did not find this topic when I searched.
It seems obvious this is possible since ADC inputs often come from Op Amp buffers and the Op Amp outputs are also ADC input pins. Would also be interested in example code necessary to set up an Op Amp with output read by the same pin ADC input.
Thanks in advance. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Sun Jun 15, 2014 7:56 am |
|
|
The data sheet is your friend....
There are only a couple of PIC's with this feature. Hence it's rarity.
It is a separate 'module'.
If you look at (for instance) the 16F527, and look at the op-amp section in the data sheet, you see that the output pins (OP1 and OP2) are also input pins to the ADC (AN7 & AN6 - why they are reversed, nobody knows...).
Once you enable the op-amp, it uses the input pins, and drives the pins that are it's outputs. If you select the analog channel, that connects to the same pin, then it reads the signal coming from the op-amp.
Yes, buffering the ADC is one of the things it is designed to do.
The connection diagram carefully shows the lines going to the ADC mux. |
|
|
mictel
Joined: 24 May 2014 Posts: 14
|
|
Posted: Sun Jun 15, 2014 9:00 am |
|
|
Thanks for the information. I am using the 16F1789 and the data sheet is not apparently as friendly. I did not see any association between the OPA module and the ADC module other than they are associated with the same I/O pin but perhaps I missed it. Just did not want to assume it worked that way. |
|
|
mictel
Joined: 24 May 2014 Posts: 14
|
|
Posted: Sun Jun 15, 2014 9:06 am |
|
|
The data sheet on the 16F1789 OPA Module does not show any lines going to the ADC Mux so then I assume you can not read the OP Amp output with the ADC channel assigned to the same I/O pin on the 16F1789. That means you have to use another ADC channel/pin connected to the Op Amp output in order to read the Op Amp voltage using an ADC. Is that correct or am I missing something? Thank You! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Sun Jun 15, 2014 11:45 am |
|
|
I read the datasheet and agree, you'll have to connect the opamp output to an ADC input. Seems there's a whack of ADC inputs so hopefully you have a couple spares to use!!
hth
jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Sun Jun 15, 2014 2:17 pm |
|
|
If you look at the connection diagram. Table 1.
OPA2OUT routes directly to AN10. OPA1OUT to AN1. For the larger devices OPA3OUT to AN21.
No external connections needed.
You can also use the op amp outputs to feed comparator inputs as well if you want.
The point is that once the op-amp is configured, it _drives_ the corresponding pins that are connected to it's output terminal. The pin functions just as if it is being driven by an external source, as far as the other peripherals are concerned. |
|
|
mictel
Joined: 24 May 2014 Posts: 14
|
|
Posted: Sun Jun 15, 2014 9:11 pm |
|
|
Well that is the way I had hoped it would work so you don't have to use up other ADC pins but was not sure. The 16F527 made things even more confusing with specific block diagrams showing one of the OP Amps associated with an ADC Mux.
Thank you for sharing your experience on how the Op Amp pins work with the associated ADC channels. |
|
|
|