Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 3 > ADC Peak Value

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



ADC Peak Value
Moderator:
RKRM

Post Reply
Follow this topic



ADC Peak Value

vgy posted on 14 Feb 2013 9:48 AM PST
Top Contributor
133 Forum Posts

Hi to all,

             I took with 16 bit , 2000 samples per second, input to the adc is 2.04 v. initially it showing correct value of 69AE but after some time it is diaplaying B900, it is showing same value for any input after dispalying correct value after some time, i am not able to find where i went wrong. here i am attaching the Project.please let me know

Thanks




Re: ADC Peak Value

Bob Marlowe posted on 14 Feb 2013 11:51 AM PST
Top Contributor
1768 Forum Posts

Unfotunately the indentation of your source-file has got lost, so it is difficult to read.

What I found at first sight is: in the line containing

for (i = 0; i < ADC_Sample_Index; i++)    

the variable i is only an int8 (-128 to 127) while ADC_Sample_Index is declared as an int16 (-32768 to 32767). So the loop will not run as expected for ADC_Sample_Index greater 127.

Are you trying to find the maximum? That you can do easier by comparing the actual ADC-value against the current maximum. When ADC is greater, save the number of the measurement and adjust the current maximum.

 

Happy coding

Bob

 



Re: ADC Peak Value

danaaknight posted on 14 Feb 2013 12:14 PM PST
Top Contributor
1773 Forum Posts

Hi, you had several inconsistancies, like declaring i as int8 rather than uint16 (its value

ranges to 2000, its used as an index hence always +), and others.

 

updated main.c attached

 

Regards, Dana.



Re: ADC Peak Value

Bob Marlowe posted on 14 Feb 2013 12:18 PM PST
Top Contributor
1768 Forum Posts

Anotheer issue I just found is that after the first loop through 2000 samples the outermost while willo be executed again (wich is desired) all your values you initialized with the declaration now have not the original values you'd like to have them,

 

Bob



Re: ADC Peak Value

danaaknight posted on 14 Feb 2013 01:15 PM PST
Top Contributor
1773 Forum Posts

Looks like I missed the attachment.

 

Regards, Dana.






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: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20