Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Noise on Supply Voltage and Signal when using Internal ADC

  1. #1
    Junior Member
    Join Date
    Jun 2019
    Posts
    3

    Noise on Supply Voltage and Signal when using Internal ADC

    Hello,
    I'm fairly new to teensy and tried to make a FFT on the Teensy 3.2 on a audio signal sampled by the internal ADC. However i see extreme noise on the Power supply Voltage and therefore on the Signal about 86 times per second, which is how often the fft1024 is available.
    I'm not sure if this noise is generated by Sampling or by the calculations made by the FFT.

    Click image for larger version. 

Name:	20190612_182933-03-3000x2250.jpg 
Views:	10 
Size:	122.9 KB 
ID:	16779

    On the Picture Blue is thre Signal on the ADC wich is connected with the circuit on the "Audio system Design Tool"
    Yellow is the Supplyvoltage of 5V at the Vin pin AC-Coupled... Noise is really high on both. I tried adding capacitors for smoothing out, supplied it with a linear regulator but nothing helped to remove the noise.
    So I don't know if this havy noise is normal when doing ADC Sampling or Computational intensive things like FFT? Do you have an idea?


    Also there was a lot more noise when I used the RMS function also.
    Click image for larger version. 

Name:	20190612_183151-2016x1564.jpg 
Views:	8 
Size:	134.4 KB 
ID:	16780
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	20190612_182933-02.jpg 
Views:	8 
Size:	120.1 KB 
ID:	16777  

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,303
    Quote Originally Posted by KidCe View Post
    So I don't know if this havy noise is normal when doing ADC Sampling or Computational intensive things like FFT? Do you have an idea?
    Unless you're doing something very special to put the processor into a low power mode, it's very unlikely to be power consumption from the CPU. The FFT code doesn't consume substantially more power than the code running "idle" waiting for more data to analyze.

    However, I/O like transmitting over USB or driving LEDs does draw more power. We can't see your code, so I can only speculate (as you've done) about what might be drawing extra power or causing noise. But I can as a general suggestion point you to look for I/O stuff you're doing just after the FFT. Or you might try using digitalWriteFast() in various places to see if various code is running just before, during, or just after the disturbance. Or you could try showing us more info about what you're really doing, like the actual code or info about any other hardware you're using.

  3. #3
    Junior Member
    Join Date
    Jun 2019
    Posts
    3
    I currently don't have access to the code because I'm not at home. But I can tell you that there is not much going on of driving I/Os. It's only some data for APA102/SK9822 LEDs sent out by the FastLED library. So I only use FastLED.show() and some calculations for light intensity.
    I also tried disconnecting the 5V power of the LEDs to see if comes from digital noise generated by the LEDs... But that didn't change anything :/
    Do you think it's possible that this noise can be caused by a damaged teensy chip? I'm not the first one using it and not sure if the one before me maybe damaged it.
    Also one mistake i did ... Using 3.3V pk-pk signal on one Analog Pin while in the Audio design tool it said the range is 1.2V. So this uses internal 1.2v reference to make it possible to read line level signals directly?

  4. #4
    Junior Member
    Join Date
    Jun 2019
    Posts
    3
    Now i have access to the Code Again:

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    #include <FastLED.h>
    
    #define LED_TYPE SK9822
    #define COLOR_ORDER BGR
    #define NUM_LEDS 144
    #define DATA_PIN 11
    #define CLK_PIN 13
    CRGB leds[NUM_LEDS];
    
    
    #define BRIGHTNESS 255
    #define FRAMES_PER_SECOND 120
    
    
    uint8_t hue = 15;
    
    //uint8_t level[144];
    uint8_t oldLevel[144];
    uint8_t value[144];
    float rawValue[144];
    
    
    float scale  = 500.0;
    float level[16];
    int shown[16];
    
    // GUItool: begin automatically generated code
    AudioInputAnalog         adc1(A3);           //xy=179,182
    AudioAnalyzeFFT1024      fft1024_1;      //xy=401,185
    AudioAnalyzeRMS          rms1;
    AudioConnection         patchCord1(adc1, fft1024_1);
    AudioConnection         patchCord2(adc1, rms1);
    // GUItool: end automatically generated code
    
    void setup() {
      AudioMemory(12);
      fft1024_1.windowFunction(AudioWindowHanning1024);
      delay(100);
      FastLED.addLeds<LED_TYPE, COLOR_ORDER>(leds,NUM_LEDS).setCorrection(TypicalLEDStrip);
      FastLED.setBrightness(BRIGHTNESS);
      pinMode(2, OUTPUT);
    
    }
    
    
    void loop() {
    
      if(fft1024_1.available()){
        
        level[0] =  fft1024_1.read(0);
        level[1] =  fft1024_1.read(1);
        level[2] =  fft1024_1.read(2, 3);
        level[3] =  fft1024_1.read(4, 6);
        level[4] =  fft1024_1.read(7, 10);
        level[5] =  fft1024_1.read(11, 15);
        level[6] =  fft1024_1.read(16, 22);
        level[7] =  fft1024_1.read(23, 32);
        level[8] =  fft1024_1.read(33, 46);
        level[9] =  fft1024_1.read(47, 66);
        level[10] = fft1024_1.read(67, 93);
        level[11] = fft1024_1.read(94, 131);
        level[12] = fft1024_1.read(132, 184);
        level[13] = fft1024_1.read(185, 257);
        level[14] = fft1024_1.read(258, 359);
        level[15] = fft1024_1.read(360, 511);
    
        hue = 20;
        for(int i=0; i<16; i++){
    
          int val = level[i] * scale;
    
          if(val > 255) val = 255;
          if(val >= shown[i]) {
            shown[i] = val;
          } else {
            if (shown[i] >  6) shown[i] = shown[i] -7;
            val = shown[i];
          }
          if(shown[i] == 0) {
            leds[i] = CRGB::Black;
          } else {
            
            leds[i*3] = CHSV(hue, 255, shown[i]-1);
            leds[(i*3)-1] = CHSV(hue, 255, shown[i]-1);
            leds[(i*3)+1] = CHSV(hue, 255, shown[i]-1);
            hue = hue + 15;
          }
        }
        FastLED.show();
        }     //end FFT-available
        
        if(rms1.available()){
          float rmsval = rms1.read();
          int rmsscaled = rmsval*scale;
          if(rmsscaled > 255) rmsscaled = 255;
          leds[50] = CHSV(150, 255, rmsscaled);
        }
        FastLED.show();
    }
    Hardware is the Teensy3.2 on a Breadboard with the Components from the Audio System Design Tool connected to ADC A3.

  5. #5
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,077
    FWIW, i ran your sketch adding a sine-wave on the T3.2 DAC (A14) as my 1khz input jumpered to A3 and hooked to scope. I didn't have any FastLEDs connected. sine wave on scope had no noise. (maybe you can try DAC as an input), here's what I added (in RED)
    Code:
    ...
    // GUItool: end automatically generated code
    AudioSynthWaveformSine   sine1;          //xy=180,469
    AudioOutputAnalog        dac1;           //xy=380,468
    AudioConnection          patchCord3(sine1, dac1);
    
    void setup() {
      AudioMemory(12);
      sine1.amplitude(1.0);
      sine1.frequency(1000);
      fft1024_1.windowFunction(AudioWindowHanning1024);
      delay(100);
      FastLED.addLeds<LED_TYPE, COLOR_ORDER>(leds,NUM_LEDS).setCorrection(TypicalLEDStrip);
      FastLED.setBrightness(BRIGHTNESS);
      pinMode(2, OUTPUT);
    
    }
    ...
    Edit: toggling pin 2 when FFT is available, scope shows pin 2 square wave with 23.2 ms period, roughly 86 FFTs/second as you noted.
    digitalWrite(2,!digitalRead(2));

    What is providing your input to A3? maybe attach a photo of your setup. Are the T3.2 header pins soldered? Separate power supplies for T3.2 and LEDs (with common ground) ?

    with my sine wave input, calculate_unscaled_power_mW(leds,144) suggests LEDs consuming 1000 mW (200 ma). With AudioSynthNoiseWhite reports 2472 mW

    I'd also remove the "extra" FastLED.show(); at the end of loop()
    Last edited by manitou; 06-25-2019 at 05:11 PM.

  6. #6
    Member
    Join Date
    Nov 2015
    Location
    Norway
    Posts
    70
    I know you wrote that you disconnected the supply to the leds. Are you sure? I had a lot of nasty noise from those LEDS influencing other signals nearby. Ended up with a 2200uF cap on the 5V supply to the leds. That killed the noise.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •