Jimi_Hendrik
New member
Dear all,
I have a Teensy 3.6 which is receiving sensor data from an Arduino Nano via UART (Baud 250000, 12 Bytes data package with a main loop running at 200 Hz) and is connected to a computer via USB (BAUD 230400, transmits 62 Bytes via Serial.write(buffer, length) at 400 Hz).
In this example I use Serial.print() but in my implementation I would use Serial.write for the full set of data (which also includes data from some analog sensors), which creates the same error.
Now I have the following issue: Sometimes I only receive a couple of bytes after opening the usb port and then the transmission stops (see figure). Then I flash the firmware again, and then it stops again after a few bytes. But when I repeat the flashing operation a few times, at some point it works and i get a continuous stream of data. Even after closing and reopening the usb port (but not after reconnecting the USB cable). My best guess is that some buffer is overflowing but the error seems to appear randomly...
Since I am a novice in this field I would be happy to receive some hints on how to fix or what to improve.
I have a Teensy 3.6 which is receiving sensor data from an Arduino Nano via UART (Baud 250000, 12 Bytes data package with a main loop running at 200 Hz) and is connected to a computer via USB (BAUD 230400, transmits 62 Bytes via Serial.write(buffer, length) at 400 Hz).
In this example I use Serial.print() but in my implementation I would use Serial.write for the full set of data (which also includes data from some analog sensors), which creates the same error.
Code:
//This is the Teensy implementation
float forces[3], torques[3];
Sensor Sensor(PinTx, PinRx);
void setup() {
Serial.begin(230400); // initialize a serial connection to computer
Sensor.begin();
}
void loop() {
if (Sensor.getForces(forces, torques) ) { // Reads the Arduino Nano datastream coming in at UART and parses to float array (confirmed working)
Serial.print(forces[0]);
// Serial.print(forces[1]); //If I want to print more than one field here it crashes.
}
delay(2); //If I take a higher number it works, if I have "2" it works randomly after I reflash the teensy a few times
}
Now I have the following issue: Sometimes I only receive a couple of bytes after opening the usb port and then the transmission stops (see figure). Then I flash the firmware again, and then it stops again after a few bytes. But when I repeat the flashing operation a few times, at some point it works and i get a continuous stream of data. Even after closing and reopening the usb port (but not after reconnecting the USB cable). My best guess is that some buffer is overflowing but the error seems to appear randomly...
Since I am a novice in this field I would be happy to receive some hints on how to fix or what to improve.