Teensy 3.1 runs for a few minutes, then constantly resets

Status
Not open for further replies.

garlinto

Member
After years of arduino experimentation, I have decided to upgrade to the teensy. Great product! Even though I am having some technical issues, I am looking forward to moving forward with a number of projects centered around the teensy 3.1 specifically.

I am running a version of the Cylon example from the FastLED 3.03 lib that I have modified to use with my 12 LED neopixel ring and 60 LED neopixel ring. I am coding in the arduino v1.6.0 IDE with your latest teensyduino beta (1.21.x). Code posted below. I am using this level shifter. I am powering the teensy from USB and the neopixels are powered from a 5V, 3A power supply. I noticed over the weekend that the power supply was actually providing about 5.2V to the level shifter/neopixels. So I put together a voltage divider to bring the voltage down to 4.8V. I didn't have any 1F caps to solder across the neopixel supply pads, so I used the largest I had, which was 220 uF, 16V. There is a 470 ohm resister on the input signal from the teensy to each ring as well. As per the neopixel docs, I have made efforts to keep the data lines from the teensy to the rings as short at possible.

After upload, the teensy will run the program as expected for a few minutes, then will start to reset randomly, until it quits resetting and just hangs and freezes. Is there an overrun or memory leak somewhere in the code that I'm not catching? I first started coding for my clock project using teensy's built-in RTC (I added the crystal), and after 15 minutes or so the clock with hang and demonstrate the same random resets. That code is much more lengthy, but since it happens with this example too, I thought I'd start here.

Code:
#include "FastLED.h"

// How many leds in your strip?
#define RING_A_LEDS 60
#define RING_B_LEDS 12

#define RING_A_PIN 5
#define RING_B_PIN 7

CRGB ringA[RING_A_LEDS];
CRGB ringB[RING_B_LEDS];

void setup() {
  FastLED.addLeds<NEOPIXEL, RING_A_PIN>(ringA, RING_A_LEDS);
  FastLED.addLeds<NEOPIXEL, RING_B_PIN>(ringB, RING_B_LEDS);
}

// loop code modified to use pixels 15-45 on big ring and 3-9 on smaller inner ring
void loop() {
  // First slide the led in one direction
  int j = 0;
  int l = 3;
  for (int i = 15; i < RING_A_LEDS - 15; i++) {
    
    // Set the i'th led to red
    ringA[i] = CRGB::Red;
    ringB[l] = CRGB::Red;
    
    
    // Show the leds
    FastLED.show();
    // now that we've shown the leds, reset the i'th led to black
    ringA[i] = CRGB::Black;
    
    j++;
    
    if (5 == j) {
      ringB[l] = CRGB::Black;
      l++;
      j = 0;
    }

    // Wait a little bit before we loop around and do it again
    delay(30);
  }
  
  j = 0;
  l = 9;
  // Now go in the other direction.
  for (int i = RING_A_LEDS - 15; i >= 15; i--) {
    // Set the i'th led to red
    ringA[i] = CRGB::Red;
    ringB[l] = CRGB::Red;
    // Show the leds
    FastLED.show();
    
    // now that we've shown the leds, reset the i'th led to black
    ringA[i] = CRGB::Black;
    
    j++;
    
    if (5 == j) {
      ringB[l] = CRGB::Black;
      l--;
      j = 0;
    }
    
    // Wait a little bit before we loop around and do it again
    delay(30);
  }
}

I should mention that these results are the same whether I code using linux or windows software. I have a dual-boot laptop so using either environment is easy. Any help would be greatly appreciated! I have a great project in mind for my two rings but I want my setup to be stable first.
 
I figured it out. Was fairly obvious once I started printing out variables, especially in loops. I had some serious buffer overruns, some of which began to overflow just seconds after powerup. Poor debugging on my part.
 
Status
Not open for further replies.
Back
Top