Application Note AN2089 Programmable Bipolar Analog Current Source. PSoC Style By: Dave an Ess Associated Project: Yes Associated Part Family: CY8C25xxx, CY8C26xxx Summary The unique configuration of the PSoC switched capacitor blocks allows construction of a programmable bipolar current source. A detailed explanation of this function is provided demonstrating how to build a programmable current source using a couple basic PSoC User Modules. Introduction Many applications require an accurate, controllable current source. The unique PSoC MCU architecture allows programmable current sources that can source and sink 40 ma. This Application Note provides: A brief explanation of instrumentation amplifier (In-Amp)- based current sources. Examples of analog current sources implemented with PSoC analog blocks. Current Source 101 Figure 1 shows a classic design of a current source built with an In-Amp: Equation (1) shows the value of i given out and : i out = (1) R If the gain of the In-Amp is to one then Equation (2) holds true: out = (2) Combining these two equations results in Equation (3): i = (3) R v 1 i v out Independent of the resistance, the voltage across R is always equal to -. With the voltage across the resistor constant, the current is defined by Equation (3) and again is independent of the resistance. v R R Figure 1: Instrumentation Amplifier-Based Current Source Equation (3) is true only when Equation (2) holds true. The amplifier attempts to make the output the difference of the inputs. out and cannot exceed the legitimate operating range for the specific In-Amp. For example, you cannot drive a finite current into an infinite. So it is possible to build a programmable current source with an In-Amp, a resistor and a reference voltage. 10/7/2002 Revision A - 1 -
We ll See Your In-Amp and Raise You 4 MIPS Figure 3 shows the User Module placement for the example: They are several good In-Amps out there. (Analog Devices AD620 and Burr Brown INA128 come to mind.) The PSoC INSAMP User Module is not cable 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 our DiffAmp is not as robust as their In- Amp, for around the same price we also include: A DAC to Set the Reference oltage A 4 MIPs CPU 16 Kbytes of Flash 256 bytes RAM 8 Digital PSoC Blocks 10 More Analog PSoC Blocks Basically, all the stuff needed to build a complete application. Figure 3: Current Source User Module Placement The DiffAmp is Switched Capacitor (SCBLOCK) User Module configured to be a differential unity gain amplifier. Figure 4 shows the parameter selection: Figure 2 shows that PSoC implementation of a current source can be built with a DAC, DiffAmp and an external current-ting resistor: PSoC DAC6_1 DiffAmp Buf0 -B P0.3 P2.1 A out R i = - / R R Figure 4: Parameter Selection for DiffAmp Ref Figure 2: PSoC Current Source Implementation DAC6_1 controls. 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 R a current is sourced into R. For background on switch capacitor design, please review Application Note AN2041 Understanding Switched Capacitor Analog Blocks. 10/7/2002 Revision A - 2 -
Those Pesky Supply Rails The circuit shown in Figure 2 is capable of driving a current into an increasing resistive until out reaches infinity or at least attempts to exceed cc whichever comes first! As mentioned earlier, the amplifier attempts to make the output the difference of the inputs. It can only do so if all the voltages are kept in the linear ranges. There are four unique voltage nodes for this circuit: Ref out Each has its own limitations effecting correct linear operation. Ref This is the return path of the resistor. It can be any value you desire. That s right, any voltage you want! It will most likely be ss (gnd), cc, or AGND. But if you want some voltage outside the supplies rails that is fine as long as the other three voltages are in their linear range. This voltage s 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). ss + AGND (4) DAC6 generates value in the range of AGND +/- ref. It is important that this voltage not exceed the limitations in Equation (4). Figure 2 shows this signal to also be an input into a switched capacitor block and accepts inputs up to, and including, the supply rails. Equation (5) defines this: ss cc cc (5) Equation (6) shows that is dependent on Ref, R, and I. = + i R (6) Ref out Figure 2 shows this signal to be an output of an analog output buffer. Equation (7) shows it to be dependent on i, R, and R : = + i R + R ) (7) out Ref ( The limitation of this buffer s range is a function of the current it supplies. Figure 5 shows the typical range of an analog output buffer as a function of impedance, while Figure 6 shows the range as a function of sourced current: olts olts Typical Buffer Output Range cc = 5 olts 5.0 4.5 4.0 3.5 3.0 Load to cc 2.5 2.0 Load to AGND 1.5 Load to ss 1.0 0.5 0.0 Infinite 100K 10K 1K 100 33 Load (Ohms) Figure 5: Buffer Range vs. Load Resistance 5.0 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 0.0 Typical Buffer Output Range cc = 5olts -100-50 -20-10 Upper Rail Lower Rail -5-2 -1 0 1 2 5 10 20 50 Load (mamps Sourced) Figure 6: Buffer Range vs. Load Current 100 It should be apparent that it is not possible to source a current into R if Ref is to cc or to sink a current from R if Ref is to ss. Of course, typical is defined as the results from measuring one at my bench. out must fall in the allowable ranges for both figures. 10/7/2002 Revision A - 3 -
So Build Something Already For this example, Figure 7 shows an ACME Transducer (distributed by Wile E.) that converts some important physical parameter to a resistance: 0-300 ohms ACME Transducer R response 0-1.2 i stimulus 4 ma Figure 7: Acme Transducer Requirements It is ground referenced and varies from 0 to 300 ohms. The manufacturer recommends a 4 ma stimulus to generate a 0 to 1.2 response. This response can then be digitized. Two requirements are: Generate a 4 ma current. Shift response to a valid PSoC ADC range. Figure 8 shows the PSoC implementation: = -1.26 PSoC DAC6_1 Ref is to ss (gnd). AGND is to be ½ cc or 2.5. The DAC6 s to 1.26. This meets the requirements in Equation (4). Setting R to 316 ohms and using Equation (2), the current is to 4 ma. has a range to 0 to 1.2 meeting the requirements in Equation (5). Figure 6 shows that for a sourced current of 4 ma, out has a range of 0.1 to 4.75 olts. out is 1.26 larger than or 1.26 to 2.46, falling well within the range margins. This voltage can also be read with the range of the ADCs (AGND +/- ref or 1.2 to 3.8 ). The project associated with this note implements this example. But I Don t Have a Port 2 The previous solution had coming in on one of the port 2 switched-capacitor inputs. This allows it a range that includes the supply rails. It also requires having a port 2. If you don t have a port 2 you are not out of luck. Below are two solutions: The Marketing Solution Have you considered getting a part that includes port 2? Think of it as super sizing your order. When your children are small (and fine looking children they are), you buy them Smiley Meals. As they grow and consume more, you have the option of getting a lot more for a very reasonable price. It s the same for the PSoC MCU. For a few more pennies per pin you can get at least 8 more general purpose I/O pins, some with switched capacitor inputs. DiffAmp Buf0 -B P0.3 P2.1 A AGND = 1 / 2 cc R = 316 ohms out Like your children, your project is also growing. Let s face it; you spend far more time with your project than you do with your children. Splurge a little! Maybe super sizing is your best option. Maybe a little more PSoC resources means less time at work and more time with your children. How many times at a project s conclusion have you wished you had less resources? i = - / R = 4mA R = 0 to 300 ohms Ref = ss = gnd Figure 8: PSoC Implementation The Technical Solution Figure 9 looks very much like the implementation in Figure 2 except that now feeds a Programmable Gain Amplifier (PGA) configured as a unity gain Buffer that has its input on Port 0[2] and output feeding DiffAmp2. 10/7/2002 Revision A - 4 -
PSoC = -1.26 DAC6_2 The primary difference is the acceptable voltage range for. This signal is now an input to continuous time analog block. Taken from the specifications in the data, Equation (7) defines the allowable range for : P0.2 Buffer DiffAmp2 Buf2 -B P0.4 A AGND = 1 / cc R = 316 ohms out. 5 1 (7) ss + cc The voltage across R ranges from 0 to 1.2. This violates the conditions of Equation (7). A simple solution is to add a 130-ohm resister in series with the transducter to boast by.52. This makes, Ref = ss = gnd i = - / R = 4mA R shift = 130 ohms R = 0 to 300 ohms Figure 9: PSoC Current Source, Sans Port 2 Figure 10 shows the User Module placement for this implementation: having a span of 0.53 to 1.76 out having a span of 1.82 to 3.02 which both meet the range requirement in Equation (7) and Figure 6. Of course, remember to subtract the contributions of R shift from your result. The project associated with this note also implements this example. Conclusion Understanding Instrumentation Amplifiers permits the construction of bipolar current sources. The PSoC MCU architecture allows for a complete programmable current source to be built with only one external resistor. Figure 10: PSoC Implementation, Sans Port 2 10/7/2002 Revision A - 5 -
Cypress MicroSystems, Inc. 22027 17th Avenue S.E. Suite 201 Bothell, WA 98021 Phone: 877.751.6100 Fax: 425.939.0999 http://www.cypressmicro.com/ / http://www.cypress.com/aboutus/sales_locations.cfm / support@cypressmicro.com Copyright 2002 Cypress MicroSystems, Inc. All rights reserved. PSoC (Programmable System on Chip) is a trademark of Cypress MicroSystems, Inc. All other trademarks or registered trademarks referenced herein are property of the respective corporations. The information contained herein is subject to change without notice. 10/7/2002 Revision A - 6 -