Download Three OPAMP instrumentation amplifier

PSoC1 3-Opamp INSAMP
Project Name: Example_INSAMP
Programming Language: C
Associated Part Families: CY8C24x23, CY8C27x43, CY8C29x66
CY8C24x94, CY8C21x34
®
Software Version: PSoC 1 Designer™ 5.2
Related Hardware : CY3210 PSoCEval1 Board
Project Objective
®
This project demonstrates the operation of INSAMP user module with three Opamp topology of the PSoC 1
device.
Overview
In this project, a differential signal is applied at the input of an instrumentation amplifier. Both the amplified signal
and the common mode output voltage are routed to analog output pins. The output of the INSAMP is also fed to
an ADC and the measure voltage is displayed on an LCD.
User Module List and Placement
The following table lists the user modules used in this project and the hardware resources occupied by each user
module.
User Module
Placement
INSAMP
ACB00 (Non inverting input)
ACB01 (Inverting input)
ASD11 (Conversion amplifier)
ADCINCVR
ASC21 (Integrator)
DBB00 (Counter)
DBB01 (PWM16_LSB)
DCB02 (PWM16_MSB)
LCD
P2[0] to P2[6]
RefMux
ACB02
User Module Parameter Settings
The following tables show the user module parameter settings for each of the user modules used in the project.
INSAMP
Parameter
AnalogBus
Value
AnalogOutBus_1
Comments
Output of instrumentation amplifier is routed to analog
output buffer 1.
CommonModeOut
Via NON_INV Block
The common mode signal is brought out using the Non
Inverting block on Analog Column 0 and through the
Analog output buffer to P0[3]
DifferentialGain
2.000
See Note
Conversion Gain
1.000
See Note
1
Note
The overall gain of the instrumentation amplifier is the product of differential gain and conversion gain. The
differential gain is set by resistive dividers in the CT blocks and the Conversion gain is set by the ratio of input and
feedback capacitors in the SC block. In this project the overall gain of the instrumentation amplifier is 2.000.
The CommonModeOut signal provides the common mode voltage of the differential input signal and can be
routed to an external pin. In practical applications, this signal can be used to improve the noise immunity of a
system by connecting to a shield around the +ve and –ve input signals.
The three OpAmp topology INSAMP uses an SC block for the Conversion Gain section. The analog column
clock for the column that has the SC block should not exceed the maximum column clock specification. Refer
the user module data sheet for the maximum column clock value for various analog powers. In this project, the
column clock for the INSAMP is set to VC2 which is 1 MHz.
ADCINCVR
Parameter
Value
Comments
Input
AnalogOutBus_1
Output of instrumentation amplifier is routed to the input of
ADCINCVR through the analog output buffer1.
Clock_Phase
Norm
Phi1 > Acquire charge
Phi2 > Transfer charge
Clock
VC2
Column clock for ADCINCVR is 1 MHz.
ADC Resolution
13 Bit
Sampled data is represented using 13 bits.
Calc Time
45
Time taken for CPU to calculate intermediate integration
result is 45 data clock.
Data Format
Signed
12 bits are used to represent magnitude and one bit is used
to represent sign.
Notes

The Clock phase parameter is set to be the opposite of the clock phase of the SCBLOCK, which sources the
data. In the default configuration of INSAMP, SCBLOCK uses the clock phase as “Normal”. So, the ADC’s
clock phase is set to “Swap”. More details on the clock phase can be found in the below article.
PSoC 1 ADCs – The Five Golden Rules


CalcTime is calculated using the data clock and the resolution of the ADC. Refer to the UM data sheet for the
formula and calculations.
The column clock to the ADCINCVR should be same as the data clock. In this case, the column clock to
Analog Column 2 should be set to VC2. More details on this can be found in the same article, PSoC 1 ADCs
– The Five Golden Rules.
RefMux
Parameter
Reference Select
Value
AGND
Comments
AGND is routed to P0[4] through analog output buffer2.
Note: The ReMux is used to bring out the internal Analog Ground to P0[4]. The AGND is used as the -ve input
for the INSAMP.
2
LCD
Parameter
Value
Comments
LCDPort
Port_2
Port 2 is used to send data to LCD
BarGraph
Disable
Bar graph is not used in this project
Global Resources
Important Global Resources
Parameter
Value
Comments
CPU Clock
SysClk/2
Sets the CPU frequency to 12 MHz.
VC1
12
Divide 24 MHz system clock by 12 to get 2 MHz clock.
VC2
2
Divide VC1 clock by 2 to get 1 MHz clock, which is given as
column clock for ADCINCVR user module.
Analog Power
SC On/Ref High
Set the maximum operating power of analog blocks to Ref
High.
Ref Mux
(Vdd/2)±(Vdd/2)
Ref High = 5 V
Ref Low = 0 V
AGND = 2.5 V
All other global resources are left at the default value because they are not specific to this project.
Pin Configuration
Pin Out
Pin
Select
Drive
Direction
Port 0_1
Analog input
High Z analog
Input
Port 0_2
Analog input
High Z analog
Input
Port 0_5
AnalogOutBuf_1
High Z analog
Output
Port 0_4
AnalogOutBuf_2
High Z analog
Output
Port2 _0-Port2_6
StdCPU
Strong
Output
3
Hardware Connections
The following figure shows the schematic of the project.
P0[1] is the +ve input and P0[2] is the –ve input to the INSAMP. AGND is brought out on P0[4] and is tied to the
–ve input of the INSAMP. The +ve input to the INSAMP comes from potentiometer VR1. The analog output of
the INSAMP is available on P0[5]. The common mode output of the INSAMP is available on P0[3]. In practical
applications, the common mode signal is used to increase the noise immunity of the system by creating a guard
trace around the +ve and –ve input signals and connecting this guard trace to the common mode voltage.
The project can be tested using CY3210 – PSoC Eval1 board. To test the project, make the following
connections:





Connect P0[1] of J6 to VR of J5. This is the +ve input to the INSAMP
Connect P0[2] of J6 to P0[4] of J6. This is the –ve input to the INSAMP
Connect LCD module to J9 header
Connect a voltmeter between P0[5] and P0[4] of J6 header to measure the output of INSAMP
The Common mode voltage output may be measured on P0[3] of J6
4
Operation
On program execution, all hardware settings from the device configuration are loaded into the device and main.c
is executed.
The following operations are performed inside main.c.
1. Enable global interrupts.
2. Start RefMux user module.
3. Start instrumentation amplifier in high power mode. The instrumentation amplifier becomes operational at this
point and needs no more CPU intervention. All the code that follows is to convert the INSAMP output to
digital value and display on the LCD.
4. Start incremental ADC in high power mode.
5. Start LCD.
6. Run the ADCINCVR in continuous sampling mode.
7. Wait for the ADCINCVR output data to be ready. If ADCINCVR output data is available, go to step 8. Else go
to step 7.
8. Get the converted data from ADCINCVR and clear the status flag.
9. Multiply ADCINCVR output data by step size of analog to digital conversion. (Step size is calculated by the
user and the calculated value is defined as macro using #define directive in the top of main.c.
Step size = (RefHigh - RefLow) / (2^Resolution)).
10. Make the cursor position on LCD as row 0 column 0.
11. Display the String “INSAMP OUTPUT” on LCD.
12. Make the cursor position on LCD as row 1 column 0.
13. Clear previously displayed value on LCD.
14. Make the cursor position on LCD as row 1 column 0.
15. Convert the float value obtained from step 9 to ASCII using ftoa() function and display the string returned by
the ftoa() function on LCD.
16. Display the character “V” on the LCD in current cursor position.
17. Go to step 7.
5
Testing the Project
To test the project using CY3210 PSoCEval1 board, follow these steps:
Make the connections as shown in the Hardware connections section.
Vary the position of potentiometer to change the input to the INSAMP. Measure the input voltage between P0[1]
and P0[2] and the output voltage between P0[4] and P0[5]. The output voltage should be (2 * Input voltage). At
the same time, the output voltage is displayed on the LCD.
For example, if the differential signal input between P0[1] and P0[2] is 1 V, then the output of instrumentation
amplifier between P0[4] and P0[5] is approximately 2 V and the LCD displays the voltage.
------------------------------------------------------------------------------------------INSAMP OUTPUT
2.0458327 V
------------------------------------------------------------------------------------------Experiment with different values of Differential and Conversion gains and verify that the INSAMP is operating
correctly.
6
PSoC is a registered trademark and PSoC Designer is a trademark of Cypress Semiconductor Corporation. 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: 408-943-2600
Fax: 408-943-4730
http://www.cypress.com/
© Cypress Semiconductor Corporation, 2009-2011. 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.
7