PSoC® 1 – Interfacing a Pressure Sensor – MPXM2102A CE57653 Project Name: Example_Pressure_Sensor Programming Language: C Associated Part Families: CY8C29/27/24/22 ® TM Software Version: PSoC Designer 5.0 SP1.1 Related Hardware: CY3210 – PSoC Eval1 Board Author’s Name: Pushek Madaan Objective ® CE57653 illustrates the interface between PSoC and a pressure sensor (MPXM2102A) and displays the pressure level on the LCD. Overview The MPXM2102A pressure sensor provides the differential analog voltage corresponding to the pressure applied. This value is amplified by the Instrumentation Amplifier and is then measured by ADCINCVR UM to calculate the pressure level, ranging from 0 kPa to 100 kPa, to display it on the LCD. Note MPXM2102A is used for example purpose only. Any analog pressure sensor can be integrated with PSoC subject to operating specifications. Block Diagram User Module List and Placement The following table lists user modules used in this code example and the hardware resources occupied by each user module. User Module Placement INSAMP ACB00, ACB01, ASD11 ADCINCVR ASC10, DBB00, DBB01, DCB02 LCD Software Implementation May 25, 2011 Document No. 001-57653 Rev. *A 1 [+] Feedback Example_Pressure_Sensor_CY8C29x66 User Module Parameter Settings The following tables show the user module parameter settings for each of the user modules used in the code example. INSAMP Parameter Value Comments Analog bus Disable Will NOT route the output of the INSAMP onto the analog bus. Common mode out No Connect Do not connect the common mode output. Differential gain 48.00 Set the differential gain to 48. Conversion gain 1.00 Set the conversion gain provided by SCBLOCK to 1. ADCINCVR Parameter Value Comments Input ASD11 Select the output block of the INSAMP as the input of ADCINCVR. Clock phase Swap See notes below Clock VC1 Selects the input clock of the ADCINCVR as the VC1. ADC resolution 13 Sets the resolution of the ADC to 13 bits. Calc time 8 See notes below Data format Unsigned Output will vary from 0 to 2^ADC Resolution – 1. Notes The parameter „Clock Phase‟ should be opposite to the SCBLOCK clock phase, which is sourcing the data. In the default configuration of INSAMP, SCBLOCK uses the clock phase as „Normal‟. Thus, it should be set to „Swap‟ in the ADC. If it is fed from a Continuous Time Block then it should be set to „Normal‟. CalcTime is calculated using the Data Clock and the resolution of the ADC. Refer to the User Module data sheet for the formula and calculations involved. LCD Parameter Value LCDPort Port 2 Comments Use Port 2 for connecting LCD Bargraph Disable Disable the Bar graph feature Global Resources Parameter Power setting [VCC / SysClk freq] Important Global Resources Value Comments 5.0 V/24 MHz Selects 5 V operation and 24 MHz SysClk CPU_Clock SysClk/2 Selects 12 MHz as the clock input for the CPU VC1 = SysClk/N 8 Set VC1 as 3 MHz. Ref Mux (VDD/2) +/- VDD/2 Set the RefHi as 5 V and RefLo as 0 V. May 25, 2011 Document No. 001-57653 Rev. *A 2 [+] Feedback Example_Pressure_Sensor_CY8C29x66 Pinouts Important Pin Configuration Interrupt Comments Configures the pin as analog input pin and connects it High Z Analog DisableInt to VIN+ of the sensor. Pin Select Drive P0[0] Analog input P0[1] Analog input High Z Analog DisableInt Configures the pin as analog input pin and connects it to VIN- of the sensor. P0[5] AnalogOutBuf_1 High Z Analog DisableInt Routes the AGND at P0[5] Note Other parameters may be left at their default values. Hardware Connections The schematic diagram for this code example is as follows. VCC 10K VCC U2 5 NC R4 10K C4 0.1UF Vcc +Vout -Vout Gnd 3 2 4 1 R5 10K VCC U1 CY8C29466-24PXI VCC R6 R7 10K 10K MAX2102A C6 0.01UF VIN+ 24 VIN- 4 25 3 C5 26 0.01UF 2 27 1 P0[0] P0[1] P0[2] P0[3] P0[4] P0[5] P0[6] P0[7] P2[0] P2[1] P2[2] P2[3] Ext AGND/P2[4] P2[5] Ext VREF/P2[6] P2[7] AGND 9 19 14 SMP XRES VSS XtalOut/SDATA/P1[0] XtalIn/SCLK/P1[1] P1[2] P1[3] EXTCLK/P1[4] SDA/P1[5] P1[6] SCL/P1[7] 28 20 8 21 7 22 6 23 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Vss Vdd Vee RS R/W E D0 D1 D2 D3 D4 D5 D6 D7 LCD 15 13 16 12 17 11 18 10 U2 is MPXM2102A which is a silicon piezoresistive pressure sensor providing linear voltage output. This is directly proportional to the applied pressure. It measures the pressure applied with respect to built-in reference vacuum and provides a differential analog signal. This device is ratiometric within the specified excitation range. It means that the sensitivity of the device is proportional to the excitation voltage applied. It is capable of measuring pressure ranging from 0 kPa to 100 kPa with a change of 0.2 mV/kPa. Because of limited ADC resolution, the signal is first amplified using an Instrumentation Amplifier which introduces the offset. To remove this offset Correlated Double Sampling (CDS) is used. For more details on CDS, refer to the application note AN2226. This schematic can be wired using the bread board area of the CY3210 PSoC Eval1 board. The LCD module should be placed on J9 on the board. Note: The PSoC‟s Internal AGND is routed to P0[5]. May 25, 2011 Document No. 001-57653 Rev. *A 3 [+] Feedback Example_Pressure_Sensor_CY8C29x66 Operation On reset, all hardware settings from the device configuration are loaded into the device and main.c is executed. The firmware performs the following operations: Global interrupt is enabled. All the modules are initialized with maximum power setting. ADCINCVR is initialized to run continuously. An infinite loop is entered where the following operations are performed: Connect the input of the instrumentation amplifier to the sensor output. Drop a few samples and measure the input signal. Connect the input of the instrumentation amplifier to the AGND pin (P0[5]). Drop a few samples and measure the offset. Calculate the signal value by subtracting the offset if the signal value is greater than offset. Calculate the Analog Voltage level by multiplying the calculated signal by 1.22 (resolution of ADCINC12 in mV). Convert the analog signal obtained by the previous step into kPa by dividing it with the sensitivity of the sensor. Convert this float value into the ASCII value using the „ftoa‟ function. Update the LCD with the new value. Note ® This code example is just to illustrate the interface between the PSoC and a Pressure Sensor (MPXM2102A) and is not tested for accuracy as it requires testing in a pressure chamber for calibration. The tests were performed on the basis of analog output of the Pressure Sensor. May 25, 2011 Document No. 001-57653 Rev. *A 4 [+] Feedback Example_Pressure_Sensor_CY8C29x66 Document History ® Document Title: PSoC 1 – Interfacing a Pressure Sensor – MPXM2102A Document Number: 001-57653 Revision ** *A ECN Orig. of Change Submission Date Description of Change 2809675 3266159 PMAD PRKR/PMAD 11/17/2009 05/25/2011 New example project for Pressure Sensor. The range of Pressure sensor is added in the overview. Steps to use CY3210 for the project are added. Added Block diagram. The project ported to PSoC Designer 5.1 SP1.1. Title changed from “Interfacing a Pressure Sensor – MPXM2102A” to ® “PSoC 1 – Interfacing a Pressure Sensor – MPXM2102A”. PSoC is a registered trademark of Cypress Semiconductor Corp. PSoC Designer 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: 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. May 25, 2011 Document No. 001-57653 Rev. *A 5 [+] Feedback