ADC multiple channel "overhearing" on M8

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have yet another ADC issue. I read two pins PC0, PC1 alternating for single reads.

 

The value read on one channel is influence by reading on the other, but not the other way round.

The two values I read;

- one for reading light intensity using a photoresistor, the other

- a NTC thermo sensor which is intended to measure temperature for a temperature correction

 

now the light intensity gives a co-variation in the NTC reading, though the temperature is definitely constant

 

       5V VCC
        !
       ! !
       ! !
       ! !   NTC  around 10k  (room temp 22C)
       ! !
       ! !
        !
        +---------- signal  >  ADC PC1  (value c)
        !
       ! !
       ! !
       ! !  3,7k
       ! !
       ! !
        !
       GND

 

        5V VCC
        !
       ! !
       ! !
       ! !   256
       ! !
       ! !
        !
        +---------- signal  >  ADC PC0  (value L)
        !
       ! !
       ! !
       ! !  photoResistor approx 1k  (at 60W incandensant, 2,6k shaded, 4k dark)
       ! !
       ! !
        !
       GND

 

The NTC reading is clearly affected in co-variation mode by the photo read value !
A lower photo value, induces a lower NTC ADC reading, while the temperature is keep constant.

The effect is more pronounced at lower temperatures (higher NTC resistance).
while the photo value is what can be seen fully independent on the NTC reading value.

 

The NTC is read before the photo, in a 20s loop, so after photo-read there is a 20s delay.

I now switch the MUX to NTC reading, directly after photoread.
I do a dummy read wait 25ms then issue the to use NTC read (introducing a first read made things better, but
going over 10ms in delay make no difference what can be noticed, while going to 10ms did, when then getting effect I did not change the MUX to NTC directly after photo either)

 

I have added a cap 100nF parallell signal-gnd for the NTC, might have done some lille effect....
not much more with a .22uF tantalum

The selected refence is VCC, and ADREF has a cap 100nF to earth. (but no cap /coil on ADVCC)

 

#define F_CPU 8000000UL
#include <avr/io.h>
#include <avr/delay.h>

void initADC() {
//****************************************************************************
// set up of ADC for oneshot read/AD on PC0-PC5, not using initerrupt
// pin to be selected at read
//****************************************************************************
//  ENABLE:   in ADCSRA     : bit ADEN -- enable, bit ADSR -- single run
//     MUX:   in ADMUX (reg); the MUX(0-2); bits default (=0), sets input to ADC0
//                                                             and n=number is direct indication of ADCn
// REFvolt:  in ADMUX (reg); the REFS(1-2) bit; refs1=0,refs0=1 for VCC with cap on ADref

    ADCSRA = ( 1 << ADEN );   // only enable, not the interrupt enable (ADIE)
    ADMUX  = ( 1 << REFS0 ); 

}

uint16_t readADC(uint8_t PINNE) {
//*********************************************************************
// fairly generic routine to make a one-shot read from an ADC pin (PC0 -- PC5)
// initiation routine should be called first
//*********************************************************************
     uint8_t d;

     // set the PIN to read; via MUX0

     d = 0b11110000;                // delete; att nollställa 4 bittar, behålla de övriga
     ADMUX &=  d<<MUX0;             // gör delete; OBS funkar inte om inte MUX0 = 0  !!!!! optimist
     ADMUX |=  (PINNE << MUX0) ;    // stoppa in den pinne vi ska läsa (kolla om fördröjning behövs, tror det

     ADCSRA |= (1 << ADSC);         // start AD conversion

     while (ADCSRA & (1 << ADSC)) ;  // liveloop; wait for finish
     return ADCW;                    // pick up result

}

snippet from main loop

       corrTempVal = readADC(CORR_TEMP_READ_PIN);
       _delay_ms(25);
       corrTempVal = readADC(CORR_TEMP_READ_PIN);

       // gör temp (& fuktinghetsmätning), två 16bits integer (signed)

       ret16 = DHT( &out_humid, &out_temp);
       if (ret16 != 0 ) {
           USART_Trsm_string("** DHT_readFail:");
           itoa( ret16, outstring, 10);  USART_Trsm_string(outstring);
           USART_Transmit(CR); USART_Transmit(LF);
       } 

       // gör ljusmåtning, kasta & gör om eftersom kanal bytt ....

       light = readADC(LIGHT_READ_PIN);    // pinne PC0 för ljusmätningen
       _delay_ms(25);
       light = readADC(LIGHT_READ_PIN);

       garbage = readADC(CORR_TEMP_READ_PIN);  // just return channel to corr reading

 

some sequencies of the measurement output C is temp correction value reads, L is light value read  :

 

------ single reads (no discards) direct read c first then L some inst. later

00:27w4294883408T209H322L79c255
00:27w4294883408T209H322L88c255
00:27w4294883409T209H322L79c255
00:28w4294883408T209H322L88c255
00:28w4294883408T209H321L88c255
00:29w4294883408T209H323L79c255
00:29w4294883408T210H323L83c255
00:29w4294883408T209H323L79c255
00:30w4294883409T210H326L88c255
00:30w4294883409T210H324L79c255
00:30w4294883408T210H323L79c255
00:31w4294883408T210H322L79c255
00:31w4294883408T209H322L199c287       <<<<<<<<  +120 -> +32
00:31w4294883408T210H322L199c284
00:32w4294883409T209H321L192c284
00:32w4294883409T209H321L199c284
00:32w4294883409T209H322L192c284
00:33w4294883409T210H323L199c287
00:33w4294883408T210H323L206c287
00:33w4294883408T210H322L192c284
00:34w4294883409T210H322L193c287
00:34w4294883408T210H322L192c284
00:34w4294883408T210H322L199c284
00:35w4294883408T210H321L192c287
00:35w4294883409T210H321L192c284
00:35w4294883409T210H321L195c284
00:36w4294883408T210H322L192c287
00:36w4294883409T210H322L195c284
00:36w4294883409T209H322L192c284
00:37w4294883408T209H322L199c284
00:37w4294883408T209H321L199c284
00:38w4294883409T209H321L195c284
00:39w4294883409T211H322L199c287
00:39w4294883409T211H322L199c287

------------------------------------- 1 pre-read, discarded, wait 3ms

03:42w4294883461T213H325L192c316
03:43w4294883408T239H305L206c316
03:43w4294883408T239H305L206c312
03:43w4294883409T239H305L206c316
03:44w4294883408T239H305L192c316
03:44w4294883408T239H304L207c312
03:44w4294883409T240H304L195c316
03:45w4294883408T240H303L207c316
03:45w4294883408T240H303L199c316
03:45w4294883408T240H302L206c316
03:46w4294883408T241H302L195c316
03:46w4294883408T241H302L48c304        <<<< -147  -> - 12
03:46w4294883408T241H306L46c304
03:47w4294883408T242H303L48c304
03:47w4294883408T242H302L39c304
03:47w4294883408T242H302L46c305
03:48w4294883408T243H301L46c305
03:48w4294883408T243H300L46c305
03:48w4294883408T243H300L46c305
03:49w4294883408T243H300L48c305
03:49w4294883408T244H300L46c305
03:50w4294883408T244H300L48c305
03:50w4294883408T244H300L39c305         <<<< + 185 -> +13
03:50w4294883408T244H300L224c318
03:50w4294883408T245H301L224c318
03:51w4294883408T245H303L216c318
03:51w4294883409T245H300L216c318
03:51w4294883408T245H302L224c318
03:52w4294883408T245H302L216c318

-----------------------------------  1 pre-rad, discarded, wait 10ms

03:52w4294883408T246H300L207c319
03:52w4294883408T246H299L216c319
03:53w4294883408T246H299L224c318

04:00w4294883408T247H300L224c319
04:00w4294883408T247H301L224c319
04:01w4294883466T246H302L224c319
04:01w4294883409T246H301L224c319
04:02w4294883408T245H300L216c319
04:02w4294883409T245H300L216c319
04:03w4294883408T245H301L224c319
04:03w4294883408T244H302L216c319
04:03w4294883408T244H302L216c319
04:04w4294883408T244H302L216c319
04:04w4294883408T244H305L216c319
04:04w4294883408T244H305L207c319
04:05w4294883408T243H303L216c319
04:05w4294883408T243H302L207c319
04:05w4294883408T243H303L224c318
04:06w4294883408T243H302L207c319
04:06w4294883408T243H302L224c319
04:06w4294883408T243H302L224c319
04:07w4294883408T242H302L224c318
04:07w4294883409T243H303L207c319
04:07w4294883408T243H303L46c312      <<<<<  - 152 -> -7
04:08w4294883408T243H304L46c312
04:08w4294883408T243H303L39c312
04:08w4294883409T243H303L39c312
04:09w4294883408T243H303L39c312
04:09w4294883408T243H311L39c312      <<<<<  + 168 -> +6
04:09w4294883408T243H313L207c318
04:10w4294883409T243H312L207c319
04:10w4294883409T243H307L207c319
04:10w4294883408T243H304L216c318
04:11w4294883408T243H302L199c318
04:11w4294883408T242H301L216c318

------------------------------------------ 2 pre-read, discarded, wait 10ms

04:26w4294883408T240H300L216c318
04:26w4294883409T240H300L216c318
04:27w4294883408T240H300L207c318
04:27w4294883408T240H301L220c318
04:27w4294883408T240H300L216c318
04:28w4294883408T240H300L206c318
04:28w4294883408T240H300L224c318
04:28w4294883408T240H300L216c318
04:29w4294883409T240H301L207c318
04:29w4294883408T240H300L216c318
04:29w4294883408T240H301L216c318
04:30w4294883408T240H300L224c318
04:30w4294883408T239H300L224c318
04:30w4294883409T239H300L216c318
04:31w4294883408T239H300L216c318
04:31w4294883408T239H300L216c318
04:31w4294883408T239H300L216c318
04:32w4294883408T239H300L216c318
04:32w4294883409T239H300L207c316
04:32w4294883408T239H300L224c318
04:33w4294883408T239H301L48c305    <<<< -176 -> -13
04:33w4294883409T238H300L56c305
04:33w4294883409T239H302L49c305
04:34w4294883408T239H300L48c305
04:34w4294883409T239H300L49c305
04:34w4294883408T239H300L49c305
04:35w4294883408T239H300L48c305
04:35w4294883409T238H300L56c305
04:35w4294883408T238H302L56c305
04:36w4294883408T237H301L49c305
04:36w4294883408T237H301L48c304
04:36w4294883408T236H300L49c304
04:37w4294883408T236H301L51c304
04:37w4294883408T236H302L39c305     <<<<< +181 -> +13
04:37w4294883409T235H301L220c318
04:38w4294883408T235H308L216c318
04:38w4294883409T235H306L224c316
04:38w4294883408T235H303L227c316
04:39w4294883408T235H303L224c318
04:39w4294883409T235H305L227c318
04:39w4294883409T234H305L224c316
04:40w4294883409T234H306L227c318
04:40w4294883408T234H306L224c318

------------------------------  2 pre-read, discarded, 20ms wait

04:47w4294883464T239H304L231c319
04:47w4294883408T242H300L231c319
04:47w4294883408T242H300L224c319
04:48w4294883408T242H300L224c319
04:48w4294883408T242H300L231c319
04:48w4294883408T242H300L224c319
04:49w4294883408T242H300L224c319
04:49w4294883408T242H303L224c319
04:49w4294883408T242H302L231c319
04:50w4294883408T242H300L224c319
04:50w4294883408T242H301L224c319
04:50w4294883409T242H302L236c319
04:51w4294883408T242H302L224c319
04:51w4294883408T242H302L224c319
04:51w4294883408T242H302L231c319
04:52w4294883408T242H301L224c319
04:52w4294883408T242H301L227c319
04:52w4294883408T242H301L224c319
04:53w4294883409T242H302L224c319
04:53w4294883408T242H301L240c319
04:54w4294883408T241H304L224c319
04:54w4294883408T241H306L56c312    <<<< - 168 -> -7
04:54w4294883409T241H309L56c312
04:54w4294883408T241H306L56c312
04:55w4294883408T242H304L56c312
04:55w4294883409T242H303L56c312
04:55w4294883408T241H303L60c312
04:56w4294883408T241H302L56c312
04:56w4294883408T240H301L60c312
04:56w4294883408T240H301L56c312    <<< + 136 -> +6
04:57w4294883408T240H303L192c318
04:57w4294883408T240H309L195c316
04:57w4294883408T240H309L206c316
04:58w4294883408T240H306L207c316
04:58w4294883408T239H305L193c316
04:59w4294883409T240H307L192c316
04:59w4294883408T240H304L199c316
04:59w4294883408T240H304L199c316
05:00w4294883409T240H304L193c316
05:00w4294883409T240H304L192c316

-------------------------------------- 1pre-read, 20ms wait
07:21w4294883429T243H340L195c318
07:21w4294883408T244H321L206c316
07:21w4294883409T244H311L199c316
07:22w4294883408T244H307L199c318
07:22w4294883409T244H305L207c318
07:22w4294883408T245H304L63c312     <<<<  -174 -> -6
07:23w4294883408T245H306L63c312
07:23w4294883408T245H303L67c312
07:23w4294883409T245H302L71c312
07:24w4294883408T245H302L63c312
07:24w4294883408T245H301L71c312
07:24w4294883409T245H301L240c319    <<<< +169 -> +7
07:25w4294883409T245H300L224c319
07:25w4294883408T245H301L227c319
07:25w4294883409T245H300L216c319
07:26w4294883409T246H300L216c319
07:26w4294883408T246H300L216c319
07:26w4294883408T246H300L224c319
07:27w4294883408T246H300L216c319
07:27w4294883409T246H300L224c319
07:27w4294883408T246H300L225c319
07:28w4294883409T246H300L224c319
07:28w4294883408T246H300L216c319
07:29w4294883466T246H300L224c319
07:29w4294883408T246H301L216c319

--------------------               1pre-read, 25ms wait, and channel back to corr after read (20s to next read)

07:29w4294883408T246H301L216c319
07:29w4294883408T246H300L224c319
07:30w4294883408T246H301L60c312
07:30w4294883408T246H302L56c312
07:30w4294883408T246H301L60c312
07:31w4294883408T245H301L60c312
07:31w4294883408T245H302L60c312
07:31w4294883408T245H302L60c312
07:32w4294883408T245H303L60c312
07:32w4294883408T244H303L56c312
07:32w4294883408T243H304L60c312
07:33w4294883408T243H304L231c319
07:33w4294883408T243H305L224c319
07:33w4294883408T243H306L240c319
07:34w4294883408T243H307L225c319
07:34w4294883408T242H306L56c312
07:35w4294883408T242H310L56c312
07:35w4294883408T242H310L56c312
07:36w4294883408T241H309L56c312

---------------------              below;  only corr, i.e. NTC temp changed (temperature); NO influence !!!??

07:42w4294883408T242H306L207c384
07:42w4294883408T242H306L199c287
07:42w4294883408T242H305L195c280
07:43w4294883409T242H305L207c280
07:43w4294883408T242H304L207c280
07:43w4294883409T242H304L199c280
07:44w4294883408T242H304L207c280
07:44w4294883409T243H304L216c316
07:44w4294883408T243H304L216c385
07:45w4294883408T243H303L207c391
07:45w4294883408T243H303L216c399
07:45w4294883408T243H303L199c399
07:46w4294883408T243H302L206c396
07:46w4294883409T243H302L216c384
07:46w4294883408T244H302L216c384
07:47w4294883408T244H302L206c368
07:47w4294883408T243H302L199c359
07:47w4294883408T243H302L206c352
07:48w4294883408T242H302L192c352
07:48w4294883408T242H304L199c344
07:48w4294883409T242H306L207c344
07:49w4294883408T241H307L216c704
07:49w4294883408T240H307L199c768
07:49w4294883408T240H308L199c743
07:50w4294883408T241H306L207c737

-----
cond 0,1uF gnd - signal tempcorr

81:01w4294738101T236H308L143c318
81:01w4294738101T236H307L195c319
81:01w4294738101T236H306L207c319
81:01w4294738101T237H304L207c319
81:01w4294738101T237H303L56c316    >>>>> less dependence -150 -> -3
81:01w4294738101T237H302L48c316
81:01w4294738101T237H303L56c318
81:01w4294738101T237H302L56c318
81:01w4294738101T237H302L56c318
81:01w4294738101T237H301L56c318
81:01w4294738101T237H301L176c319   >> +120 -> +1
81:01w4294738101T237H302L176c319
81:01w4294738101T237H301L176c319
81:01w4294738101T237H301L167c287  -- corr into colder water
81:01w4294738101T237H300L184c225
81:01w4294738101T236H300L184c224
81:01w4294738101T236H300L184c224
81:01w4294738101T235H299L176c224
81:01w4294738101T235H300L192c224  << cold water ; even bigger diff for light change
81:01w4294738101T235H300L56c207
81:01w4294738101T235H300L56c207
81:01w4294738101T234H300L49c207
81:01w4294738101T234H301L56c207
81:01w4294738101T234H302L49c207

81:01w4294738101T233H303L56c207
81:01w4294738101T233H305L49c207
81:01w4294738101T233H305L49c207
81:01w4294738101T232H305L49c207
81:01w4294738101T231H305L56c207    ----????
81:01w4294738101T231H307L56c216
81:01w4294738101T231H308L56c216
81:01w4294738101T231H308L48c216
81:01w4294738101T231H308L56c216
81:01w4294738101T231H308L56c216
81:01w4294738101T231H308L48c216
81:01w4294738101T231H308L48c216
81:01w4294738101T231H307L49c216
81:01w4294738101T231H307L56c216
81:01w4294738101T232H307L163c224
81:01w4294738101T232H307L176c224
81:01w4294738101T232H306L176c224
81:01w4294738101T232H306L167c224
81:01w4294738101T232H305L176c224
81:01w4294738101T232H305L167c224
81:01w4294738101T232H305L167c224
81:01w4294738101T232H305L167c224
81:01w4294738101T232H305L163c224
81:01w4294738101T232H305L159c224
81:01w4294738101T232H305L176c225
81:01w4294738101T232H305L167c225
81:01w4294738101T232H305L174c225
81:01w4294738101T232H305L176c225

This topic has a solution.

Last Edited: Sat. Jan 11, 2020 - 07:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Post a small complete program that demos the issue so others can help troubleshoot, please.

Often you will discover the problem yourself while doing the above....

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

Last Edited: Sat. Jan 11, 2020 - 03:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, right. Will take some time. Be back. /g

 

(but what could go wrong  :) , so you think there's a problem in the rest of the code, where no ADC influence is present..)

Last Edited: Sat. Jan 11, 2020 - 03:20 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

testcode as here; gives very much the same effect on measurements as given for the L and c columns of the above data

#define F_CPU 8000000

#include <stdint.h>
#include <stdlib.h>
#include <avr/io.h>
#include <util/delay.h>


#include "uart_main.h"

// light measurement via photoresistor probe

#define LIGHT_READ_PIN 0   // PC0 for ADC input for light

// temp measurement, via ADC, for weight correction

#define CORR_TEMP_READ_PIN 1       // PC1 for termocouple read  (a table also needed in EEPROM) 

// -- LIght measurement routines

void     initADC();
uint16_t readADC(uint8_t pinne);

int main() {

//---------USART--------
   char CR=13; char LF=10;
   uint16_t baud=103;      // 4800 vid 8Mhz clock
   uint8_t in_char;
//----light----
   uint16_t light;
   uint16_t corrTempVal;   //  weight corr temp measurement
   uint16_t garbage;
//-------------------------------------------------------------------
   char    outstring[40];     

   // initieringar

   USART_Init(baud);            /* Set up transmitt UART */
   USART_Init_rcv();            /* set up UART reception with interrupt */ 

   sei();

   initADC();   // this is non-interrupt ADC measurments

   //  --------

   USART_Trsm_string("***** hi *****");   
   USART_Transmit(CR); USART_Transmit(LF); 

   while (1) {

     PORTB &= ~( 1 << PB0);   
     _delay_ms (500);       
     PORTB |= ( 1 << PB0);  
     _delay_ms (500); 

       corrTempVal = readADC(CORR_TEMP_READ_PIN);
       _delay_ms(25);
       corrTempVal = readADC(CORR_TEMP_READ_PIN);

       light = readADC(LIGHT_READ_PIN);    // pinne PC0 för ljusmätningen
       _delay_ms(25);
       light = readADC(LIGHT_READ_PIN);

       garbage = readADC(CORR_TEMP_READ_PIN);  // just return channel to corr reading
       USART_Transmit('L');
       itoa ( light  , outstring, 10);
       USART_Trsm_string(outstring); 

       USART_Transmit('c');
       itoa ( corrTempVal , outstring, 10);
       USART_Trsm_string(outstring);

       USART_Transmit(CR); USART_Transmit(LF); 

  } 
} 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you even measured the voltage on the pins with a meter or to see what is going on?

 

If you are measuring light, why would you keep getting the same number anyhow?

 

What happens when you feed 2 pot voltages into the 2 pins...are your readings then stable & independent?    That will tell you a lot, if they are not (software issue).  If they are stable, then you have some sort of sensor variation effect (noie, time constant, meaurement variations, etc)

 

instead of some long list of gibberish...show only when you get WRONG adc readings, (say off more than +/-4 counts)

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. Jan 11, 2020 - 04:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

please, its not gibberish, you have the two rightmost columns where you see the steps in light, that immediately goes into the other channel, that with high certainty is stable temperature NTC value. Of cause I could go for pots, but I dont think the sensors could do much, pure resistive as they are. I have deliberatly included a "long listing" to show the stability of readings before and after the change in light intens.  The places you seek "that go wrong", are marked in the "long listing".

Measuring voltage directly doesnt show any fluctuations on the NTC sensor input, nor on the 5v feed to the sensor (both with respect to GND), when altering the light intensity (intput / reading on the other channel).

 

So I guess there is nothing obvious wrong, then possibly some pcb problem, like bad soldering... closer to the MCU than the sensors.

Last Edited: Sat. Jan 11, 2020 - 05:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Of cause I could go for pots

You should...it will take 10 minutes & will tell you a lot (sort of divide the issue in half).   Also, did you check your ADC voltages with a meter...Then you can say when the values are WRONG, which may help to track things down.

 

Try reporting only one channel....maybe somehow you are blending your numbers together (by that I mean you are measuring correctly, but not reporting correctly)...that can lead to a wild goose chase

 

Is the ADC hooked up properly (AVcc connected, Aref cap , to gnd)....note if you switch the reference type between channels, that is "not recommended"  (by me) as it adds extra complications for things to go wrong.  Try to do everything using only one reference setting, when possible.

 

You haven't said why you think the light value should be steady....what is the light?

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. Jan 11, 2020 - 05:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

10minutes if you have the pots in order, Im not sure that I have the ranges in order.... (well work for future good to have)

 

Yes (i thought I had written) the ADC is as per your question. And yes I use only the VCC as ref (should also be visible from supplied).

 

And I have reduced the "artifact" somewhat by the means mentioned (discard read, wait inbetwen reads), but not at all satisfying.

 

But given this I possibly should try measurements directly on MCU pins.... (its that darn clip I never bought for budget reasons ...)

 

Did I say the light/photorestor value steady, well that is the value I change, between a dark(shaded) and a lit (60w incand) L in the gibberish, which gives the variations in the NTC- which is very stable, when not touched or mixed with, in giving room temp.

 

While I also tested the NTC in cold water (giving a higher resistance value, also stable, as stable as the water, slowly rising...) and got even higher influence from the light variations. Also went for a LED irridiance into the light resistor, giving a much higher light reding (value L) which then had a big impact on the NTC-temp value reading.

Last Edited: Sat. Jan 11, 2020 - 06:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have now measured directly on PC1 as steady hand as posibly, and that voltage is not moving (well 1mV when 1,5V) as result

of the light change (alterd value on PC0 channel), what can be detected using AVO at least.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gechxx wrote:
please, its not gibberish,

You were asked for a complete program--the "skipped" routines may well be of great importance.

 

A quick check to go further:  Do a double-convert on each channel.  E.g. A A B B A A B B ...  How do the results compare then?

 

Put a small cap right next to the pin [to ground] for the ADC to sip from.  Do the results change?

 

The first thing we will look at when you post the whole program will be the ADC clock speed.  The second thing will be how you are testing for conversion-complete.

 

Let me see if I can find the thread "partial believer"...

https://www.avrfreaks.net/commen...

https://www.avrfreaks.net/commen...

theusch wrote:

Paulvdh wrote:
Throwing away a reading after each channel change is redicilous.

No, it is not ridiculous.  In many situations, double-convert gives better results than single-convert.

 

I'll see if I can dig out the "evidence", Your Honor...

 

I remember "partial believer", which led me to

https://www.avrfreaks.net/forum/s...

...where #5 leads me to a legacy link with the discussion...

http://legacy.avrfreaks.net/inde...

...which is the "do it badly" thread https://www.avrfreaks.net/forum/a...

 

There have been other similar discussions with test results, and not dealing with the BG channel.  Given the above, I lean toward double-convert when starting a new app, especially with e.g. thermistors that might not have a lot of oomph.  [Our board designer routinely added a series R to protect from the real-world signal, and a small C next to the AVR pin.  Thus, my reluctance to believe at first, as that setup (most ideally suited for slow-moving signals) gives the channel pretty good drive with the cap to sip from so in practice I didn't see as bad results as some others found when converting a "naked" signal.]

 

 

 

 

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

Last Edited: Sat. Jan 11, 2020 - 06:41 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I see the "missing" routines from the complete program in an earlier post.  Are those what you are using?

 

Your ADC clock rate is too fast.

 

I have a hard time understanding that read routine.  Just build ADMUX each time.

 

There are a number of references to Vcc throughout. But none to AVcc, except the questions you chose not to answer.

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

HI !

 

A quick check to go further:  Do a double-convert on each channel.  E.g. A A B B A A B B ...  How do the results compare then?

 

Right; I know that my text is not very readable; but yes, the read - discard, read again is included in the measurement series;

and yes It makes a small but noticable difference, but nowhere enough.

 

Put a small cap right next to the pin [to ground] for the ADC to sip from.  Do the results change?

Same as above (actually supposed to be in description): yes; i have included a cap for the thermo-"sensor" accross, signal - ground; again, small diff but no where signficant (less then the one above, while that one was still in place doing this here)

 

 

The first thing we will look at when you post the whole program will be the ADC clock speed.  The second thing will be how you are testing for conversion-complete.

Well I think I have done that; there is the ADC code in the first entry, then a bit down the test code, that still shows the problem.

 

 

Let me see if I can find the thread "partial believer"...

David Prentice; well I didnt find that one, ....., but I saw Davids text refering to it, there is where I got the idea for double reads....

 

/g

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok,sorry. AVCC has a cap of cerami 100nF, but no coil (inductance), directly connected to VCC.

 

Clock rate ? ok, here could b something I have not gotten..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Of cause.

 

I do confuse myself (and others). The 2 channel read was adopted from an earlier routine one channel read, where I did cater to the ADPS.

But in that use, I had concluded that the ADPS made no difference, and at some point I had falsely concluded that that was only for freerunning. Thus removed. Crap.

(btw I guess you didnt approve of my channel setting since the comments were in swedish :)  .. but it works actually (as long as the generality of MUX0 stays zero ) )

 

Thanks a lot.

 

/georg

Last Edited: Sat. Jan 11, 2020 - 08:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you 100% sure you are reading the correct ADC channel (and/or that your sensor is 100% hooked to the correct pin).

The reason I mention that is say you read chan 2, but leave the chan 2 pin floating and hook the signal to chan5 by mistake...you may get some strange results that look like the signal due to the floating pin & leakage paths.  I seem to remember seeing that on some AVRs that had 2 pins the were for ADC use only (adc6,adc7 not IO)...they were sensitive to ghost pickup from other pins (or perhaps it was just between 6 &7)  ...which can be misleading!   

 

This was 10 years ago, so it's foggy.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, thanks, and yes; it runs like clockwork now. It was the sampling time that I now have firmly established (...) that short sampling time, i.e. the default:when not setting ADPS0:2, makes overhearing between channels. Guess the short sampling time does not get time enough to suc away the old charges, for new ones. Much in line with the "David Prentice-i just might accept to make two reads".

Last Edited: Sat. Jan 11, 2020 - 08:39 PM