4 Replies Latest reply on Feb 14, 2013 3:15 PM by user_14586677

    ADC Peak Value

    rajendra.prasad

      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

        • 1. Re: ADC Peak Value
          user_1377889

          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

          • 2. Re: ADC Peak Value
            user_14586677

            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.

            1 of 1 people found this helpful
            • 3. Re: ADC Peak Value
              user_1377889

              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

              1 of 1 people found this helpful
              • 4. Re: ADC Peak Value
                user_14586677

                Looks like I missed the attachment.

                   

                 

                   

                Regards, Dana.

                1 of 1 people found this helpful