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

Thread: Power and Noise Questions

  1. #1
    Junior Member
    Join Date
    Oct 2021
    Posts
    14

    Power and Noise Questions

    Hi, I'm nearing completion of building a foot pedal sample player and MIDI controller. It all functions when connected to my laptop by USB, albeit with some noise when playing samples, but when I try to connect it to other USB power, it doesn't function. It does part of the start up, but seems to get stuck before it gets to the point where it can play samples or send MIDI or respond in any way.

    So, my questions are:

    1) Is the noise an issue with USB power? Maybe a ground loop kind of thing?

    2) Is there a way to run it off a USB power brick? Or should I build in a different power option? I was considering setting it up to run on a 9V pedal power supply (stepped down to 5V) so it can integrate with my other guitar pedals.

    Here's the internals, and a clip of the noise issues.

    Click image for larger version. 

Name:	2022-03-15 13.13.37.jpg 
Views:	5 
Size:	156.6 KB 
ID:	28675

    https://www.youtube.com/watch?v=FkKzRurRfzo

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    4,188

    Cool

    Quote Originally Posted by AaronVAudio View Post
    Hi, I'm nearing completion of building a foot pedal sample player and MIDI controller. It all functions when connected to my laptop by USB, albeit with some noise when playing samples, but when I try to connect it to other USB power, it doesn't function. It does part of the start up, but seems to get stuck before it gets to the point where it can play samples or send MIDI or respond in any way.

    So, my questions are:

    1) Is the noise an issue with USB power? Maybe a ground loop kind of thing?
    Others can give you more detailed information about this.

    Quote Originally Posted by AaronVAudio View Post
    2) Is there a way to run it off a USB power brick? Or should I build in a different power option? I was considering setting it up to run on a 9V pedal power supply (stepped down to 5V) so it can integrate with my other guitar pedals.
    In almost all of the time, this is caused by code that waits for the Serial USB line to be initialized. Given you are being run off of battery, it never will be initialized. Usually the code looks something like:

    Code:
        while (!Serial)
            ;
    Instead, you should put a timeout in the loop, such as:

    Code:
        // Wait for up to 3 seconds for the USB serial output to finish initializing
        while (!Serial && micros () <= 3000UL)
            ;

  3. #3
    Junior Member
    Join Date
    Oct 2021
    Posts
    14
    That's incredibly helpful. Thank you! I'll give that a shot and look into it some more. If nothing else, if I can get it running off other USB power it'll let me troubleshoot the noise more effectively.

    Edit: I checked my code and I don't have anything like that, but it does give me a direction to research in. Would something to do with the Audio Shield or SD Card functions be causing it to wait in a similar way?

  4. #4
    Junior Member
    Join Date
    Oct 2021
    Posts
    14
    Ok, after some debugging, it seems to hang at the if (!(SD.begin())) step when not connected to my laptop.

    Code:
      if (!(SD.begin(SDCARD_CS_PIN))) {
        while (1) {
    //      Serial.println("Unable to access the SD card");
          displayE();
          delay(500);
        }
      }
    It reaches this point and just sticks on displaying "E" on my 7-segment. If it's connected to my laptop, it gets past this point no problem and everything works. (SDCARD_CS_PIN is set to 10)

    Is there any reason SD.begin() would fail when not connected to a PC but work fine when connected to a PC?
    Last edited by AaronVAudio; 06-19-2022 at 07:18 PM.

  5. #5
    Senior Member
    Join Date
    Aug 2018
    Location
    Brisbane, Australia
    Posts
    117
    Quote Originally Posted by AaronVAudio View Post
    Is there any reason SD.begin() would fail when not connected to a PC but work fine when connected to a PC?
    Is there enough power being fed to the teensy when standalone?

  6. #6
    Junior Member
    Join Date
    Oct 2021
    Posts
    14
    Quote Originally Posted by thebigg View Post
    Is there enough power being fed to the teensy when standalone?
    That's my current (no pun intended) theory, as I just had the same problem when I was powering it from my laptop with my laptop running off the battery. It seems like it shouldn't be an issue with the power supply, though, since I specifically bought this power supply, which is what I've been trying to use and should provide more than enough power safely.

Posting Permissions

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