7 Replies Latest reply on Aug 3, 2017 8:53 PM by user_51122829

    Need help on AN66444

    user_51122829

      I am trying to implement application note AN66444 in my project that require an accurate voltmeter.

         

      Following is the code segment from main.c downloaded with AN66444:-

         

           { ...................

         

          /*perform CDS*/
              iVcds = iVout1 - iVout2;
              
              /* IIR Filter*/
              iVcds_curr = iVcds;
              iVcds_acc += (iVcds_curr - iVcds_acc) >> 4;
              }
          
          /*Display output in desired format on UART*/
          fVcds = ADC_DelSig_1_CountsTo_Volts(iVout1);
          UART_1_PutChar('\r');
          UART_1_PutChar('\n');
          sprintf(caVcds_decimal_str,"%f",(float)fVcds);
          UART_1_PutString((uint8*)caVcds_decimal_str);

         

      The display routine is displaying "iVout1".

         

      I could not find any link between the "IIR routine" and the "display routine".

         

      Would greatly appreciate if someone can help me on how the IIR Filter is being used here ?

        • 1. Re: Need help on AN66444
          user_1377889

          Welcome in the forum!

             

          Change some settings:

             

          In system view set the heap size to 0x0200

             

          in Project->Build settings->Arm GCC...->Linker set both "Use newlib nano" and "Use newlib nano float formatting" to true.

             

           

             

          Bob

          • 2. Re: Need help on AN66444
            user_51122829

            Hi, thank you thequick reply.

               

            Sorry, i did not make my problem clear.

               

            The IIR Filter code are not being utilized. I would like help on how to make use of the IIR Filter code to perform the low pass filter.

               

            The "iVcds_acc" value does not correspond to the actual input value. I think additional code are needed to implement the filter.

               

            I can understand the correlated double sampling (CDS) but am at a total lost on the IIR Filter portion.

               

            Jim

            • 3. Re: Need help on AN66444
              user_1377889

              Can you please post your complete project or a shortened version that shows the error so that we all can have a look at all of your settings. To do so, use
              Creator->File->Create Workspace Bundle (minimal)
              and attach the resulting file.

                 

               

                 

              Bob

              • 4. Re: Need help on AN66444
                user_342122993
                        jimbies, Look on this output conversion code (counts to volt): fVcds = ADC_DelSig_1_CountsTo_Volts(iVout1); If you replace "iVout1" with "iVcds_acc", the output to terminal will show averaged value. (well, it is my guess without seeing all code)   
                • 5. Re: Need help on AN66444
                  user_51122829

                  Thank you all for the reply.

                     

                  I did replace "iVout1" with "iVcds_acc" but the value is much lower that my actual input. It looks like something is missing in the "/* IIR Filter*/" code segment.

                     

                  I have attached the project file, which is actually the example file from AN66444, The only change that I have made is the output code - from UART to LCD Display.

                  • 6. Re: Need help on AN66444
                    user_342122993
                            jimbies, I am not at computer right now. My guess is that you not need correlated data sampling (CDS), so following code modification should work: { ......... /* IIR Filter*/ iVcds_curr = iVout1; iVcds_acc += (iVcds_curr - iVcds_acc) >> 4; } /*Display output in desired format on UART*/ fVcds = ADC_DelSig_1_CountsTo_Volts(iVcds_acc);   
                    • 7. Re: Need help on AN66444
                      user_51122829

                      iVcds_acc += (iVcds_curr - iVcds_acc) >> 4; is giving an output = 7.573.

                         

                      iVcds gives an output = 4.622 which I have verified with a multimeter to be correct.

                         

                      Being bad at filter equations, I am not able to figure out what is wrong. Any tips would be most helpful.