Problem communicating with Teensy 3.2

Status
Not open for further replies.

BuffaloFan32

Well-known member
I have two Teensy 3.2's controlling an LED matrix. Right now, the two Teensy's are independent; one controls one part of the matrix, the other controls the rest. I have no trouble uploading sketches to either Teensy and, if the sketches are autonomous, they both run fine. My problem is when I try to use the serial communicator to tell the Teensy's what to do. I have a script where I can enter an integer and it will light up the corresponding LED in the matrix. Works fine on one Teensy but not the other. Same thing for the VideoDisplay script. Even when I totally disconnect the working Teensy, the problem persists. Any idea how to troubleshoot this?
 
Not seeing a clear picture of what the setup is? Are the Teensy's connected to each other by Serial#, do they have common GND to each other. Or just talking to both USB Serial? They both will have different COM# port ID's for USB Serial. How is the Serial USB connected with software? IDE Serial Monitor? That only connects to one Teensy at a Time - at least on Windows? What OS? Is TeensyLoader being used? Programming each with a button press? TyCommander can do multiple SerMon and program multiple units from GUI - there is a thread for that - last post I added had links to getting current version.
 
I am running it on a Windows machine. I am using the serial monitor on the Arduino ide to do the talking. It might be easier to forget about the working Teensy for a second. Even if I totally disconnect it, I can still use the teensy loader to upload a sketch to the remaining Teensy. It will work fine as long as it doesn’t depend on any input from the serial monitor. If I upload a sketch that requires any input from serial, it stops working.
 
What does the Tools Menu : Ports show when that Teensy is connected?

As asked - is the button used to program the problem Teensy?

Does this same sketch work differently on another Teensy or is it unique? Without the code being posted we can't see it.

If you could swap the working teensy for the problem teensy would the behavior follow? That is : is it possible the connections to this device are the problem?
 
@defragster I swapped the Teensy's and the problem persisted. I don't usually need to push the button to program the Teensy but I have tried it both ways. I can upload scripts to it just fine (like the rainbow script in the example files). I have just the nonworking Teensy connected right now and Tools >> Ports shows COM3 and COM4. Here is a copy of the script that works on one Teensy but not the other:

Code:
#include <OctoWS2811.h>

const int ledsPerStrip = 89*8;

DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];

const int config = WS2811_GRB | WS2811_800kHz;

OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);
String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete
  int microsec = 200000000 / leds.numPixels();  // change them all in 2 seconds


void setup() {
  leds.begin();
  leds.show();
  // initialize serial:
  Serial.begin(9600);
  inputString.reserve(200);
}

#define RED    0xFF0000
#define GREEN  0x00FF00
#define BLUE   0x0000FF
#define YELLOW 0xFFFF00
#define PINK   0xFF1088
#define ORANGE 0xE05800
#define WHITE  0xFFFFFF

void loop() {
  int inChar;

  // uncomment for voltage controlled speed
  // millisec = analogRead(A9) / 40;

//  colorWipe(RED, microsec);
//  colorWipe(GREEN, microsec);
//  colorWipe(BLUE, microsec);
//  colorWipe(YELLOW, microsec);
//  colorWipe(PINK, microsec);
//  colorWipe(ORANGE, microsec);
//  colorWipe(WHITE, microsec);
  
if (stringComplete) {
  //colorWipe(BLUE, microsec, inputString.toInt());
  inputString="";
}
}

void colorWipe(int color, int wait, int LEDnum)
{
    leds.setPixel(LEDnum+7*ledsPerStrip, color);
    leds.show();
    delayMicroseconds(wait);
    Serial.print(LEDnum);
    Serial.print('\n');
}



void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    //inputString="";
    char inChar = (char)Serial.read(); 
    // add it to the inputString:
    inputString += inChar;    
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == ',') {
     colorWipe(BLUE, microsec, inputString.toInt());
     inputString="";
     stringComplete = true;
    } 
    if (inChar == 'o') {
     for (int i = 0; i < ledsPerStrip; i++) {
       leds.setPixel(i+7*ledsPerStrip, 0);
       leds.show();
     }
    }
  }
}
 
@defragster I swapped the Teensy's and the problem persisted. I don't usually need to push the button to program the Teensy but I have tried it both ways. I can upload scripts to it just fine (like the rainbow script in the example files). I have just the nonworking Teensy connected right now and Tools >> Ports shows COM3 and COM4. Here is a copy of the script that works on one Teensy but not the other:

'persisted' ... To be clear - did it follow the problem Teensy to the other board - or stay with the board the formally working and make the better Teensy seem bad?

Not seeing anything telling - I'd try setup like this to see something print - and add a call to qBlink(); - perhaps in serialEvent or a place where it will toggle LED to show running code:
Code:
#define qBlink() (digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ))
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  qBlink();
  Serial.begin(9600);
  while ( !Serial && millis() <4000 ) ;
  Serial.print( "\n Hello World! ");
  qBlink();
  leds.begin();
  qBlink();
  leds.show();
  // initialize serial:
  qBlink();
  inputString.reserve(200);
}
 
Sorry, persisted meant that the non working Teensy was still not working when it switched to the other matrix.

I will try your code and get back to you. Thanks!
 
Okay, That suggests that Teensy has been rendered non-functional in some way. That code change to setup() and the qBlink will give some idea if it is coming up and going anywhere.

If I counted right LED will go on - wait up to 4 seconds for Serial to connect - then OFF, ON and OFF before leaving setup.
 
Status
Not open for further replies.
Back
Top