Hello,ich möchte hier mal ganz vorsichtig Erfolg vermelden. Nach unzähligen Analysen, Modifikationen im Quellcode und bei den Debug-Ausgaben, bin ich zu der Überzeugung gekommen, dass das Problem, welches den Watchdog-Reset erzeugt, der Watchdog selbst ist.
Der Watchdog ist im Prinzip ein Timer, den man auf 10 Sekunden einstellt. Laufen diese 10 Sekunden ab, dann resetet der Watchdog den Adafruit. Damit das nicht passiert, wird in jedem Loop des Adafruit der Watchdog wieder auf 10 Sekunden gestellt. Bei mir dauert ein durchschnittlicher Loop 3 Millisekunden und im Bestfall unter einer Millisekunde. Meine Vermutung ist, dass es bei diesem häufigen Zurücksetzen des Watchdog-Timers zu Komplikationen kommt.
Als Lösung setze ich den Watchdog-Timer nur noch einmal pro Sekunde zurück. Seit dieser Änderung habe ich inzwischen 2 Batterieladungen bis zu Grund leergefahren und keinerlei Probleme mit dem Watchdog mehr. Ich hoffe, dass das auch so bleibt.
Ich halt euch auf dem Laufenden.
Watchod reset can have multiple cause ,so you need to add some part in the code to help detect the trouble.Hello,
could you share your code modification. I will try on my side.
At this time, some days I have no reset, some days I could have 3/4 resets. It is very variable
void run(){
//bber
unsigned long StartReadAt = 0;
unsigned long EndReadAt = 0;
unsigned long ReadDuration = 0;
// IMU
if (millis() > nextImuTime)
{
nextImuTime = millis() + 50;
// imu.resetFifo();
if (imuIsCalibrating)
{
activeOp->onImuCalibration();
}
else
{
StartReadAt = millis();
readIMU();
EndReadAt = millis();
ReadDuration = EndReadAt - StartReadAt;
if (ReadDuration > 30)
{
CONSOLE.println("Error reading IMU too long duration need < 30 : ");
CONSOLE.println(ReadDuration);
}
}
}
gps.run();
calcStats();
if (millis() >= nextControlTime)
{
if (millis()-nextControlTime > 20)
{
CONSOLE.print("Exceed Control time duration better if < 20 ms : ");
CONSOLE.println(millis()-nextControlTime);
}
nextControlTime = millis() + 20;
controlLoops++;
hey Manu27,Hello,
could you share your code modification. I will try on my side.
At this time, some days I have no reset, some days I could have 3/4 resets. It is very variable
Yes with AGCM4 its the same. In sunray, it is used to store some debug-Information. The Watchdog-Reset is hardcoded to 16sec. The debug-information will be stored after 10sec.Maybe the Adafruit watchdog can do the same ??
did you test my code? With that smal changes my mower runs like a charme, without any watchdog-resets.hey Manu27,
you can find my changes on Github in the watchdog-tree. It is based on version 303.
I think, you are right with that, but for me the workaround does the job for the moment hopefully till the bug is fixed.With all this in mind, don't forget that there is a serious stack problem with AGCM4. see github error message "code wastes stack memory on AGCM4".
This causes an unpredictable, unstable behaviour and SW hangs, at least for me.
Comment out this line into comm.cppWith all this in mind, don't forget that there is a serious stack problem with AGCM4. see github error message "code wastes stack memory on AGCM4".
This causes an unpredictable, unstable behaviour and SW hangs, at least for me. If I replace the AGCM4 with an Ardiuno DUE, I notice a stable stack pointer and the Ardumower runs (almost) without those problems!
CONSOLE.print (statControlCycleTime);
//CONSOLE.print (" op=");
//CONSOLE.print (activeOp->getOpChain());
//CONSOLE.print (stateOp);
#ifdef __linux__
Not the same at all: Only a resetWatchdog occur after 10 sec and it did not help at all if GCM4 freeze the reset is never call and watchdog is trig after 16sec without any info.,Yes with AGCM4 its the same. In sunray, it is used to store some debug-Information. The Watchdog-Reset is hardcoded to 16sec. The debug-information will be stored after 10sec.
Is that really so easy? Just changed and flashed... sp is stable!Comment out this line into comm.cpp
Unfortunately this practice do not solve the bug describe by @AlexanderG in the activeOp->getOpChain() .Seems to work on my AGCM4 as well!
Incredible, you solved the problem! There's a trophy for that!!! Many thanks for your efforts! How did you come up with this and do you have any explanation for the behaviour of the stack?
// output summary on console
void outputConsole(){
//return;
if (millis() > nextInfoTime){
bool started = (nextInfoTime == 0);
nextInfoTime = millis() + 120000;
unsigned long totalsecs = millis()/1000;
unsigned long totalmins = totalsecs/60;
unsigned long hour = totalmins/60;
unsigned long min = totalmins % 60;
unsigned long sec = totalsecs % 60;
CONSOLE.print (hour);
CONSOLE.print (":");
CONSOLE.print (min);
CONSOLE.print (":");
CONSOLE.print (sec);
CONSOLE.print (" ctlDur=");
//if (!imuIsCalibrating){
if (!started){
if (controlLoops > 0){
statControlCycleTime = 1.0 / (((float)controlLoops)/120.0);
} else statControlCycleTime = 120;
statMaxControlCycleTime = max(statMaxControlCycleTime, statControlCycleTime);
}
controlLoops=0;
CONSOLE.print (statControlCycleTime);
//CONSOLE.print (" op=");
//CONSOLE.print (activeOp->getOpChain());
//CONSOLE.print (stateOp);
#ifdef __linux__
CONSOLE.print (" mem=");
struct rusage r_usage;
getrusage(RUSAGE_SELF,&r_usage);
CONSOLE.print(r_usage.ru_maxrss);
#else
CONSOLE.print (" freem=");
CONSOLE.print (freeMemory());
uint32_t *spReg = (uint32_t*)__get_MSP(); // stack pointer
CONSOLE.print (" sp=");
CONSOLE.print (*spReg, HEX);
#endif
// CONSOLE.print(" bat=");
// CONSOLE.print(battery.batteryVoltage);
// CONSOLE.print(",");
// CONSOLE.print(battery.batteryVoltageSlope, 3);
// CONSOLE.print("(");
// CONSOLE.print(motor.motorsSenseLP);
// CONSOLE.print(") chg=");
// CONSOLE.print(battery.chargingVoltage);
// CONSOLE.print("(");
// CONSOLE.print(battery.chargingCurrent);
// CONSOLE.print(") diff=");
// CONSOLE.print(battery.chargingVoltBatteryVoltDiff, 3);
// CONSOLE.print(" tg=");
// CONSOLE.print(maps.targetPoint.x());
// CONSOLE.print(",");
// CONSOLE.print(maps.targetPoint.y());
// CONSOLE.print(" x=");
// CONSOLE.print(stateX);
// CONSOLE.print(" y=");
// CONSOLE.print(stateY);
// CONSOLE.print(" delta=");
// CONSOLE.print(stateDelta);
// CONSOLE.print(" tow=");
// CONSOLE.print(gps.iTOW);
// CONSOLE.print(" lon=");
// CONSOLE.print(gps.lon,8);
// CONSOLE.print(" lat=");
// CONSOLE.print(gps.lat,8);
// CONSOLE.print(" h=");
// CONSOLE.print(gps.height,1);
// CONSOLE.print(" n=");
// CONSOLE.print(gps.relPosN);
// CONSOLE.print(" e=");
// CONSOLE.print(gps.relPosE);
// CONSOLE.print(" d=");
// CONSOLE.print(gps.relPosD);
// CONSOLE.print(" sol=");
// CONSOLE.print(gps.solution);
// CONSOLE.print(" age=");
// CONSOLE.print((millis()-gps.dgpsAge)/1000.0);
CONSOLE.println();
//logCPUHealth();
}
great job to find out!Comment out this line into comm.cpp