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

Thread: noise on A0 when using audio shield

  1. #1
    Senior Member
    Join Date
    Dec 2018
    Posts
    130

    noise on A0 when using audio shield

    Hello,

    I notice a strange problem.
    I have attached a pot to A0. When reading my pot output value, I have noticed there is a lot of noise (+/- 10). When my pot is connected on other analog inputs, I have no noise (I mean no more than +/-1). This happens only when audio shield is active. When it is disable, the is no noise.
    Emmanuel

    noise on A0 :
    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    //// GUItool: begin automatically generated code
    AudioSynthWaveform       waveform1;      //xy=434,340
    AudioOutputI2S           i2s1;           //xy=699.1111450195312,337.888916015625
    AudioConnection          patchCord1(waveform1, 0, i2s1, 0);
    AudioControlSGTL5000     sgtl5000_1;     //xy=159.04762649536133,90.31746006011963
    //// GUItool: end automatically generated code
    
    
    void setup() {
      sgtl5000_1.enable(); 
      sgtl5000_1.volume(0.2);  
      AudioMemory(8);          
    }
    
    
    void loop() {
      int pot0 = analogRead(A0);
      Serial.println(pot0);
      delay(5);
    }
    no noise on A0
    Code:
    //#include <Audio.h>
    //#include <Wire.h>
    //#include <SPI.h>
    //#include <SD.h>
    //#include <SerialFlash.h>
    //
    ////// GUItool: begin automatically generated code
    //AudioSynthWaveform       waveform1;      //xy=434,340
    //AudioOutputI2S           i2s1;           //xy=699.1111450195312,337.888916015625
    //AudioConnection          patchCord1(waveform1, 0, i2s1, 0);
    //AudioControlSGTL5000     sgtl5000_1;     //xy=159.04762649536133,90.31746006011963
    ////// GUItool: end automatically generated code
    
    
    void setup() {
    //  sgtl5000_1.enable(); 
    //  sgtl5000_1.volume(0.2);  
    //  AudioMemory(8);          
    }
    
    
    void loop() {
      int pot0 = analogRead(A0);
      Serial.println(pot0);
      delay(5);
    }

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,280
    Hello Emmanuel,
    on which Teensy Model does this happen? Teensy 4?
    And which Teensyduino version are you using?
    Last edited by Frank B; 01-04-2021 at 11:24 AM.

  3. #3
    Senior Member
    Join Date
    Dec 2018
    Posts
    130
    Hello,

    Sorry I omitted these informations.
    I did this test on Teensy 3.5. I use teensyduino 1.54 beta 5.

    I noticed that in general that enabling the audio shield tends to add some noise on the power supply. The 0V and 3.3V flickers when audio shield is enable. Same remark for the analog inputs : enabling the audio shield adds some noise when reading analog values. I have the same issue when powering teensy from batteries. It is not very bad though...

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,280
    I tried this on a T3.5, but without the audio shield connected.
    The noise is subjectively the same in this case. So it might actually be the hardware - and not a software bug in a lib, as I first thought (but I do not definitively rule it out yet).


    You can try adding a 100nF capacitor and / or a lower resistance potentiometer.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,076
    The Rev C audio shield transmits I2S data on pin 13, which is right next to pin A0/14. Maybe the digital rising/falling edges are coupling? Using a lower resistance pot and capacitor should help. If you're not going to use the audio shield for an input signal, you might also try cutting off pin 13.

  6. #6
    Senior Member
    Join Date
    Dec 2018
    Posts
    130
    Thank you for you suggestions.

    Yes I think pin 13 and A0 /14 are coupling.
    I am going to cut pin 13 and see.

  7. #7
    Senior Member
    Join Date
    Dec 2018
    Posts
    130
    Cutting pin 13 makes no difference.
    Adding a cap smooth the reading, but still some noise.

  8. #8
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    854
    For less noise, you should be doing a differential read on two analog inputs.

  9. #9
    Junior Member
    Join Date
    Jul 2017
    Posts
    18
    What i usually do for clean pot readings is:
    1. Proper supply decoupling. All pots and AVREF are decoupled with an LC filter 10uH + 1u.
    2. 100n filter caps placed close to the analog inputs for each pot wiper.
    3. Increase AnalogAveraging param, but at the cost of response time.
    4. Use extra software filtering, simple lowpass filter or a dedicated library as the https://github.com/dxinteractive/ResponsiveAnalogRead.

  10. #10
    Senior Member
    Join Date
    Dec 2018
    Posts
    130
    Hello,

    I have done more testing about analog inputs noise issue.
    First of all, filtering with caps + code solve the problem. But still, I would really like to know what's going wrong when audio shield is hooked.

    To summarize :
    - no noise on analog inputs when audio shield is either physically disconnected or disable in Setup.
    - noise on some analog inputs (not all) when audio shield is hooked and enable in Setup. A0 and A10 especially get very noisy when doing simple pot readings.

    I could repeat this behaviour on the 3 T3.6 I have. I try different power source (including batteries) with no success.

    Emmanuel

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,076
    Impedance matters. The lower the resistor value, the less susceptible to interference. A capacitor gives low impedance, but only at high frequencies. Just looked over this thread again and still didn't see what value pot was actually used. Was that ever mentioned?

  12. #12
    Senior Member
    Join Date
    Dec 2018
    Posts
    130
    Hi Paul,

    I use 10k pots.
    I am still making some tests to see where the problem is.
    Emmanuel

Posting Permissions

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