1 2 Previous Next 15 Replies Latest reply on Jan 17, 2013 6:49 AM by user_14586677

    To find a Peak value of ADC

    rajendra.prasad

       hi to all,

         

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

         

      Regards

         

      PRP

        • 2. Re: To find a Peak value of ADC
          user_14586677

          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.

             

           

             

           

             

           

             

          Regards, Dana.

          • 3. Re: To find a Peak value of ADC
            user_14586677

            Picture did not post, here it is -

               

             

               

               

             

               

            Regards, Dana.

            1 of 1 people found this helpful
            • 4. Re: To find a Peak value of ADC
              user_14586677

              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.

              1 of 1 people found this helpful
              • 5. Re: To find a Peak value of ADC
                rajendra.prasad

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

                • 6. Re: To find a Peak value of ADC
                  rajendra.prasad

                  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];

                     

                                                }

                     

                                                                     }

                     

                                                 }

                     

                     }                    

                     

                  }

                     

                   

                     
                          
                  • 7. Re: To find a Peak value of ADC
                    user_1377889

                    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

                    1 of 1 people found this helpful
                    • 8. Re: To find a Peak value of ADC
                      rajendra.prasad

                      Hi Bob,

                         

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

                      • 9. Re: To find a Peak value of ADC
                        user_14586677

                        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.

                        1 of 1 people found this helpful
                        • 10. Re: To find a Peak value of ADC
                          rajendra.prasad

                          hi Dana,

                             

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

                          • 11. Re: To find a Peak value of ADC
                            user_14586677

                            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.

                            1 of 1 people found this helpful
                            • 12. Re: To find a Peak value of ADC
                              rajendra.prasad

                              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.

                              • 13. Re: To find a Peak value of ADC
                                user_1377889

                                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

                                1 of 1 people found this helpful
                                • 14. Re: To find a Peak value of ADC
                                  rajendra.prasad

                                  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

                                  1 2 Previous Next