CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

ADC channels unwanted crosstalk (solved)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
krasi



Joined: 17 Jun 2009
Posts: 9
Location: Bulgaria

View user's profile Send private message

ADC channels unwanted crosstalk (solved)
PostPosted: Sat Mar 19, 2011 3:36 am     Reply with quote

Hi,

I am reading several different voltages with the ADC channels on a 18F25k20. And it seems that there is crosstalk between channels which I don't want. My compiler version is 4.093.
I tried all possibilities that I have on mind but no effect. So, what I've tried so far is:
- increasing the time after setting the MUX, from 20us to 100us;
- changing the acquisition time;
- adding same voltage to all inputs;
- disabling the reading;

My hardware is simple: at each analog channel I have a resistor divider like 1.2kOms in serial of the input and 10kOms in parallel of it. So my input impedance is below max allowed specified in the datasheet.
I post the simple test program that I used and still have the crosstalk.
Code:

#include <18F25k20.h>
#device ADC=10

#FUSES HS,NOWDT,NOPROTECT,NOLVP   
#use delay(clock=16M, oscillator=4M)   // 4Mhz Crystal is Used with enabled PLL (x4)

void main(void)
{
  int16 value;
 
   // ADC SETUP
   setup_adc_ports(sAN0|sAN1|sAN2|sAN3);
   setup_adc(ADC_CLOCK_DIV_16|VSS_VDD);   // 1us Tad
   //setup_adc(ADC_CLOCK_DIV_32|VSS_VDD);   // 2us Tad
   
  while( TRUE )
   {
      set_adc_channel(0);
      delay_us(100);         
      value=read_adc();      // take a read from ADC
      delay_ms(2000);
   
      set_adc_channel(1);
      delay_us(100);         
      value=read_adc();      // take a read from ADC
      delay_ms(2000);
   
      set_adc_channel(2);
      delay_us(100);         
      value=read_adc();      // take a read from ADC
      delay_ms(2000);
   
      set_adc_channel(3);
      delay_us(100);         
      value=read_adc();      // take a read from ADC
      delay_ms(2000);
  }
}


Disabling lines with read_adc(), also have no effect, so I think the problem is somewhere in the MUX settings, but I can't figure it out.

I tried the same program with PIC18F2580 and it works perfect.
I'm stuck in this, so any ideas are welcome.

Thanks in advance.

Krasi


Last edited by krasi on Sat Mar 19, 2011 8:49 am; edited 1 time in total
temtronic



Joined: 01 Jul 2010
Posts: 9169
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Mar 19, 2011 5:33 am     Reply with quote

Ok, I'm not using those PICs but

These lines...

setup_adc_ports(sAN0|sAN1|sAN2|sAN3);
setup_adc(ADC_CLOCK_DIV_16|VSS_VDD);

can be combined into one

setup_adc_ports(sAN0|sAN1|sAN2|sAN3|setup_adc(ADC_CLOCK_DIV_16|VSS_VDD);


Maybe the compiler is using the last setup_adc(..); and resetting sANn selection. You'ld have to check the listing to see if the correct bits are set/reset.
I've always combined all options into one directive and never had a problem.
krasi



Joined: 17 Jun 2009
Posts: 9
Location: Bulgaria

View user's profile Send private message

PostPosted: Sat Mar 19, 2011 7:35 am     Reply with quote

Ok, I've checked the option with combined lines, but an error appears - "A numeric expression must appear here".
I checked the listing file as you mentioned, but everything seems to be normal.
So, I'm keep searching for a decision.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Mar 19, 2011 7:59 am     Reply with quote

Quote:
it seems that there is crosstalk between channels which I don't want.

I would prefer some more substantial information. How do you determine the crosstalk? What's the voltage at all involved ADC pins in this situation? Can you exclude interferring signals at other pins or an unstable supply/ADC-reference?
temtronic



Joined: 01 Jul 2010
Posts: 9169
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Mar 19, 2011 8:34 am     Reply with quote

oops
it should be..

setup_adc_ports(sAN0|sAN1|sAN2|sAN3|ADC_CLOCK_DIV_16|VSS_VDD);

for some reason it looked fine when I cut and pasted it,

hopefully it'll look right this time.
there should be a vertical bar(| ) between each option;
krasi



Joined: 17 Jun 2009
Posts: 9
Location: Bulgaria

View user's profile Send private message

Problem solved!
PostPosted: Sat Mar 19, 2011 9:03 am     Reply with quote

The problem is solved already.
Thanks to all of you for your ideas and especially to FvM. When he mentioned:
Quote:
Can you exclude interferring signals at other pins or an unstable supply/ADC-reference?
I start thinking and discover my problem.
Because I used an old PCB made for 5V PIC, most of my inputs were 5V tolerant. So, for 25k20 which is 3V PIC, I've changed all necessary pins to 3V, and forgot the others. So, there was 5V applied to few pins which acts like digital inputs. And in this case the internal protection diodes were triggered and the result was changed Vreff and so on, and so on.
That's why I measured different value every time, although I was applied same voltage to all analog pins.

Thanks again for your help.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group