AN2223 PSoC 1 - Approximating an Opamp with a Switched Capacitor Integrator.pdf

AN2223
PSoC® 1 – Approximating an Opamp with a Switched Capacitor Integrator
Author: Dave Van Ess
Associated Project: Yes
Associated Part Family: CY8C24xxx, CY8C27xxx,
CY8C28xxx, CY8C29xxx
Software Version: PSoC Designer™ 5.1 SP1.1
Related Application Notes: AN2041, AN2168,
AN16833, AN2155
Abstract
A switched capacitor integrator can approximate the functionality of an opamp. You do this by exploring the opamp’s
characteristics and learn how they are similar to an integrator. Next you create an integrator (a faux opamp) using
®
PSoC 1 switched capacitor blocks. Examples of a voltage follower and a programmable gain amplifier demonstrate
the use of a faux opamp in real-world applications.
Introduction
Figure 1. The Ideal Opamp
Opamps have simplified circuit design for engineers. They
form a basic building block for the analog and mixed-signal
design. PSoC 1 analog blocks, both continuous time (CT)
and switched capacitor (SC) do not have a native opamp
mode. They are wired so that they can create PGAs,
insamps, filters, integrators, and so on. However, in some
designs you only need a plain opamp. This application note
shows you how to configure a SC block so that it
approximates the functionality of an opamp.
You see:
The ideal opamp has the following characteristics:

A brief explanation of how an opamp works.

Infinite gain

An explanation of how a SC integrator can emulate an
opamp (faux opamp).

Infinite bandwidth

Examples of faux opamp circuits.

Infinite input impedance

This application note does not give in depth information
about SC blocks. For more information see AN2041 –
Understanding PSoC 1 Switched Capacitor Analog
Blocks.

Zero output impedance

Zero input offset error

Zero phase delay

Zero noise
Opamp Primer: The Ideal Opamp

Zero power consumption
An ideal opamp is shown is Figure 1.

Zero cost

Available off-the-shelf everywhere

Free shipping for any size order
They are fabricated from Utopian Nitrate and are packaged
in Impossibilium. The Ideal opamp is only a model to help
with the design and analysis of opamp circuits.
www.cypress.com
Document No. 001-33763 Rev. *D
1
PSoC® 1 – Approximating an Opamp with a Switched Capacitor Integrator
Figure 3. Typical Integrator Bode Plot
Opamp Golden Rules
From the ideal opamp characteristics two golden rules are
obtained that simplify the analysis of opamp circuits.

The output attempts to do whatever is necessary to
make the voltage difference between its inputs zero.

The inputs draw no current.
Gain
If there is a negative feedback:
Real World Compensated Opamp
In the real world opamps are not ideal; they have many
non-idealities such as finite gain and phase delay. Phase
delay can introduce instability into opamp circuits. To
reduce the possibility of instability (oscillations), most
widely used commercial opamps have frequency
compensation. This reduces the chance of oscillation
when the opamp is connected in a feedback network. A
Bode plot of a generic compensated opamp is shown in
Figure 2.
Gain
Differential Switched Capacitor
Integrator
Open Loop Gain
Figure 4. Differential Input SC Integrator
φ1
VinA
CA
VinB
GBW
The compensated opamp has an open loop DC Gain and
rolls off to unity gain at a frequency known as the gain
bandwidth (GBW). A compensation pole is located at
GBW/Gain. The transfer function is shown in Equation 1.
Gain
s
1+
 GBW 
2π 

 Gain 
Equation 1
Equation 1 and Figure 2 show that the compensated
opamp is actually a high gain low pass filter (LPF). Due to
this an opamp can also be considered as an integrator
with saturated gain at lower frequencies. Equation 2
shows the simplified transfer function; Figure 3 shows the
typical integrator Bode plot.
2πGBW
s
www.cypress.com
Equation 2
CF
φ2
φ2
CB
φ2
Frequency
H ( s) ≈
For frequencies greater than the roll off point, the transfer
function and bode plot of an opamp approximate an
integrator. For closed-loop control circuits, an integrator
can be used in place of an opamp.
An integrator can be created in PSoC 1 SC blocks; its
implementation is shown in Figure 4.
Figure 2. Typical Opamp Bode Plot
H (s) =
Frequency
φ1
Vout
φ1
The transfer function is shown in Equation 3.
 f s Ci

CF
H (s) ≈ 
s


: C =C =C
A
B
i
Equation 3
Since SC integrators can function as opamps but actually
are not opamps, we refer to them as faux opamps. For
more information on SC blocks see AN2041 ®
Understanding PSoC 1 Switched Capacitor Analog
Blocks.
As stated earlier, the opamp embedded in the SC block
cannot natively be used as a standalone opamp. Thus the
need for an SC integrator that approximates the
functionality of an opamp in closed-loop systems is a
must.
Document No. 001-33763 Rev. *D
2
PSoC® 1 – Approximating an Opamp with a Switched Capacitor Integrator
Figure 5. Voltage Follower Schematic
Programmable GBW
Combining equations 2 and 3 produces the GBW value for
a SC integrator, shown in Equation 4.
GBW =
f s Ci
2π CF
Equation 4
VinA
The SC block power settings and bias levels determine
the maximum sample frequency (fs). Table 1 shows the
maximum sample frequency for all six power and bias
settings. These settings are configured in the global
resources window of PSoC Designer. Power is set by
changing the analog power setting; bias is changed by
changing the opamp bias setting.
Table 1. Power Settings
Power Setting
CA
CF
PSoC
φ2
φ2
P0.3
P2.3
Changing the values of Ci (CA CB), CF, or fs alters the
GBW. Flexible control of GBW enables you to design a
stable closed-loop feedback system.
φ1
P2.1
CB
φ2
VinB
Vout
φ1
φ1
ASC10
With negative feedback established, the output must
become equal to the VinA for the input difference to be
zero; remember the golden opamp rules discussed earlier.
To create a faux opamp an SCBLOCK needs to be placed
in a PSoC Designer project. The SCBLOCK is located in
the generic folder of the user module catalog. Figure 6 is
an example of the user module placement.
Max fs
High Power High Bias
4 MHz
High Power Low Bias
2 MHz
Medium Power High Bias
1 MHz
Medium Power Low Bias
500 kHz
Low Power High Bias
250 kHz
Low Power Low Bias
125 kHz
Figure 6. Faux Opamp User Module Placement
Examples
Now that we have covered how a SC integrator can act as
an opamp, we are going to go through a few examples of
how this faux opamp can be used in real world
applications. Included with this application note is a basic
example project that the reader can use to implement the
examples discussed as following.
Example I (Voltage Follower)
In this example the faux opamp acts as a voltage follower
or buffer. VinA is the Non-Inverting input and VinB is the
Inverting Input. To create the voltage follower/buffer the
output needs to be fed back to VinB. The schematic for the
follower is shown in Figure 5.
www.cypress.com
The SCBLK user module should be configured as shown
in Figure 7.
Document No. 001-33763 Rev. *D
3
PSoC® 1 – Approximating an Opamp with a Switched Capacitor Integrator
Figure 7. Parameter Selections for FAUX SCBlock
Figure 8. Global Resources
For more information on these configuration settings refer
to AN2041 – Understanding PSoC 1 Switched Capacitor
Analog Blocks
Using Equation 4 as a template, the parameters are
plugged in to determine GBW. The calculation is shown in
Equation 5.
The following system parameters must be set:
GBW =
1.
2.
Ref Mux to (Vdd/2) +/- (Vdd/2). This sets AGND to
Vdd/2. For more information on the Ref Mux and the
meaning of the different settings see: AN2219 ®
PSoC 1 Selecting Analog Ground and Reference.
Set VC1 to 4 MHz. This value is selected as the
column clock frequency.
fs =
f cc 4.0 MHz
=
= 1MHz
4
4
Equation 5
The global resource parameters are shown in Figure 8.
f s Ci 1MHz 26
=
= 129kHz
2π C F
2π 32
Equation 6
When this project is actively running, the output voltage
can be measured at Vout (P0[3]). The output voltage
follows the input voltage (P2[1]).
The faux opamp is useful in a classical voltage follower
just as the typical opamp is. However, the faux opamp has
other advantages, such as programmable bandwidth and
programmable gain. The following examples highlight
some other features of the faux opamp that go beyond the
traditional opamp.
Differential Input Capacitors
All the analysis until now has been done with the input
capacitors ( C A , C B ) equally weighted. Doing so causes
the opamp golden rules to apply. However, if the inputs
have different weights, then the output attempts to make
the differential input capacitor charge transfer zero. This is
expressed in Equation 6.
VinA C A − VinB C B = 0
Equation 7
Example II (Programmable Gain)
In the previous example the output voltage followed the
input. For this example we want the output voltage to be
double the input voltage. Remember that the output is
relative to AGND (Vdda/2). Equation 7 shows how to
calculate the output voltage.
www.cypress.com
Document No. 001-33763 Rev. *D
4
PSoC® 1 – Approximating an Opamp with a Switched Capacitor Integrator
Vout = AGND + (Vin − AGND)
CA
CB
Figure 10. Switched Polarity Component
Equation 8
To get 2x gains, the input capacitors need to be sized
correctly
CA = 26
CB = 13
These two parameters are changed as shown in Figure 9.
Figure 9. Parameter Selection Voltage Doubler Out
The new faux opamp golden rule must be expanded to
reflect this change. It is shown in Equation 9.
AsignVinAC A − VinB C B = 0
Equation 10
Example III (Programmable Gain with
Polarity)
With the new opamp shown in Figure 10, you can create
negative gain. For this example, a gain of –2 needs to be
applied to the input. For this configuration the output
follows Equation 10.
Vout = AGND + ASign (Vin − AGND)
CA
CB
Equation 11
Looking at the previous example it is known how to get a
gain of 2. All you need to do is switch the polarity of the A
input.
One solution is:
CA = 26
CB = 13
When this project is actively running, the output follows
equation 7 with the parameters set in Figure 9.
The GBW is determined by the value of the capacitor
connected to the feedback path. It is calculated in
Equation 8.
GBW =
f s C B 1MHz 13
=
= 64.7 kHz
2π C F
2π 32
Asign = neg
These three parameters are changed as shown in
Figure 11.
Figure 11. Parameter Selection –2 gain
Equation 9
You can change the input capacitors to create a wide
variety of input-to-output voltage ratios; creating a
programmable gain amplifier out of SC blocks.
Changing Input Polarity
An opamp cannot have two negative inputs. However, a
faux opamp can. The SC blocks allow for switching the
polarity of VinA. This results in the component shown in
Figure 10.
www.cypress.com
Document No. 001-33763 Rev. *D
5
PSoC® 1 – Approximating an Opamp with a Switched Capacitor Integrator
When this project is actively running, the output voltage
follows Equation 10, using the parameters from Figure 11.
Now you can create a programmable gain and polarity
amplifier with the faux opamp.
A transistor can be added to the output as shown in Figure
12 to increase the current capacity of the output, thus
creating a programmable power supply.
Figure 12. Programmable Power Supply
Refhigh φ1
VinA
CA
CF
P0.3
VinB P2.3
CB
φ2
Equation 12
Rshunt
Note that the VinA input does not have to come from an
external source. It can be tied to an internal voltage like
RefHi, or the output of a VDAC.
SC blocks are easily configured as integrators. The
integrator then functions as an opamp. Parameterization
of the capacitor values and sample frequency enables
precise control of GBW. Intentional misbalancing of the
input capacitor and adjusting the polarity of the VinA input
enables some unique PSoC applications.
Vout
φ1
I out =
CA
CB
Summary
PSoC
φ2
φ2
AGND + Asign (Vin − AGND)
φ1
ASC10
About the Author
You can create a programmable current source by adding
a shunt resistor to the emitter of the transistor as shown in
Figure 13.
Name:
Dave Van Ess
Title:
Member of Technical Staff,
Applications Engineer, Cypress
Semiconductor
[email protected]
Figure 13. Programmable Current Source
Refhigh φ1
VinA
CA
CF
Contact:
PSoC
Load
φ2
φ2
I out
P0.3
CB
VinB P2.3 φ2
φ1
Rshunt
φ1
ASC10
The shunt resistor causes the output voltage to be
converted into current. This current is available at the
collector of the transistor. The output current is determined
by the parameters in Equation 11.
www.cypress.com
Document No. 001-33763 Rev. *D
6
PSoC® 1 – Approximating an Opamp with a Switched Capacitor Integrator
Document History
®
Document Title: PSoC 1 – Approximating an Opamp with a Switched Capacitor Integrator – AN2223
Document Number: 001-33763
Revision
ECN
Orig. of
Change
Submission
Date
Description of Change
**
1499983
MAXK
10/04/2007
New application note.
*A
2678525
TDU
03/25/2009
Updated software version and associated PSoC project
3253271
TDU
05/13/2011
Updated Project to 5.1, Fixed Grammar and Structure of AN, Updated Title and
Abstract to better reflect contents of AN, and Updated Template.
3441042
TDU
11/21/2011
*B
*C
Template update
Updated Project files
*D
4382168
www.cypress.com
MQY
05/16/2014
Sunset review. Minor copy editing. Removed link on Pg. 8 to Optical Navigation
Sensors.
Document No. 001-33763 Rev. *D
7
PSoC® 1 – Approximating an Opamp with a Switched Capacitor Integrator
Worldwide Sales and Design Support
Cypress maintains a worldwide network of offices, solution centers, manufacturer’s representatives, and distributors. To find
the office closest to you, visit us at Cypress Locations.
Products
PSoC® Solutions
Automotive
cypress.com/go/automotive
Clocks & Buffers
cypress.com/go/clocks
psoc.cypress.com/solutions
Interface
cypress.com/go/interface
PSoC 1 | PSoC 3 | PSoC 5
Lighting & Power Control
cypress.com/go/powerpsoc
cypress.com/go/plc
cypress.com/go/memory
Cypress Developer Community
Community | Forums | Blogs | Video
| Training
Memory
PSoC
cypress.com/go/psoc
Touch Sensing
cypress.com/go/touch
USB Controllers
cypress.com/go/usb
Wireless/RF
cypress.com/go/wireless
PSoC is a registered trademark of Cypress Semiconductor Corp. "Programmable System-on-Chip" and PSoC Designer are trademarks of Cypress
Semiconductor Corp. All other trademarks or registered trademarks referenced herein are the property of their respective owners.
Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
Phone
Fax
Website
: 408-943-2600
: 408-943-4730
: www.cypress.com
© Cypress Semiconductor Corporation, 2007-2014. The information contained herein is subject to change without notice. Cypress Semiconductor
Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any
license under patent or other rights. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control or
safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as
critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The
inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies
Cypress against all charges.
This Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwide
patent protection (United States and foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a
personal, non-exclusive, non-transferable license to copy, use, modify, create derivative works of, and compile the Cypress Source Code and derivative
works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypress
integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source
Code except as specified above is prohibited without the express written permission of Cypress.
Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the
right to make changes without further notice to the materials described herein. Cypress does not assume any liability arising out of the application or
use of any product or circuit described herein. Cypress does not authorize its products for use as critical components in life-support systems where a
malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support systems
application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.
Use may be limited by and subject to the applicable Cypress software license agreement.
www.cypress.com
Document No. 001-33763 Rev. *D
8