I found this odd behavior while trying to debug some code to detect a USB connection. I kept removing code and hardware to get to the root cause of the teensy 3.2 not running the sketch if powered by a 5V source and not the USB. I did cut the trace and have diodes to protect each power source. I've attached the schematic. The battery power circuitry consists of 2 AA batteries feeding a Pololu 5V step up regulator #2564. it is JP5 in the schematic
https://www.pololu.com/product/2564
The battery + is routed to an isolated switch built into the headphone jack SJ-435107RS. When the connection is made the battery voltage goes to the input pin of the step up regulator. That output feeds a diode D1 tied to VIN.
To eliminate the USB itself as the problem I compiled this sketch with no USB selected in the IDE.
What happens makes no sense to me.
If I connect the USB connector the sketch runs fine including the delay before the red LED comes on.
With the USB cable in place, if I plug in the headphone jack to enable battery power and unplug the USB connector it continues to run. That tells me that the battery power circuit is working properly.
From a powered off state, if I only plug in the headphone jack to run solely off battery power I get either no red LED, an immediate red LED (no delay), or for no apparent reason an immediate blue LED.
I rigged a test harness to allow me to scope and measure the voltage of VIN and VUSB. VUSB comes in at 5V and VIN about 4.67V which allows for the BAT54C Schottky Diodes voltage drop. When I look at the VIN as powered from the battery circuit I see no noise, just a clean signal at the correct voltage.
I'm out of ideas except maybe the startup of VIN from the battery only is too slow or glitchy since it depends on the switch built into the headphone jack. I saw nothing obvious noticed in the scope. Any suggestions on what to try would be greatly appreciated.
https://www.pololu.com/product/2564
The battery + is routed to an isolated switch built into the headphone jack SJ-435107RS. When the connection is made the battery voltage goes to the input pin of the step up regulator. That output feeds a diode D1 tied to VIN.
To eliminate the USB itself as the problem I compiled this sketch with no USB selected in the IDE.
Code:
// battery power problem
// 4/13/22 Jim Darrah
#define BlueLED 16
#define RedLED 17
void setup() {
//To save power set all 34 Teensy 3.2 IO pins to output
for (int i=0; i<34; i++) {
pinMode(i, OUTPUT);
}
delay(1000);
digitalWrite(RedLED, HIGH); // LED off to start
}
void loop()
{
}
What happens makes no sense to me.
If I connect the USB connector the sketch runs fine including the delay before the red LED comes on.
With the USB cable in place, if I plug in the headphone jack to enable battery power and unplug the USB connector it continues to run. That tells me that the battery power circuit is working properly.
From a powered off state, if I only plug in the headphone jack to run solely off battery power I get either no red LED, an immediate red LED (no delay), or for no apparent reason an immediate blue LED.
I rigged a test harness to allow me to scope and measure the voltage of VIN and VUSB. VUSB comes in at 5V and VIN about 4.67V which allows for the BAT54C Schottky Diodes voltage drop. When I look at the VIN as powered from the battery circuit I see no noise, just a clean signal at the correct voltage.
I'm out of ideas except maybe the startup of VIN from the battery only is too slow or glitchy since it depends on the switch built into the headphone jack. I saw nothing obvious noticed in the scope. Any suggestions on what to try would be greatly appreciated.