Possible USB issue Teensy 3.2

Status
Not open for further replies.
I wrote a simple sketch that sends a message every 300ms over the USB serial on a teensy 3.2. The messages alternate between two versions.

I noticed that some times the same message repeats, as if a data packet was being dropped. I tried using another serial port and an FTDI USB serial converter and saw no problems.

Along the way I tried connecting the teensy USB serial to a serial monitor app called termite but it did not work. It only works when using the Arduino serial monitor. If I use Termite to connect to the FTDI serial it works fine, it just doesn't like the native USB on the Teensy.

I recompiled the same code and tested it on an UNO with no issues (but UNO uses the FTDI chip for serial anyway so I didn't expect it to)

I haven't yet tried reinstalling any USB drivers but I was wondering if anyone has encountered this issue before and if so whether they know if it is specific to teensy?.

Code:
const int VIB_PWM = 3;
const int VIB_EN  = 13;
const int delaytime = 300;
long int stepn = 0;
void setup() {
  Serial.begin(115200);
  //Serial1.begin(115200);
  pinMode(VIB_PWM, OUTPUT);
  pinMode(VIB_EN, OUTPUT);
}

void loop() {
  vibON();
  if(Serial) {Serial.print(stepn);Serial.println(" ON");}
   //Serial1.print(stepn);Serial1.println(" ON");
  stepn++;
  delay(delaytime);
  vibOFF();
  if(Serial) {Serial.print(stepn);Serial.println(" --");}
  //Serial1.print(stepn);Serial1.println(" --");
  stepn++;
  delay(delaytime);
}

void vibON(){
  digitalWrite(VIB_EN, 1);
  analogWrite(VIB_PWM, 1023);
}

void vibOFF(){
  digitalWrite(VIB_EN, 0);
  analogWrite(VIB_PWM, 0);
}
 
A problem with IDE SerMon when Serial was connected showing (!Serial) as TRUE was recently reported - i.e. (Serial) goes FALSE. Perhaps this is somehow replicating in this case?

Try that code removing the "if (Serial)" test.

In the case noted above - printing even when (!Serial) was tested - a .print() saying "NO SERIAL" was still displayed.

When I ran that same code against TyCommander - there was no FALSE reporting relating to if (Serial) {}
 
Please try uploading with Tools > USB Type set to RawHID. That will cause Arduino to use HID to emulate serial. It’s completely different code and a different driver. Whether the problem still happens in both modes can really help narrow down where it’s losing data.
 
I just removed the if(Serial) as suggested and it isn't dropping packets any more I used this code to indicate if the if(Serial) returns true or not:
Code:
void loop() {
  vibON();
  if(Serial)Serial.println("S-ON ");
  else      Serial.println("SOFF ");
  Serial.print(stepn);Serial.println(" ON");
  stepn++;
  delay(delaytime);
  vibOFF();
  //if(Serial) {Serial.print(stepn);Serial.println(" --");}
  Serial.print(stepn);Serial.println(" --");
  stepn++;
  delay(delaytime);
}
When connected to the Arduino serial monitor is periodically shows as not connected however when connecting with Termite it shows as never connected - this explains why I didn't get any output from Termite, but I would like to understand why it doesn't recognise an open serial connection here.
 
I've made a first beta release of an ambitious redesign of the Arduino serial monitor and ports menu. It's meant to solve these long-standing issues.

https://forum.pjrc.com/threads/49831-Teensyduino-1-42-Beta-1

If you're still watching this thread and experiencing this problem, please give this latest beta a try. It's still a bit rough around the edges, as you can see from the known issues list. But it does already solve some of these problems, and my hope is to be able to fix every long-standing serial issue by the 1.42 release. Some of these problems only happen on certain computers or with specific setups, so I'm really depending on feedback.
 
Status
Not open for further replies.
Back
Top