Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 3 > To find a Peak value of ADC

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



To find a Peak value of ADC
Moderator:
RKRM

Post Reply
Follow this topic



To find a Peak value of ADC

vgy posted on 15 Jan 2013 11:23 PM PST
Top Contributor
133 Forum Posts

 hi to all,

              here i am attaching bundle of  workspace. can any body help by modifying to get peak value of ADC

Regards

PRP




Re: To find a Peak value of ADC

vgy posted on 15 Jan 2013 11:27 PM PST
Top Contributor
133 Forum Posts

here i ataching bundled work space



Re: To find a Peak value of ADC

danaaknight posted on 15 Jan 2013 02:40 AM PST
Top Contributor
1773 Forum Posts

I have not looked at your project, but from the trigger val from ADC that

tells you a strip has been inserted, you keep doing ADC conversions,

saving the conversion if it is > last conversion, and keep going until

your ADC value falls below trigger value.

 

Re: To find a Peak value of ADC

danaaknight posted on 15 Jan 2013 02:55 AM PST
Top Contributor
1773 Forum Posts

Picture did not post, here it is -

 

 

Regards, Dana.



Re: To find a Peak value of ADC

danaaknight posted on 15 Jan 2013 03:04 AM PST
Top Contributor
1773 Forum Posts

I opened your project, you seem to be working with older ES silicon,

you should update your dev board if you are working with a Cypress

board.

 

http://www.cypress.com/?app=kitupgrade&CFID=1216625&CFTOKEN=65660931

 

Also you are using an older verison of Creator, you should be on 2.2

 

http://www.cypress.com/?id=2494

 

Regards, Dana.

 

 

 

 



Re: To find a Peak value of ADC

vgy posted on 15 Jan 2013 05:02 AM PST
Top Contributor
133 Forum Posts

 The development board i have is not my personal , so i have to use that only.



Re: To find a Peak value of ADC

vgy posted on 15 Jan 2013 09:41 PM PST
Top Contributor
133 Forum Posts

 

hi to all,

              i am getting an error of

 *** ERROR L127: UNRESOLVED EXTERNAL SYMBOL

    SYMBOL:  ADC_Samples

The command 'LX51.exe' failed with exit code '2'.

-------------------------------------------------------------------------------------------------------

Here is my code , Can any body help me where i went wrong.

-----------------------------------------------------------------------------------------------------

#define ADC_NUMBER_SAMPLES ( )            

 /* Initialize array elements to zero. */

     uint16 ADC_Samples[ ];

/* Defining and initializing the index */

     int16 ADC_Sample_Index = 0; 

///* Initiialize the average result */

     uint32 ADC_Sample_Max = 0; 

  /* Sample read from ADC */

      int16 ADC_Current_Sample = 0;  

/* Indicator for when sample is available */

     int8 ADC_Sample_Available = 0; 

void main()

{

    int8 i;

             /* Start the VDAC component */

                  VDAC8_2_Start();

    /* Start the opamp component */

          Opamp_1_Start();

             /* Sets the OpAmp power mode to high power */

          Opamp_1_SetPower(Opamp_1_HIGHPOWER);

             /* Start the VDAC component */

                   VDAC8_1_Start();

             /* Start the TIA component */ 

                   TIA_1_Start();

              /* Set the Resistive feedback to 40k ohms */

                    TIA_1_SetResFB(TIA_1_RES_FEEDBACK_40K);

              /* Set the capacitive feedback to 3.3pF */

                     TIA_1_SetCapFB(TIA_1_CAP_FEEDBACK_1_3PF);

             PGA_1_Start();

            /* Sets the PGA gain to 4 */

                     PGA_1_SetGain(PGA_1_GAIN_08);

            /* Sets the power mode to medium power */

                     PGA_1_SetPower(PGA_1_HIGHPOWER);

            /* Start the ADC */

                    ADC_DelSig_1_Start();   

             /* Start the ADC conversion */ 

                    ADC_DelSig_1_StartConvert(); 

                   CyGlobalIntEnable;                /* Uncomment this line to enable global interrupts. */

                    for(;;)

                    /* Place your application code here. */

            {

                               /* Check whether ADC conversion complete or not */

                                  if (ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_WAIT_FOR_RESULT))

                                          {

                                           /* Get the result */

                                             ADC_Current_Sample = ADC_DelSig_1_GetResult8();

                                             ADC_Sample_Available = 1;

                                            }

 

                                             /* Testing for sample available from the ADC */

                                         if (ADC_Sample_Available) 

                                              {

                                                ADC_Sample_Available = 0;

                                                 /* storing the sample into the array, based on the index */

                                                 ADC_Samples[ADC_Sample_Index++] = ADC_Current_Sample;       

                                                 ADC_Sample_Max = 0;                          

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

                         {

                          if(ADC_Samples[i]>ADC_Sample_Max)

                              {

                                   ADC_Sample_Max=ADC_Samples[i];

                              }

                                                   }

                               }

   }                    

}

 

 

 



Re: To find a Peak value of ADC

Bob Marlowe posted on 16 Jan 2013 01:15 AM PST
Top Contributor
1768 Forum Posts

Since you posted just the code and not the complete project we cannot compile it without getting a bunch of errors due to the missing componentst, pins etc..

 

What I can see so far is that you defined your array

uint16 ADC_Samples[ ];

But this does not allocate memory for it, only the pointer.

Better use

uint16 ADC_Samples[SampleCount};

or

ADC_Samples = malloc(sizeof(uint16) * SampleCount);

 

but all of the above should not cure your prime error-message.

 

Bob



Re: To find a Peak value of ADC

vgy posted on 16 Jan 2013 01:48 AM PST
Top Contributor
133 Forum Posts

Hi Bob,

here i am attaching the project .and i am using older version i.e creator 2.0



Re: To find a Peak value of ADC

danaaknight posted on 16 Jan 2013 04:41 AM PST
Top Contributor
1773 Forum Posts

Per Bob's suggestion, if you change this -

 

uint16 ADC_Samples[ ];// = {}; /* uint16 ADC_Samples[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; */

 

to this

 

uint16 ADC_Samples[ 15 ];// = {}; /* uint16 ADC_Samples[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; */

 

It compiles.

 

Regards, Dana.

 



Re: To find a Peak value of ADC

vgy posted on 16 Jan 2013 06:48 AM PST
Top Contributor
133 Forum Posts

hi Dana,

if i use  uint16 ADC_Samples[ 15 ]; it take only 15 samples , but i need more , so what else we can do.



Re: To find a Peak value of ADC

danaaknight posted on 16 Jan 2013 07:09 AM PST
Top Contributor
1773 Forum Posts

You can size that array larger. What exactly are you trying to do ? Average, or

store the entire reaction response curve in the array to then process ? If you

are trying to just get peak value then just comparing current sample against

last will get you there. You coould consider a peak detector as shown in following -

 

http://www.cypress.com/?rID=41001 but calculate droop for the implementation,

to make sure Vsignal does not droop more than 1 LSB, or there abouts.

 

of just do it with algorithim. from detect insertion -

1) Detect insertion

2) ADC conversion, save this in ADCtrigval

3) Save last conversion in ADColdvalue

4) ADC current conversion, bigger than ADColdvalue, then ADCpeak = ADCcurrent

5) ADCcurrent > ADCtrigval, goto 3

6) Done

 

Regards, Dana.

 



Re: To find a Peak value of ADC

vgy posted on 17 Jan 2013 11:35 PM PST
Top Contributor
133 Forum Posts

hi Dana,

               U mentioned to use Peak detection,but i have one doubt ragarding this peak detection.my doubt is suppose if we are getting multiple peaks eg. suppose we got first peak at V1 volts followed by a minimum and again a second peak  v2(v2>v1), whether the peak detector will detect V2 or V1.

Regards

PRP.



Re: To find a Peak value of ADC

Bob Marlowe posted on 17 Jan 2013 01:20 AM PST
Top Contributor
1768 Forum Posts

A simple comparision between a current value and the actual maximum value will always find THE maximum. The only question will be when to end the algorithm.

Time could be one. Set max seconds to scan input with a timer.

Drop of input from actual maximum larger than a pre-declared value

Both of the above.

 

Bob



Re: To find a Peak value of ADC

vgy posted on 17 Jan 2013 02:57 AM PST
Top Contributor
133 Forum Posts

Hi Bob,

            Could you explaim me a more elaborate way . example my timer is for 10 seconds and ADC is 8 bit with contiunous  mode and conversion rate is 8500 SPS.how can i stop ADC to stop conversions. the app ADC_Stop(); is not valid in PSoC 3 ES2 version.

Regards

PRP



Re: To find a Peak value of ADC

danaaknight posted on 17 Jan 2013 04:49 AM PST
Top Contributor
1773 Forum Posts

If the response contains more than one rersponse curve it wopuld be instructive

to understand what is causing the additional peak. Not being a chemistry expert,

let alone blood chemistry, I would venture a guess the chemistry proceeds to a

single peak then once reactive agent is exhausted recedes. So this would imply

electrical noise, strip re-positioning, non-uniformity of strip test chemicals, non uniform

electrode composition........

 

 

So does the minimum between peaks always look the same in time and value ?

Then you can discriminate in code based on value or time or both.

 

 

First you need to understand the problem before the solution can be applied. What is

causing the 2'ond peak ? Then determine which peak is the one to examine.

 

 

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