9 Replies Latest reply on Nov 10, 2014 10:34 AM by AlVa_264671

    ADC_ DSM


      Hi  there!


      May be someone can help me with some silly thing.


      I've attached a file with a simple project that consist in the reading of an array of 4x4 FSR.


      The project started to operate ok, BUT AFTER DOING SOME CHANGE  that I cannot remeber,  the system make correct reading of each  FSR,  but  those FSR which are not  pressed give me a redout  which are oscillating betwen 0x00 and 0xFF.


      I have tried  to connect ADC input to Vdda  and Vssa and either situation do not stop that ocillating values.


      Really I Would neeed  some help.


      Thank you very much in advance.

        • 1. Re: ADC_ DSM

          You sue a polled approach on multi sample mode, either change to


          continuous mode or observe these two cautions for multi sample mode -




          Multi-sample mode captures single samples back to back, resetting itself and the modulator
          between each sample automatically.


          This mode is useful when the input is switched between multiple signals. The filters are
          flushed between each sample so previous samples do not affect the current conversion.


          Note Take care when switching signals between ADC conversions. Either switch the input
          quickly between conversions with hardware control or stop the ADC conversion
          (ADC_StopConvert()) while switching the input. Then restart the ADC conversion
          (ADC_StartConvert()) after the new signal has been connected to the ADC. Failure to do this
          may result in contamination between signals in the ADC results




          AND -




          Note When operating in either the Multi-Sample, Continuous, or Multi-Sample (Turbo) modes, exercise caution to read the last ADC reading prior to the next ADC result completion. If reading the last result at the exact same time as the next result is complete, an incoherent reading may occur. When using DMA triggered by EOC or code in the ADC's ISR, this issue is easily avoided. Since you have a complete conversion time to read the last result, this should not be a problem in most designs. If the firmware cannot keep up with the ADC's conversion rate, the rate should be reduced to a manageable speed. This condition only occurs in the PSoC 3 family of products.




          If you use an ISR in multi sample make sure all variables used in ISR are declared volatile.


          Regards, Dana.

          • 2. Re: ADC_ DSM

            Visually I cannot see any errors you made. You fulfill the requirements Dana told from the datasheets.


            Only thing to change I would suggest is the way of getting an 8-bit value from the 16-bit result.


            GetResult() delivers an int16, so do not store it into an uint16. Followed by two ifs you can write


            if(Value <0) Value = 0;


            if (Value > 255) Value = 255;




            An additional hint: You may compute the value of A for the control-register as


            A = 0x01 << j;     // No "if" needed





            • 3. Re: ADC_ DSM

              Thank you Dana  an thank you Bob


              Bob I will try your valuable sughgestions.


              The weitd tthing is that the projext was operatinh vry well , with no issues like  originate this post.


              I was following the recomendation of Dana before this post and trying to improve some  project behavior suddenly with some change I cannot  remeber the issue was started.


              Bob, I wil try that you suggest  and thank you very much  your guys for help me.

              • 4. Re: ADC_ DSM

                    Hello again you guys!!




                Below is the code change  that Bob suggest me:






                         Mux_Control_Write(i) ;
                        ADC_DelSig_1_StartConvert() ;  
                        while (((0x00==  (Return_ADC= ADC_DelSig_1_IsEndConversion( ADC_DelSig_1_RETURN_STATUS  )  ) )));  
                        Value[i][j]=ADC_DelSig_1_GetResult16() ;


                          Arr[i][j]= Value[i][j] & 0x00FF;


                          if (Value[i][j]<0) Value[i][j]=0x00;


                         if (Value[i][j]>0)  Value[i] [j]=0xff;


                "Thje issue remain."


                But there are a weird situation with the ADC: If I put the four analog inpunt to vssa( no connection to the ), the display shows that the adc continuos displaying oscillating values betwen 00 or FF.


                The same happens if the connection of analogs input are to vdda.


                I been doing project like this, trying diferent type of array and it never happened.


                Thank you for your time.

                • 5. Re: ADC_ DSM

                  Since after the two "if"s your value is between 0 and 255 you should assign it then to your Arr[][]. And leave out the "&"





                  • 6. Re: ADC_ DSM

                    Bob !!!! It seems to be that your proposed modification in the code is working ok, my friend !!!!


                    Before I just follow the recomendation of spec which has been working at that mom,ent.


                    Your approach is working good in this case.


                    So thank you so much !


                    Have a wonderfull day.



                    • 7. Re: ADC_ DSM

                      Alex, you are always welcome!





                      • 8. Re: ADC_ DSM

                        Bob !!! Thank you again.


                        I woul like to known what you know.


                        Best regards

                        • 9. Re: ADC_ DSM

                          "... das einzig was ich weiß ist, dass wir nichts wissen können.


                          Das will mir schier das Herz verbrennen!" (Goethe, Faust I)