Hello everyone.
I'm doing a certain project working with TEENSY 4.0.
I make a current pulse. And with the help of the controller I control the current with a simple pid.
At the end of each pulse. I send the samples made by the controller to the computer via serial communication (Serial.println ()).
During the pulse I save the current samples (25 k samples) in an array of floats. And at the end of the teensy pulse sends the whole array in one blow.
Every time I try to send the entries I stop getting information from teensy (can still send information to him and he responds to the information (not in serial back))
To "fix" the problem I disconnect and connect the USB cable from the computer and everything works out until the next pulse.
Yesterday, after an hour of disconnections and connections. The teensy stopped communicating completely with the computer. The computer no longer recognizes it as a serial device and also any attempt I tried with the program button did not help.
The code snippet of the serial sending.
I'm doing a certain project working with TEENSY 4.0.
I make a current pulse. And with the help of the controller I control the current with a simple pid.
At the end of each pulse. I send the samples made by the controller to the computer via serial communication (Serial.println ()).
During the pulse I save the current samples (25 k samples) in an array of floats. And at the end of the teensy pulse sends the whole array in one blow.
Every time I try to send the entries I stop getting information from teensy (can still send information to him and he responds to the information (not in serial back))
To "fix" the problem I disconnect and connect the USB cable from the computer and everything works out until the next pulse.
Yesterday, after an hour of disconnections and connections. The teensy stopped communicating completely with the computer. The computer no longer recognizes it as a serial device and also any attempt I tried with the program button did not help.
The code snippet of the serial sending.
Code:
/////////////////////////////////////////////////////////////END OF PULSE///////////////////////////////////////////
digitalWrite(outgate1, LOW);
analogWrite(outgate2, LOW);
arraypulsestop=arrsize;
trigertime = millis() - starttime;
while (trigertime < pulsewitdhval+5) {
trigertime = millis() - starttime;
RunAvg ( analogCurrentIn, SizeOfRead, totalCur, readIndexCur,averageCur, inputCurARR);
realcurrent=(((((float)(averageCur)*(3.3/4096.0))/(Ivoltdiv)))-Idcfix);
TimeSand[arrsize]=trigertime;
CurrentSand[arrsize]=realcurrent;
arrsize++;
//Serial.println(realcurrent);
}
if(arrsize!=0){
/*Serial.println('t');
for(int y=0;y<arrsize;y++){
Serial.println(TimeSand[y]);
}
Serial.println('T');
delay(100);
Serial.println('c');*/
for(int y=0;y<arrsize;y++){
if(maxcur<=CurrentSand[y]){
maxcur=CurrentSand[y];
}
if(y>arraypulsestart && y<arraypulsestop){
if(mincur>=CurrentSand[y]){
mincur=CurrentSand[y];
}
curavg+=double(CurrentSand[y]/(arraypulsestop-arraypulsestart));
}
Serial.println(CurrentSand[y]);
}
// Serial.println('C');
Serial.print("Max current = ");
Serial.println(maxcur);
Serial.print("Min current = ");
Serial.println(mincur);
Serial.print("Average current= ");
Serial.println(curavg);
Serial.print("Ripple = ");
Serial.println(maxcur-mincur);
Serial.print("Ripple % = ");
Serial.println(float((maxcur-mincur)*100/currentval));
Serial.print("Cap Voltage = ");
Serial.println(capacitorVoltCalcF);
Serial.print("Resistance");
Serial.println((double)capacitorVoltCalcF/maxcur,4);
}
delay(500);
TIK=millis();
stopwatch.Reset();