Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 3 > ltage measurment Project simple problem..

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



ltage measurment Project simple problem..
Moderator:
RKRM

Post Reply
Follow this topic



ltage measurment Project simple problem..

blueblood posted on 27 Nov 2011 10:54 PM PST
Member
10 Forum Posts

Hello !! I have made a simple demo project of voltage measurment upto 5 volts in psoc.. it is working fine upto 2.49 volts.. but when i increase the voltage level greater then that voltage goes in negative values..

that means for 0 < Voltage < 2.499 volts, it displays proper values on lcd.. but for 2.5 volts it shows -2.5 volts and starts gradually decreasing as i increase voltage further.. for 5 volts it shows exact 0 on lcd..

so i made simple conversion logic to add simple 5 volts for values in between 2.5 to 5 volts to display it properly on lcd..

i am using psoc dev kit on 5 volts.. why i am facing that problem any guess ??

i have attached the peoject along this post..




Re: ltage measurment Project simple problem..

Bob Marlowe posted on 27 Nov 2011 12:19 AM PST
Top Contributor
1768 Forum Posts

Hi,

the C-language distinguishes strictly between signed and unsigned items. When you have a look at the API of your ADC ther is mentioned to use the ADC_Get16() - call to overcome problems with the sign-bit. Your var "result" is already a signed int.

Despite from the former used PSoC 1, you shoulod use for PSoC3 and 5 the given tpedefs

int16

uint16

int8

uint8

char8

int32

and uint32

which all you can +define or typedef for your PSAoC1 projects as well to maintain portability.

Your Creator-Libraries are rather olde, please consider an update (with the Cypress updeate Manager).

Have fun, happy coding

Bob



Re: ltage measurment Project simple problem..

Gautam Das posted on 27 Nov 2011 08:03 AM PST
Cypress Employee
742 Forum Posts

Hi blueblood,

 

Here are my suggestions after testing your project:

 

1) First and foremost, please update to the latest version of PSoC Creator. The link is http://www.cypress.com/?id=2494&source=header . I updated the componentes in the project to the latest ones.

2) The variable used to store the ADC converted value "result" was declared as "int". Declaring it as an uint8 is better in this case as you are using it in single ended mode with the input varying from Vss to Vdd (0V - 5V). Using "int" is advisable when using ADC in differential mode where both negative and positive values are to be expected.

3) As is advised in the ADC Component datasheet, it is recommended to use the GetResult16( ) API when ADC is configured for 8 bits mode or higher and GetResult32( ) when ADC is configured for 16 bit mode or higher. When "result" is declared as "uint16" variable, there is no error due to rolling off of the ADC value when the input slightly exceeds 5.00V. The roll-over error persists when GetResult8( ) is used.

4) For the ADC to continuously measure the input voltage, the ADC conversion mode is set to "Continuous". The  updating of LCD is done in an infinite loop { while(1) } after waiting for the conversion to end.

5) There are APIs which directly gives the counts in Volts, mVolts, and uVolts. The APIs are ADC_CountsTo_Volts( ), ADC_CountsTo_mVolts( ) and ADC_CountsTo_uVolts( ) respectively. You can use it to your advantage as it frees you from computing the Voltage explicitly.

6) When using these APIs, remember to set the right values for Vdda (as this is the reference). This can be done is .cydwr > System > Voltage Configuration. Set it to appropriate value as thje Vdda provided to the device.



Re: ltage measurment Project simple problem..

Gautam Das posted on 27 Nov 2011 08:48 AM PST
Cypress Employee
742 Forum Posts

The ADC has input Buffer which provides gains of 1,2,4 and 8. The noise performance of this internal buffer is better than the one using PGA.

The modified project is attached. Please note that the project is modified using PSoC Creator 1.0

You'll be able to use if if you update to Creator 1.0



Re: ltage measurment Project simple problem..

blueblood posted on 27 Nov 2011 02:18 PM PST
Member
10 Forum Posts

thanx dasg and bob !! it was really a great help !! i am going through learning phase of psoc and your help is immensly helpful !! thanx once again !! :)






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20