Can't connect to Teesny anymore

Status
Not open for further replies.
Hello everyone!

I'm having a problem with my Teensy 3.2. I had been happily coding with it throughout the last days. Yesterday I implemented a code that uses the serial monitor as input. The code would get bytes from the serial monitor and then print the respective text on a LED-Matrix that I've built on my own. All worked perfectly until I unplugged the teensy at some point while serial monitor was still running. Since then I can't connect my Teensy anymore as the arduino IDE throws the "No Teensy boards were found on any USB ports of your computer." error message and there is no COM Port device detected by the Computer. I tried to upload new code by pressing the pushbutton - didn't work. However the old code appears to still run on the Teensy it just doesn't print anything anymore because there's no input from the serial monitor. I also noticed that in the bottom right corner of my arduino IDE it doesn't say "Teensy 3.2 [...] on COM1" anymore like it did before but rather "Teensy 3.2 [...] on usb:0/140000/0/3" (I don't know if that's related but I had to switch from COM1 to COM5 in the tools>ports menu to be able to connect the teensy and the serial monitor). Finally I tried to reinstall the arduino and Teensy uploader but it didn't work either. I attached the code below and highlighted the parts where I used the serial.


Code:
#include <TimerOne.h>

#define ROW_DATA     0    //Pin Number for Row Serial Data output
#define ROW_SCLK     1    //Pin Number for ROW SERIAL CLK output
#define ROW_NSCLR    2    //Pin Number for ROW INV SERIAL CLK output

#define BLUE_DATA    3    //Pin Number for B-Value Serial Data output
#define BLUE_NSCLR   4    //Pin Number for BLUE INV REGISTER CLEAR
#define BLUE_SCLK    5    //Pin Number for BLUE SERIAL CLK output
#define BLUE_RCLK    6    //Pin Number for BLUE REGISTER CLK output
#define BLUE_NOE     7    //Pin Number for BLUE INV OUTPUT ENABLE output

#define GREEN_DATA   8    //Pin Number for G-Value Serial Data output
#define GREEN_NSCLR 18    //Pin Number for GREEN INV REGISTER CLEAR
#define GREEN_SCLK  17    //Pin Number for GREEN SERIAL CLK output
#define GREEN_RCLK  16    //Pin Number for GREEN REGISTER CLK output
#define GREEN_NOE   20    //Pin Number for GREEN INV OUTPUT ENABLE output

#define RED_DATA    19    //Pin Number for R-Value Serial Data output
#define RED_NSCLR   23    //Pin Number for RED INV REGISTER CLEAR
#define RED_SCLK    22    //Pin Number for RED SERIAL CLK output
#define RED_RCLK    21    //Pin Number for RED REGISTER CLK output
#define RED_NOE     15    //Pin Number for RED INV OUTPUT ENABLE output

#define RED         1     //Color Code for Red
#define GREEN       2     //Color Code for Green
#define YELLOW      3     //Color Code for Yellow
#define BLUE        4     //Color Code for Blue
#define PURPLE      5     //Color Code for Purple
#define TURQ        6     //Color Code for Turquoise
#define WEISS       7     //Color Code for White

#define LED         13

//Initialize Counter and State Variable for Interrupt handler 
volatile int scnt = 0;
volatile int rcnt = 9;
volatile int SCLK_State = 0;
volatile int RCLK_State = 0;
volatile int RSCLK_State = 0;
volatile int RSER_State = 0;

int color[8]={0,RED,GREEN,BLUE,YELLOW,TURQ,PURPLE,WEISS};

//Buchstaben
int Alphabet[26][10]={{14,17,17,17,31,17,17,17,17, 0},{30,17,17,17,30,17,17,17,30, 0},{15,16,16,16,16,16,16,16,15, 0},   
                      {28,18,17,17,17,17,17,18,28, 0},{31,16,16,16,28,16,16,16,31, 0},{31,16,16,16,28,16,16,16,16, 0},   
                      {14,17,16,16,16,23,17,17,15, 0},{17,17,17,17,31,17,17,17,17, 0},{31, 4, 4, 4, 4, 4, 4, 4,31, 0},   
                      {31, 1, 1, 1, 1, 1, 1, 1,30, 0},{17,17,18,20,24,20,18,17,17, 0},{16,16,16,16,16,16,16,16,31, 0},   
                      {17,27,21,17,17,17,17,17,17, 0},{17,25,21,19,17,17,17,17,17, 0},{14,17,17,17,17,17,17,17,14, 0},
                      {30,17,17,17,30,16,16,16,16, 0},{14,17,17,17,17,17,21,19,15, 0},{30,17,17,17,30,20,18,17,17, 0},
                      {15,16,16,16,14, 1, 1, 1,30, 0},{31, 4, 4, 4, 4, 4, 4, 4, 4, 0},{17,17,17,17,17,17,17,17,31, 0},
                      {17,17,17,17,17,17,17,10, 4, 0},{17,17,17,17,17,17,21,27,17, 0},{17,17,17,10, 4,10,17,17,17, 0},
                      {17,27,21, 4, 4, 4, 4, 4, 4, 0},{31, 1, 2, 4, 8,16,16,16,31, 0}};
//Zeichen
int Space[10]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int Qmark[10]={14,17, 1, 1, 2, 4, 4, 0, 4, 0}; 
int Xmark[10]={ 4, 4, 4, 4, 4, 4, 4, 0, 4, 0};

//Initialize Image Matrix
volatile byte image[10][24];
volatile byte pixel=0;
String inString;          //Ausgelesener String
volatile int SerFlag=0;            //Interrupt Flag

void setup() {
  // put your setup code here, to run once:

  //Set output Pins
  pinMode(RED_DATA,OUTPUT);
  pinMode(GREEN_DATA,OUTPUT);
  pinMode(BLUE_DATA,OUTPUT);
  pinMode(ROW_DATA,OUTPUT);
  pinMode(RED_RCLK,OUTPUT);
  pinMode(GREEN_RCLK,OUTPUT);
  pinMode(BLUE_RCLK,OUTPUT);
  pinMode(RED_SCLK,OUTPUT);
  pinMode(GREEN_SCLK,OUTPUT);
  pinMode(BLUE_SCLK,OUTPUT);
  pinMode(RED_NSCLR,OUTPUT);
  pinMode(GREEN_NSCLR,OUTPUT);
  pinMode(BLUE_NSCLR,OUTPUT);
  pinMode(RED_NOE,OUTPUT);
  pinMode(GREEN_NOE,OUTPUT);
  pinMode(BLUE_NOE,OUTPUT);
  pinMode(ROW_SCLK,OUTPUT);
  pinMode(ROW_NSCLR,OUTPUT);

  pinMode(LED,OUTPUT);

  // Initialize output pins
  digitalWrite(RED_DATA,HIGH);
  digitalWrite(GREEN_DATA,HIGH);
  digitalWrite(BLUE_DATA,HIGH);
  digitalWrite(ROW_DATA,LOW);
  digitalWrite(RED_RCLK,LOW);
  digitalWrite(GREEN_RCLK,LOW);
  digitalWrite(BLUE_RCLK,LOW);
  digitalWrite(RED_SCLK,LOW);
  digitalWrite(GREEN_SCLK,LOW);
  digitalWrite(BLUE_SCLK,LOW);
  digitalWrite(RED_NSCLR,LOW);
  digitalWrite(GREEN_NSCLR,LOW);
  digitalWrite(BLUE_NSCLR,LOW);
  digitalWrite(RED_NOE,HIGH);
  digitalWrite(GREEN_NOE,HIGH);
  digitalWrite(BLUE_NOE,HIGH);
  digitalWrite(ROW_SCLK,LOW);
  digitalWrite(ROW_NSCLR,LOW);
  digitalWrite(LED,LOW); 

  delay(100);

  digitalWrite(RED_NSCLR,HIGH);
  digitalWrite(GREEN_NSCLR,HIGH);
  digitalWrite(BLUE_NSCLR,HIGH);
  digitalWrite(RED_NOE,LOW);
  digitalWrite(GREEN_NOE,LOW);
  digitalWrite(BLUE_NOE,LOW);
  digitalWrite(ROW_NSCLR,HIGH);
  digitalWrite(ROW_DATA,HIGH); 

  //Initialize Timer to trigger interrupt with 14.4kHz
  Timer1.initialize(20);
  Timer1.attachInterrupt(MatrixOut);  

[COLOR="#FF8C00"]//Initialize Serial Port
  Serial.begin(9600);[/COLOR]

  
  //Initialize Matrix 
  for (int i=0; i<10; i++){
    for (int j=0; j<24; j++){
       image[i][j]= BLUE;
    }
  }  
}

//Timer1 Interrupt handler
void MatrixOut(void)
{
  SCLK_State = scnt &  1;               //Toggles with every interrupt
  RCLK_State = scnt == 0;               //Toggles twice when new row starts 
  RSER_State = rcnt == 1;               //Stays up during first row of every image, the 1 is then shiftet through with RSCLK to enable the other rows subsequently
  RSCLK_State = scnt<24;                //Toggles twice during every row
  
  pixel = image[rcnt][scnt>>1];          //Copy current image pixel 

  //Write pinstates
  digitalWrite(RED_SCLK,SCLK_State);    
  digitalWrite(RED_RCLK,RCLK_State);
  digitalWrite(RED_DATA,!(pixel & 1));  
  
  digitalWrite(GREEN_SCLK,SCLK_State);
  digitalWrite(GREEN_RCLK,RCLK_State);
  digitalWrite(GREEN_DATA,!((pixel>>1) & 1));

  digitalWrite(BLUE_SCLK,SCLK_State);
  digitalWrite(BLUE_RCLK,RCLK_State);
  digitalWrite(BLUE_DATA,!((pixel>>2) & 1));

  digitalWrite(ROW_DATA,RSER_State);
  digitalWrite(ROW_SCLK,RSCLK_State);
  

  //increment counters
  scnt++;
  
  if(scnt > 47){
    scnt=0;
    rcnt++;
    if(rcnt > 9){
      rcnt=0;
    }
  }

}

[COLOR="#FF8C00"]//SerialEvent Handler
void serialEvent(){
  SerFlag=1;
}

void loop() {
  // put your main code here, to run repeatedly:
  for (int j=0;j<10;j++){
    for (int k=0;k<24;k++){
      image[j][k]=0;
    }
  }
  
  if(Serial.available()){
    SerFlag=0;
    int n=Serial.available();
    char chars[n];
    for(int i=0;i<n;i++){
      chars[i]=Serial.read();
    }
    inString=chars;
    Serial.print(inString);
    Serial.println("");
    runText(inString,BLUE);
  }
}[/COLOR]

void runText(String Input, int color){
  int len=Input.length();
  int Text[10][len*6+48];
  for (int h=0; h<len*6+48;h++){
    for (int g=0; g<10; g++){ 
      Text[g][h]=0;
    }
  }
  for (int i=0; i<len; i++){
    int cnt=0;
    int let=Input.charAt(i);
    if ((let<65)||(let>122)){
     if(let==33){
      for (int j=24+i*6;j<i*6+30;j++){
        for (int k=0; k<9; k++){
          int on=((Xmark[k]>>(5-(j-(24+i*6))))&1);
          if (on){
            Text[k][j]=color;
          }
        }
      }
     }else if(let==63){
      for (int j=24+i*6;j<i*6+30;j++){
        for (int k=0; k<9; k++){
          int on=((Qmark[k]>>(5-(j-(24+i*6))))&1);
          if (on){
            Text[k][j]=color;
          }
        }
      }
     }else{
      
     }
    
    }else if(let<97){
      int idx=let-65;
      for (int j=24+i*6;j<i*6+30;j++){
        for (int k=0; k<9; k++){
          int on=((Alphabet[idx][k]>>(5-(j-(24+i*6))))&1);
          if (on){
            Text[k][j]=color;
          }
        }
      }
    }else{
      int idx=let-97;
      for (int j=24+i*6;j<i*6+30;j++){
        for (int k=0; k<9; k++){
          int on= ((Alphabet[idx][k]>>(5-(j-(24+i*6))))&1);
          if (on){
            Text[k][j]=color;
          }           
        }
      }
    }
  }
  int shift=0;
  while(1){
    while(shift<len*6+24){
     for (int i=0; i<24;i++){
      for (int j=0; j<10;j++){
        image[j][i]=Text[j][shift+i];
        if(SerFlag){
          return;
        }
      }
     }
     shift++; 
     delay(100);
     
    }
    shift=0;
  }
}

Help would be greatly appreciated!

Thanks in advance and cheers,
Mladenman
 
I've had a somewhat similar problem that I handled a few minutes ago, although I still need to fix the original issue that I was trying to solve. What OS are you using? I'm guessing Windows. In Win10, you can go to settings>update & security > troubleshoot, and plug it in and run the Hardware And Devices troubleshooter. For me, it made some driver changes (I accidentally on purpose messed with them to see if I could solve my original problem) and required a restart and then the Teensy LC showed up again. There may be a similar troubleshooter in older versions of Windows. I hope this helps.
 
All worked perfectly until I unplugged the teensy at some point while serial monitor was still running.

Maybe you're using Windows 7 or 8?

There's a known driver bug in all pre-10 versions of Windows, where unplugging while the port is in uses causes the driver gets messed up the *next* time you connect Teensy. Rebooting solves the problem. So does upgrading to Windows 10 (or Linux or Macintosh).
 
Thanks for the reply! Yes, I'm using win8. However, I tried rebooting the computer and plugging in the teensy while pressing the pushbutton but it didn't change anything :/
 
Best to keep Teensy Loader visible on your screen while testing, and turn off Auto mode.

When you release the button, Teensy Loader is supposed to detect the board. You can only see this easily if Auto mode is turned off. When Auto mode is on, it will quickly reprogram and reboot the board.

You should also see a "HID compliant device" appear in the Windows Device Manager. In the details tab, its Hardware-Id should have "HID\VID_16C0&PIC_0478".

https://www.pjrc.com/teensy/check_halfkay_vista.html
 
Best to keep Teensy Loader visible on your screen while testing, and turn off Auto mode.

When you release the button, Teensy Loader is supposed to detect the board. You can only see this easily if Auto mode is turned off.

Unfortunately I can't see anything happening when I do this ...

You should also see a "HID compliant device" appear in the Windows Device Manager. In the details tab, its Hardware-Id should have "HID\VID_16C0&PIC_0478".

There are some devices, but none of them has this ID, does that maybe mean the USB driver of the Teensy itself isn't working anymore?
 
Can you try another good cable? I've lost time when a good cable went bad … Also using a different USB port - and perhaps performing a reboot of the computer in case Windows has written the port off for confusion.

The BUTTON on the Teensy and the program mode provides an interface independent of any USER code on the Teensy so it doesn't take usable Teensy USB user code to work - that is more of the Magic and joy provided by the secondary bootloader processor chip PJRC puts on the Teensy. Particularly when the button is held as indicated above when the Teensy is plugged in.
 
Can you try another good cable?
Yep I tried a different cable and verified the old one was still working with other devices.
I also changed the USB Port and rebooted multiple times. Still nothing changes... When I connect a different µC board it is shown in the device manager...
 
There are some devices, but none of them has this ID, does that maybe mean the USB driver of the Teensy itself isn't working anymore?

No, it most certainly does not mean the driver is broken. If anything, those other HID devices show the driver is working on your system!

The HID driver is extremely reliable. If it breaks, you lose keyboard & mouse support (well, unless you're using an ancient non-USB keyboard). Every version of Windows has this driver always installed. That's why we designed Teensy to use HID protocol. It's the one absolutely solid & reliable driver on all versions of Windows.

But if you really want to rule out such problems, just test on a different computer. Or boot your PC with an Ubunutu Linux CD (or USB stick) and use the no-install live system. Open a terminal and run "lsusb", and look for any USB device with an ID starting with "16c0".


Yep I tried a different cable and verified the old one was still working with other devices.
I also changed the USB Port and rebooted multiple times. Still nothing changes... When I connect a different µC board it is shown in the device manager...

Well, then this is really looking like some sort of hardware problem. If you have *any* other hardware connected to your Teensy, now is the time to remove it, in case it's somehow interfering. If you've got a voltmeter, this is a good time to check whether VIN is close to 5V and the 3.3V power is present. Visually inspect the USB connector and the board in general for signs of damage.

If all this fails, I'm afraid there's a very real possibility your board got damaged somehow and may be permanently dead.

But over and over again on this forum, we've seen cases like this where it was the USB cable or some other hardware connected was drawing too much power or similar problems. Hopefully yours will be one of those. But from all the info you've given and everything you've said you've done so far, I'm afraid it's not looking too good at this point.
 
Status
Not open for further replies.
Back
Top