AN36179 Programmable Bipolar Analog Current Source, PSoC Style.pdf

AN36179
PSoC® 1 Programmable Bipolar Analog Current Source
Author: Dave Van Ess, Rajiv Vasanth Badiger
Associated Part Family: CY8C24x23, CY8C24x94, CY8C27x43, CY8C28xxx, CY8C29x66
Related Application Notes: AN2041
To get the latest version of this application note, or the associated project file,
please visit http://www.cypress.com/go/AN36179.
The unique configuration of PSoC® 1 switched capacitor blocks enables construction of a programmable bipolar
current source. This application note explains how to build a programmable current source using a couple of basic
PSoC User Modules.
Contents
1
2
3
4
5
6
7
1
Introduction ...............................................................1
PSoC Resources ......................................................2
2.1
PSoC Designer ................................................2
2.2
Code Examples ...............................................3
2.3
Technical Support ............................................4
Current Source .........................................................5
Working with In-Amps and MIPS ..............................6
PSoC Implementation...............................................6
Supply Rails..............................................................7
Application Example .................................................9
8
Solutions for Port 2 ................................................. 10
9
Summary ................................................................ 11
Document History............................................................ 12
Worldwide Sales and Design Support ............................. 13
Products .......................................................................... 13
PSoC® Solutions ............................................................. 13
Cypress Developer Community....................................... 13
Technical Support ........................................................... 13
Introduction
Many applications need an accurate and controllable current source. The unique PSoC MCU architecture enables
programmable current sources that source and sink 40 mA. This application note provides:


A brief explanation of instrumentation amplifier based (In-Amp) current sources.
Examples of analog current sources implemented with PSoC analog blocks.
www.cypress.com
Document No. 001-36179 Rev. *E
1
PSoC® 1 Programmable Bipolar Analog Current Source
2
PSoC Resources
Cypress provides a wealth of data at www.cypress.com to help you to select the right PSoC device for your design,
and quickly and effectively integrate the device into your design. In this document, PSoC refers to the PSoC 1 family
of devices. To learn more about PSoC 1, refer to the application note AN75320 - Getting Started with PSoC 1.
The following is an abbreviated list for PSoC 1:
2.1


Overview: PSoC Portfolio, PSoC Roadmap

Datasheets: Describe and provide electrical
specifications for the PSoC 1 device family.

Application Notes and Code Examples:
Cover a broad range of topics, from basic to
advanced level. Many of the application
notes include code examples.

Technical Reference Manuals (TRM):
Provide detailed descriptions of the internal
architecture of the PSoC 1 devices.

Product Selectors: PSoC 1, PSoC 3,
PSoC 4, or PSoC 5LP. In addition, PSoC
Designer includes a device selection tool.

Development Kits:

CY3215A-DK
In-Circuit
Emulation
Lite
Development Kit includes an in-circuit emulator
(ICE). While the ICE-Cube is primarily used to
debug PSoC 1 devices, it can also program PSoC
1 devices using ISSP.

CY3210-PSOCEVAL1 Kit enables you to evaluate
and experiment Cypress's PSoC 1 programmable
system-on-chip
design
methodology
and
architecture.

CY8CKIT-001 is a common development platform
for all PSoC family devices.
The MiniProg1 and MiniProg3 devices provide an
interface for flash programming.
PSoC Designer
PSoC Designer is a free Windows-based Integrated Design Environment (IDE). Develop your applications using a
library of pre-characterized analog and digital peripherals in a drag-and-drop design environment. Then, customize
your design leveraging the dynamically generated API libraries of code. Figure 1 shows PSoC Designer windows.
Note: This is not the default view.
1.
Global Resources – all device hardware settings.
2.
Parameters – the parameters of the currently selected User Modules.
3.
Pinout – information related to device pins.
4.
Chip-Level Editor – a diagram of the resources available on the selected chip.
5.
Datasheet – the datasheet for the currently selected UM
6.
User Modules – all available User Modules for the selected device.
7.
Device Resource Meter – device resource usage for the current project configuration.
8.
Workspace – a tree level diagram of files associated with the project.
9.
Output – output from project build and debug operations.
Note: For detailed information on PSoC Designer, go to PSoC® Designer > Help > Documentation >
Designer Specific Documents > IDE User Guide.
www.cypress.com
Document No. 001-36179 Rev. *E
2
PSoC® 1 Programmable Bipolar Analog Current Source
Figure 1. PSoC Designer Layout
2.2
Code Examples
The following webpage lists the PSoC Designer based Code Examples. These Code Examples can speed up your
design process by starting you off with a complete design, instead of a blank page and also show how PSoC
Designer User modules can be used for various applications. For more information on PSoC 1 code examples, visit
http://www.cypress.com/go/PSoC1Code Examples.
To access the Code Examples integrated with PSoC Designer, follow the path Start Page > Design Catalog >
Launch Example Browser as shown in Figure 2.
Figure 2. Code Examples in PSoC Designer
www.cypress.com
Document No. 001-36179 Rev. *E
3
PSoC® 1 Programmable Bipolar Analog Current Source
In the Example Projects Browser shown in Figure 3, you have the following options:




Keyword search to filter the projects.

Create a new project (and a new workspace if needed) based on the selection. This can speed up your design
process by starting you off with a complete, basic design. You can then adapt that design to your application.
Listing the projects based on Category.
Review the datasheet for the selection (on the Description tab).
Review the code example for the selection. You can copy and paste code from this window to your project, which
can help speed up code development, or
Figure 3. Code Example Projects, with Sample Codes
2.3
Technical Support
If you have any questions, our technical support team is happy to assist you. You can create a support request on the
Cypress Technical Support page.
You can also use the following support resources if you need quick assistance.


Self-help
Local Sales Office Locations
www.cypress.com
Document No. 001-36179 Rev. *E
4
PSoC® 1 Programmable Bipolar Analog Current Source
3
Current Source
Figure 4 shows a classic design of a current source built with an In-Amp.
Figure 4. Instrumentation Amplifier Based Current Source
1
vset
vout
iset
vload
Rset
Rload
Equation 1 shows the value of iset given Vout and Vload.
iset 
Equation 1
Vout  Vload
Rset
If the gain of the In-Amp is set to one, the Equation 2 holds true.
Equation 2
Vout  Vload  Vset
Combining these two equations results in Equation 3.
i set 
Equation 3
 Vset
Rset
Independent of the load resistance, the voltage across R set is always equal to –Vset. Equation 3 defines current. This
is independent of load resistance, considering the voltage across the resistor as constant.
Equation 3 is true only when Equation 2 holds true. The amplifier attempts to make the output, the difference of the
inputs. Vout and Vload cannot exceed the legitimate operating range for the specific In-Amp. For example, you cannot
drive a finite current into an infinite load. Therefore, it is possible to build a programmable current source with an InAmp, a resistor, and a reference voltage.
www.cypress.com
Document No. 001-36179 Rev. *E
5
PSoC® 1 Programmable Bipolar Analog Current Source
4
Working with In-Amps and MIPS
There are several good In-Amps (Analog Devices
AD620 and Burr Brown INA128). The PSoC
INSAMP User Module is not capable of operating
with only a gain of one. However, it is possible to
build a unity gain difference amplifier (DiffAmp)
using a Switched Capacitor Block User Module
(SCBLOCK). Although the DiffAmp is not as
robust as the In-Amp, you can include the
following for the same price:






Figure 5. PSoC Current Source Implementation
PSoC
Vset
DAC6_1
DiffAmp
Vload P2.1
-B
Buf0
P0.3
Vout
A
A DAC to set the reference voltage
Rset
A 4 MIPS CPU
iset = -Vset / Rset
Rload
4K to 32 Kbytes of Flash
256 bytes to 2K RAM
VloadRef
4 to 16 digital blocks
4 to 12 analog blocks
These are the prerequisites for building a
complete application.
5
PSoC Implementation
Figure 5 shows the PSoC implementation of a
current source built with a DAC, DiffAmp, and an
external current setting resistor. PSoC Designer
project is provided for this implementation.
Figure 6. Current Source User Module Placement
DAC6_1 controls Vset. It feeds the negative input
of DiffAmp. The amplifier’s output is buffered
(Buf0) and brought out on Port 0[3]. The input is
brought in on Port 2[1] and connects to the
positive input of DiffAmp. When the input is
connected to the output via Rset, a current is
sourced into Rload. Figure 6 shows the user
module placement for the example.
The DiffAmp is the SCBLOCK User Module
configured to be a differential unity gain amplifier.
Figure 7 shows the parameter selection.
Figure 7. Parameter Selection for DiffAmp
Note For background information on switch
capacitor design, refer to the application note
AN2041 – Understanding PSoC 1 Switched
Capacitor Analog Blocks.
Note For DAC6 input between –28 and –31, the
DAC column clock must be limited to 250 kHz.
For a DAC6 input greater than –28, the column
clock must be limited to a frequency not greater
than 2 MHz.
www.cypress.com
Document No. 001-36179 Rev. *E
6
PSoC® 1 Programmable Bipolar Analog Current Source
6
Supply Rails
The circuit shown in Figure 5 is capable of driving a current into an increasing resistive load until V out reaches infinity
or at least attempts to exceed the Vdd one that comes first. As mentioned in the Working with In-Amps and MIPS
section, the amplifier attempts to make the output the difference of the inputs. It does so if all the voltages are kept in
the linear ranges.
There are four unique voltage nodes for this circuit. They are:

VloadRef
This is the return path of the load resistor. It is a value you choose. It is V ss (gnd), Vdd, or AGND. You can have
any other voltage outside the supplies’ rails as long as the other three voltages are in their linear range.

Vset
This voltage sets the current level. It is an input into a switched capacitor block and accepts inputs up to, and
including, the supply rails as show in Equation 4.
Equation 4
Vss  Vset  AGND  Vdd
DAC6 generates Vset value in the range of AGND ± Vref. It is important that this voltage does not exceed the limits
set in Equation 4.

Vload
Figure 5 shows this signal as an input into a switched capacitor block and accepts inputs up to, and including, the
supply rails. Equation 5 defines this.
Equation 5
Vss  Vlaad  Vdd
Equation 6 shows that Vload is dependent on VloadRef, Rload, and Iset.
Equation 6
Vload  Vload Re f  iset  Rload
It is not possible to source a current into Rload, if VloadRef is set to Vdd or to sink a current from Rload if VloadRef is set
to Vss.

Vout
Figure 5 shows this signal as an output of an analog output buffer. Equation 7 shows it as dependent on iset,
Rload, and Rset.
Equation 7
Vout  VloadRef  iset  ( Rload  Rset )
The limitation of this buffer’s range is a function of the current it supplies. Each has its own limits which affects
the correct linear operation.
Figure 8 shows the typical range of an analog output buffer as a function of load impedance.
www.cypress.com
Document No. 001-36179 Rev. *E
7
PSoC® 1 Programmable Bipolar Analog Current Source
Figure 8. Buffer Range Vs Load Resistance, Vdd = 5 V
Figure 9 shows the range of an analog output buffer as a function of sourced load current.
Figure 9. Buffer Range Vs Load Current, Vdd = 5 V
Of course, “typical” is defined as the results from measuring one at the bench. Vout falls in the allowable ranges for
Figure 8 and Figure 9.
www.cypress.com
Document No. 001-36179 Rev. *E
8
PSoC® 1 Programmable Bipolar Analog Current Source
7
Application Example
Figure 10 shows a typical transducer that
converts some arbitrary physical parameter to a
resistance.
It is ground-referenced and varies from 0 to 300
ohms. The manufacturer recommends a 4-mA
stimulus to generate 0-V to 1.2-V response. This
response is then digitized. This requires:


Figure 10. Typical Transducer Requirements
Vresponse
0 - 300 ohms
0 - 1.2 V
Typical
Transducer
istimulus
4 mA
Rload
Generating a 4 mA current.
Shifting response to a valid PSoC ADC
range.
Vdd of PSoC is set to 5.0 V. VloadRef is set to Vss
(gnd). AGND is set to ½Vdd or 2.5 V. The DAC6
sets Vset to 1.25 V. This meets the requirements
set in Equation 4. Setting Rset to 316 ohms and
using Equation 2, the current is set to 4 mA. Vload
has a range from 0 to 1.2 V meeting the
requirements set in Equation 5. Figure 9 shows
that for a sourced current of 4 mA, Vout has a
range of 0.1 to 4.75 V. Vout is 1.25V larger than
Vload or 1.25V to 2.45 V, falling within the range
margins.
Figure 11. PSoC Implementation
PSoC
Vset = 1.25 V
DAC6_1
DiffAmp
Vload
-B
P2.1
Buf0
P0.3
Vout
A
AGND = 1/2Vcc
Rset = 316 ohms
iset = -Vset / Rset = 4mA
Rload = 0 to 300 ohms
VloadRef = Vss = gnd
www.cypress.com
Document No. 001-36179 Rev. *E
9
PSoC® 1 Programmable Bipolar Analog Current Source
8
Solutions for Port 2
The previous solution has Vload coming in on one of the port 2 switched-capacitor inputs. This enables a range that
includes the supply rails. However, not all PSoC 1 devices have port 2. An alternate design is presented in Figure 12.
Figure 12 looks identical to the implementation in Figure 5 except that Vload now feeds a Programmable Gain
Amplifier (PGA) configured as a unity gain Buffer that has its input on P0[1] and output feeding DiffAmp2.
Figure 12. PSoC Current Source, Sans Port 2
Figure 13. PSoC Implementation, Sans Port 2
PSoC
V set = 1.25 V
Buffer
Vload
DAC6_1
DiffAmp
-B
P0.1
Buf0
P0.3
Vout
A
AGND= 1 /2 Vdd
Rset = 316 ohms
iset = -V set / Rset = 4mA
Rload = 0 to 300 ohms
VloadRef = Vss = gnd
The primary difference is the acceptable voltage range for V load. This signal is now an input to the continuous time
analog block. Equation 8 defines the allowable range for Vload taken from the specifications in the device datasheet.
Equation 8
(Vss + 0.5) ≤ Vload ≤ (Vdd – 1)
The voltage across Rload ranges from 0 to 1.2 V. This violates the conditions of Equation 8. A simple solution is to add
a 130 ohm resister in series with the transducer load to boost V load by 0.52 V.
This ensures:


Vload of span of 0.52 to 1.72 V
Vout of span of 1.77 to 2.97 V
Both meet the range requirements set in Equation 8 and Equation 7. Of course, subtract the contributions of Rshift
from your result.
www.cypress.com
Document No. 001-36179 Rev. *E
10
PSoC® 1 Programmable Bipolar Analog Current Source
9
Summary
Understanding instrumentation amplifiers permits the construction of bipolar current sources. The PSoC MCU
architecture further enables you to build a complete programmable current source with only one external resistor.
About the Author
Name:
Rajiv Vasanth Badiger
Title:
Applications Engineer Staff
www.cypress.com
Document No. 001-36179 Rev. *E
11
PSoC® 1 Programmable Bipolar Analog Current Source
Document History
Document Title: AN36179 - PSoC® 1 Programmable Bipolar Analog Current Source
Document Number: 001-36179
Revision
ECN
Orig. of
Change
Submission
Date
Description of Change
**
1406903
SFV
03/30/2010
New application note.
*A
2552494
DWV
08/14/2008
Updated Section on DAC Clock Frequency.
*B
2901738
YARA
04/01/2010
Added reference to AN2089 in Document Properties. AN2089 is an older version
of this application note.
*C
3739205
RJVB
09/10/2012
Updated in new template.
*D
4664928
ASRI
02/18/2015
Updated the project to PSoC Designer 5.4.
Updated document template and reorganized the content.
Added PSoC Resources.
*E
4835488
ASRI
07/24/2015
Updated the project to PSoC Designer 5.4 SP1.
Updated the document title.
Updated Supply Rails and Solutions for Port 2.
www.cypress.com
Document No. 001-36179 Rev. *E
12
PSoC® 1 Programmable Bipolar Analog Current Source
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.
PSoC® Solutions
Products
Automotive
cypress.com/go/automotive
psoc.cypress.com/solutions
Clocks & Buffers
cypress.com/go/clocks
PSoC 1 | PSoC 3 | PSoC 4 | PSoC 5LP
Interface
cypress.com/go/interface
Cypress Developer Community
Lighting & Power Control
cypress.com/go/powerpsoc
Memory
cypress.com/go/memory
PSoC
cypress.com/go/psoc
Touch Sensing
cypress.com/go/touch
USB Controllers
cypress.com/go/usb
Wireless/RF
cypress.com/go/wireless
Community | Forums | Blogs | Video | Training
Technical Support
cypress.com/go/support
PSoC is a registered trademark and PSoC Creator is a trademark 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, 2010-2015. 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-36179 Rev. *E
13