Trying to run Teensy 4.1, using 5v power from my midi keyboard PCB

Tim N.

Member
Hi everyone;
I know this issue has been discussed in a number of posts here in the past, but I still can't get my Teensy 4.1 to work with 5v external power. I've cut the trace on the back of the Teensy, which separates the USB power from the Vin pin. Although I could have alternately cut the USB red (5v) wire. My test meter shows no connection between the 2 pads or any accidental short to the usb ground shield.

A little background...
I'm programming the Teensy to provide the functionality required for my revamped MIDI keyboard. I've had the whole setup working nicely on my breadboard for some time. The MIDI keys are multiplexed using a pair of SN74HC4851D IC's. All the keys, plus the pitchbend and mod wheel controls do exactly what they are supposed to. Also, MIDI-Ox recognizes my MIDI keyboard by name, and the keys and controls register the correct MIDI messages, just as advertised. So I'm certain that the code is working properly when powered via the USB. The Teensy is set as MIDI, in the Arduino IDE.

By the way, for the breadboard setup, I have a short USB cable (25cm), connecting the Teensy micro B to a small sub-board. The open leads of the cable are wired to this sub-board, which uses a USB-B connector. The connection to the computer uses a good quality USB-B to USB-A cable. This works fine.

Now that it works, I've created a single PC board to plug in the midi keys ribbon cables, the pitchbend, modwheel, sustain pedal and volume pedal, and of course the Teensy 4.1 (plugs into a couple of 24-pin headers). I checked and re-checked the circuit layout many times, before I had the PCB fabricated for me.

I've wired up the power supply section of my PCboard (without the Teensy or any other connections, other than the hard-wired multiplexers). I'm using a 12vdc/500ma wall wart supply. This goes through the power switch, then to a standard 7805 regulator, with a 220uf/25v electro cap at the 7805 input and a similar 220uf/10v at the output. When powered up, I'm getting 4.97v from the regulator output. So far, so good.

When I plugged the Teensy into its socket (yes..oriented correctly), along with all the keyboard connections, and powered it up, the Vin pin measures the same (4.97v). Anyway, I hooked up the Teensy USB to the computer and opened up my Arduino sketch (unchanged from before). It said the Teensy was not connected. I pressed the button on the Teensy, but the Arduino IDE still failed to recognize it (though the red led near the USB remained on). Also, MIDI-Ox no longer sees the MIDI device either. The breadboard version worked fine, though I never powered the Teensy from my breadboard supply.

I'm not using the serial port in the code, at the current time. The code has this line, at the end of the main loop: while (usbMIDI.read()) {}. It makes no difference whether I comment this out, or just leave it. The keyboard is never receiving messages..only sending.

Anyway, I set the Teensy back to normal, by soldering a short jumper wire across the two pads, plugged it back into my PCB, disconnected my PCB's power, hooked up the USB to the computer, and ran the Arduino sketch again. It works perfectly well this way.

Once I'm finished tweaking the code, the Teensy should not need to be re-programmed, but is easily accessible if I open up the keyboard. However, the keyboard needs to be seen as a stand-alone MIDI device, when powered up, and connected to my DAW.

I can't figure out what's missing. Is there a power-up timing issue here? Or something to do with the USB protocol? Are those 2 pads on the Teensy connected to anything else other than the USB 5v and the Vin pin? I'm stumped.

Thanks in advance.
 
Do you have something like while(!Serial); in your setup? If so change it to while (!Serial && (millis() < 3000));
 
Thanks for carefully describing the exact issue. Everything seems to be correct (and I note that Arduino serial monitor is not being used, so that is not the issue).

Given that the LEDs are lighting up it seems 3V3 is being generated from the 5V supply but perhaps you could check the voltage on the 3V3 pin?

For your external supply, you have the regulator output going to the Vin and also the regulator ground going to the GND pin, right?
 
Thanks for carefully describing the exact issue. Everything seems to be correct (and I note that Arduino serial monitor is not being used, so that is not the issue).

Given that the LEDs are lighting up it seems 3V3 is being generated from the 5V supply but perhaps you could check the voltage on the 3V3 pin?

For your external supply, you have the regulator output going to the Vin and also the regulator ground going to the GND pin, right?
Yes, the regulator 5v out feeds the Vin pin, as well as the 2 multiplexers. The regulator GND and the Teensy GND are common. Both 3v3 pins show 3.29v. Everything works now, thanks to BriComp's suggestion.
 
Do you have something like while(!Serial); in your setup? If so change it to while (!Serial && (millis() < 3000));
Thanks for the suggestion, this did the trick. Even though none of the sketch code contains any Serial references, I included your while (!Serial && (millis() < 3000)); snippet at the end of the main loop. This solved the USB issue. I only had to tweak a couple of lines of code, due to a change of routing from the breadboard config., plus a couple of minor PCB tweaks.
 
Adding that line by itself should not solve any problem, it's only meant to replace an existing "while (!Serial);" statement causing the program to pause forever.
If your design is actually working consistently now, and you never had a "while (!Serial);" to begin with, then the problem was elsewhere.
 
Back
Top