ADCTouch and analogRead() interfering?

I am using a Nano.
I am using 5 analog inputs to read voltage values from a power supply.
I am using the remaining 3 analog inputs with the ADCTouch library so I have capacitive sensing buttons.

If I use either of these functions without the other they each work well.
If I try to analogRead() from any adc input, it reads about 2.5 volts.

This sounds like its giving me the average of a charging cap, which is how the adc touch library works.

Does anyone know if the ADCTouch library takes over all adc pins? Is touch library telling the whole adc on the chip to go into that tri state mode mentioned in the library?

Adc touch Sourse Code:

  ADCTouch.cpp - Library for Capacittive touch sensors using only one ADC PIN
  Created by martin2250, April 23, 2014.
  Released into the public domain.
#include "Arduino.h"
#include "ADCTouch.h"

int ADCTouchClass::read(byte ADCChannel, int samples)
 long _value = 0;
 for(int _counter = 0; _counter < samples; _counter ++)
 pinMode(ADCChannel, INPUT_PULLUP);
 ADMUX |=   0b11111;
 ADCSRA |= (1<<ADSC); //start conversion
 while(!(ADCSRA & (1<<ADIF))); //wait for conversion to finish
 ADCSRA |= (1<<ADIF); //reset the flag
 pinMode(ADCChannel, INPUT);
 _value += analogRead(ADCChannel);
 return _value / samples;

ADCTouchClass ADCTouch;

My Code, I dont know what may be relevant to this problem(maybe its just timings or something) so here it all is:

oh… i can only type out 9000 bytes… sooo ill attach it…

VoltmeterWSerialTouchSensorTimings.ino (11.3 KB)

The ADCTouch library plays with the internals of the ADC, I suspect you should call analogRead() twice
after using it to clear the ADC state, just like you should do after reset.

Perhaps try an extra

  analogRead (VoltageSupply1Input);

after the calls to the ADCTouch functions?

BTW I'd change this:

  voltCalcSupplyA = analogRead(VoltageSupply1Input)/1023.0*VoltPrescalerSupply1*(VoltScalerSupply1/VoltPrescalerSupply1);

to the simpler, more accurate

  voltCalcSupplyA = (analogRead (VoltageSupply1Input) +0.5) / 1024 * VoltScalerSupply1;

You were both multiplying and dividing by VoltPrescalerSupply1, and don't know the correct ADC interpolation formula (thats the DAC interpolation formula!)

Thank you much for your response MarkT!

That did seem to help a very small amount but no matter how i approach it there is too much crosstalk, or it takes too long for my loop: i think i will have to go to tactile buttons for this one.

so.. if I have this right, then the 8 channel adc on the 328p is just an 8 channel multiplexer hooked up to one physical comparator? that would be wonderful to have know before now but i am an edge case...

yea that voltCalc is convoluted xD
Eventually i will be reading up to 22 volts or something like that, through a voltage divider.
That was my unnecessarily long calc to map 1023 divisions of 5 volts to a number i dont know yet, but for right now i am using 5 volts, so i multiplied and divided by 5 xD who needs clock cycles anyways right lol

oh a few questions about that interpolation thingy:
what does the +.5 do?
why is it 1024 instead of 1023? (i had originally thought it should be 1024, but in testng if i used 1024 then i couldnt get 0.000 to 5.000 volts)

Thanks again for your post