ADC_ DSM

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

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.

0 Likes
9 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

   

 

   

Bob

0 Likes
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

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.

0 Likes
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

    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=ADC_DelSig_1_GetResult16() ;
       

   

          Arr= Value & 0x00FF;

   


          if (Value<0) Value=0x00;

   


         if (Value>0)  Value =0xff;
          
        ADC_DelSig_1_StopConvert();

   

"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.

0 Likes
lock attach
Attachments are accessible only for community members.
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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 "&"

   

 

   

Bob

0 Likes
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

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.

   

Alex101

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Alex, you are always welcome!

   

 

   

Bob

0 Likes
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

Bob !!! Thank you again.

   

I woul like to known what you know.

   

Best regards

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

   

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

   

 

   

Bob

0 Likes