How to perform a simultaneous reading of A2 (for FFT) and A14 (for a NTC sensor)?

TFTLCDCyg

Well-known member
I want to use a teensy 4.1 to be able to monitor the audio signal from the PC obtaining it's approximate FFT.

Since I recently installed liquid cooling for the processor and video card of the PC, I would also like to monitor the temperature of the coolant and some extra components that normally don't have a sensor. I built four temperature sensors with film NTC probes, to get the temperature with the help of the teensy, I connected each sensor as a resistive voltage divider.

I monitor the readings of each signal through an analog pin of the teensy; for this I want to use pins A14, A15, A16 and A17.

This is the routine that generates the FFT using pin A2 as the audio signal input.

Code:
#include <Audio.h>
AudioInputAnalog         adc1;   
AudioAnalyzeFFT1024      fft1024_2;
AudioOutputI2S           i2s1;  
AudioConnection          patchCord3(adc1, fft1024_2);

#define NUM_BINS         380        // 380-16000 Hz (1 BIN = 42.18 Hz)
double  Datos[NUM_BINS];
int     Bin_inicial =      3;    // 6
double  FRuido=            0;
double  escalaFFT =       10;
double  MultiFFT =      1000;

const int Sensor_3 = A14;
double LecturaS_3=0;

void setup() {
  AudioMemory(30);
  fft1024_2.windowFunction(AudioWindowTukey1024);

  Serial.begin(115200);
}

void loop() {
  //LecturaS_3=analogRead(Sensor_3);
  if (fft1024_2.available()) 
  {
    for (int i=Bin_inicial; i < NUM_BINS; i=i+1) 
    {  
      Datos[i] = (fft1024_2.read(i)*MultiFFT*escalaFFT)-FRuido*escalaFFT;
      if(Datos[i]<=0){Datos[i]=1;}
      
      Serial.println(Datos[i]);
      //LecturaS_3=analogRead(Sensor_3);
    }
    //LecturaS_3=analogRead(Sensor_3);
  }
  //LecturaS_3=analogRead(Sensor_3);
}

Without reading the analog pin the FFT is generated without problems

Sin A14a.jpg

No matter where I place the reading of pin A14, within the routine, the audio signal is interrupted and the FFT is not produced.

Con A14.jpg

NTC
T41_NTC.jpg

FFT
T41_FFT.jpg

Separately the routines work very well, however when joining them in the main program, the reading of the NTC probes prevails and that of pin A2 for FFT is interrupted.

Is it possible to get any analog pin read without affecting the process of obtaining the FFT on the A2 pin?
 
Last edited:
Back
Top