Hesitation in executing sketch code on Teensy 3.6

Status
Not open for further replies.

rbrewer

New member
I am building a neopixel display using a Teensy 3.6 coupled to a SN74AHCT125 to boost the data voltage to 5v. I am using bare sk6812 neopixels which have to be soldered. Before I install the soldered neopixels, I use the following sketch to test each one. This sketch does not run the neopixels smoothly. Instead there seems to be random hesitations of varying length of up to a second or two. I ran the sketch on a Uno. There were no hesitations. The voltage booster has 4 channels. It doesn't make a difference if I change channels. It doesn't make any difference if I exclude the use of the voltage booster altogether.

Here's the sketch:


// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
// the first NeoPixel is 0, second is 1
#include <Adafruit_NeoPixel.h>
#define PIN 6
#define NUMPIXELS 1
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int x; // utility variable
int r; int g; int b;// red,blue,green
int p; // pixel number

int n=NUMPIXELS;

void setup() {
Serial.begin(9600);
pixels.begin(); // This initializes the NeoPixel library.
}

void loop() {
x=0;
while(x<n){
on(x,50,0,0);
delay(500);
off(x);
on(x,0,50,0);
delay(500);
off(x);
on(x,0,0,50);
delay(500);
off(x);
x++;
}
}

void on(int p, int r, int g, int b){
pixels.setPixelColor(p, pixels.Color(r,g,b));
pixels.show();
}
void off (int p){
pixels.setPixelColor(p, pixels.Color(0,0,0));
pixels.show();
}

void alloff(){
x=0;
while(x<100){ off(x);x++;}

}

Any suggestions?

Richard Brewer
r2pbrewer@yahoo.com
 
We're seeing a similar issue with the latest libraries on Teensy 3.2. It appears to be related to the call to "Serial.begin"
 
We're seeing a similar issue with the latest libraries on Teensy 3.2. It appears to be related to the call to "Serial.begin"

A version or two back in TeensyDuino "Serial.begin()" was changed to NOT RETURN for some time ( ~1.5 seconds ) unless Serial connection was established sooner.

Simply remove the call to "Serial.begin()" and that 'wait' will be removed - but the odds are Serial will not be online for some time after power on. The built in delay is 400 ms from power on until setup() is entered - even with a ready PC it can be up to 700 ms or beyond before Serial is online. If the user has to tell the PC to connect this "Serial.begin()" wait allows for that to happen before continuing into setup() where prints will not show up.

The alternative is a variation of " while ( !Serial ) ; " which will NEVER leave until Serial is online. Or " while ( !Serial && millis() < 4000 ) ; " which would only wait for 4 seconds.
 
Maybe the new 1.5 second wait is too long?

I ran a test just now with the program from msg #1 on both Teensy 3.6 and Arduino Uno.

file.png

The red trace is 5V power for both boards. The yellow trace is Uno's output on pin 6. The blue trace is Teensy's output. Uno is starting about 1.3 seconds earlier, because Teensy is doing the extra wait.

After they're both running, they stay in sync.
 
Status
Not open for further replies.
Back
Top