Blink runs on teensy 3.2, USB powered but will not always start when using battery

jrdarrah

Well-known member
I've been having this problem on a sketch I'm working on but to remove all extraneous information I can recreate the problem with blink.

Code:
/*-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
 */

// Pin 13 has an LED connected on most Arduino boards.
// Pin 11 has the LED on Teensy 2.0
// Pin 6  has the LED on Teensy++ 2.0
// Pin 13 has the LED on Teensy 3.0
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

Today I did some testing where I compiled using different options using Arduino 1.8.19 and Teensy 1.56. The hardware has the trace cut between VUSB and VIN. I feed power to each via a diode.
mcfPkgwAAACgAQkzAAAA0ICEGQAAAGhAwgwAAAA0IGEGAAAAGpAwAwAAAA1ImAEAAIAGJMwAAABAAxJmAAAAoAEJMwAAANCAhBkAAABoQMIMAAAANCBhBgAAABr8HwEnLf4gj1pdAAAAAElFTkSuQmCC

mcfPkgwAAACgAQkzAAAA0ICEGQAAAGhAwgwAAAA0IGEGAAAAGpAwAwAAAA1ImAEAAIAGJMwAAABAAxJmAAAAoAEJMwAAANCAhBkAAABoQMIMAAAANCBhBgAAABr8HwEnLf4gj1pdAAAAAElFTkSuQmCC




It failed unless I dropped the clock speed down to 48 MHz and then only when compiled with Faster or Fastest option. Fast worked but only when I had Serial+MIDI but not when No USB was selected. How can I diagnose why this Fails (or Works)? I don't like leaving this process to chance depending on clock speed, code length or how it was linked together. I need the teensy to work reliably on both battery (with step up regulator) or USB.
 

Attachments

  • blink startup problem.jpg
    blink startup problem.jpg
    237.3 KB · Views: 33
Hopefully someone who is less electrically challenged than me, will be able to give a more definitive answer.

Note: when I first read the message, it was not clear to me, what battery...

But looking at the attached thumbnail, you are using 2 AA batteries connected to a Pololu 5v step up regulator.
I believe this one(https://www.pololu.com/product/2564)

Might help to know/see how the batteries are connected and the like, For example some holder have really bad connections and very small wires.

What type of AA battery? alkaline? Or rechargeable...

Again wondering if issue with enough current? Or how the voltage ramps up?

Again hope someone else can give you some better hints.

Kurt
 
battery power connection

Reply to Kurt:

Hopefully someone who is less electrically challenged than me, will be able to give a more definitive answer.

Note: when I first read the message, it was not clear to me, what battery...

But looking at the attached thumbnail, you are using 2 AA batteries connected to a Pololu 5v step up regulator.
I believe this one(https://www.pololu.com/product/2564) Yes that is the one I'm using

Might help to know/see how the batteries are connected and the like, For example some holder have really bad connections and very small wires. The teensy is on a carrier board that provides connections to the battery holder. #24 gauge wire if I remember correctly.

Here is how the power is connected. A little confusing since I feed the battery and vin voltages to a resistor divider to keep the voltage for the analog input below 3.3V. Ultimately I determined to only measure the battery voltage to trigger an alarm when it gets low. I've tried deleting the resistors and it still fails to start with just the battery. Since I need them to detect voltage, I put them back

teensy 3.2 power.jpg

What type of AA battery? alkaline? Or rechargeable... I have tried Everyready Ultimate Lithium which by far last the longest and Alkaline. Rechargeable batteries just got here and are on my to do list

Again wondering if issue with enough current? Or how the voltage ramps up? It isn't a matter of enough current. I can have the USB connected and the battery connected, remove the USB cable and everything continues to work on just the battery. It fails when powered off then on by just the battery circuit. I don't know how the voltage ramps. Since every new project requires at least one new tool I ordered a small digital oscilloscope which should be here this week. I plan on using it to determine how both the 5V & 3.3V ramp up.

Again hope someone else can give you some better hints. Thanks for the input
 
confirmation of slow power up

I finally got my cheap digital oscilloscope and did confirm that I have a slow power up. Attached is a picture showing the startup delay caused by the TPS6120 used in the Pololu 5V boost regulator. The graph voltage is off by .24V due to a DC offset induced by the scope.. The red line shows the 3.3V pin on the teensy 3.2 board. I measured the voltage with my meter and it comes in at 3.3V and not the 3.54V as shown in the lower graph. The upper graph shows that the regulator starts quickly, but only outputs about 1.58V when corrected for the scope induced DC offset. It remains about that level for 21.4ms then ramps up to the full 3.3V about 34ms from power on.

Right now I'm stuck using the Pololu 2564 5V step up regulator due to size limitations. Given that, how can I add a delay in the teensy startup code to wait for at least 34ms to allow the power to stabilize?

I do know that the battery fed circuit works. If I start the teensy using USB and also feed via battery it starts properly and continues to run when the USB is unplugged.

teensy power  up delay.jpg
 
You probably need a switch circuit after the voltage regulator and before the Teensy that only switches on when voltage has reached 3V.
If that was not clear the switched voltage will supply the Teensy when up to at least 3V.
 
what modules are executed before entering setup

I want to do some low tech debugging (blink LEDs) to see how far teensy gets with my slow start power supply. Before I begin I need to know what modules are executed, and in what order, before setup is called. That way I'll know which ones might be involved in the hang due to the power. I'm hoping I can come up with a software solution to slow down boot code for about 50ms in order for the power supply to come up enough to allow the teensy 3.2 board to generate the 3.3V power feed. Any help along these lines will be greatly appreciated.
 
To close this topic out. I did some more testing using spare teensy 3.2s and regulators. They all worked fine for power up via battery. That lead me back to the regulator soldered in my circuit board. I replaced it and now it starts almost instantaneously. The old regulator worked but it took 40-50ms to get to full voltage which was why I could power up via USB then run on battery after I unplugged the USB cable.
 
Back
Top