OttoDIY / OttoDIYLib

Latest and official Libraries for Arduino Otto DIY robots
http://www..ottodiy.com/
GNU General Public License v3.0
113 stars 73 forks source link

Wemos D1 mini with Soft WDT reset #21

Closed 408881465 closed 3 years ago

408881465 commented 3 years ago

I use Wemos D1 mini with my OTTO Robot, sometimes it goes with Soft WDT reset as follows.

My Code is as below:


#include <Otto.h>

#define LeftLeg 14 // left leg pin, servo[0]
#define RightLeg 12 // right leg pin, servo[1]
#define LeftFoot 13 // left foot pin, servo[2]
#define RightFoot 15 // right foot pin, servo[3]
#define Buzzer 16 //buzzer pin

Otto Otto;
String inputData;

void setup() {
  Serial.begin(9600);
  inputData = "home";
  Otto.init(LeftLeg, RightLeg, LeftFoot, RightFoot, true, Buzzer);
}

void loop() {
  if (Serial.available() > 0) {
    inputData = Serial.readString();
    inputData.trim();
    Serial.println(inputData);
    if (String(inputData).equals(String("home"))) {
      Otto.home();

    }
    if (String(inputData).equals(String("forward"))) {
      Otto.walk(1, 1000, 1); // FORWARD
      Otto.walk(1, 1000, 1); // FORWARD
      Otto.walk(1, 1000, 1); // FORWARD

    }
    if (String(inputData).equals(String("backward"))) {
      Otto.walk(1, 1000, -1);
      Otto.walk(1, 1000, -1);
      Otto.walk(1, 1000, -1);

    }
    if (String(inputData).equals(String("OttoHappy"))) {
      Otto.playGesture(OttoHappy);

    }
    if (String(inputData).equals(String("OttoSuperHappy"))) {
      Otto.playGesture(OttoSuperHappy);

    }
    if (String(inputData).equals(String("OttoSad"))) {
      Otto.playGesture(OttoSad);

    }
    if (String(inputData).equals(String("OttoSleeping"))) {
      Otto.playGesture(OttoSleeping);

    }
    if (String(inputData).equals(String("OttoConfused"))) {
      Otto.playGesture(OttoConfused);

    }
    if (String(inputData).equals(String("OttoFretful"))) {
      Otto.playGesture(OttoFretful);

    }
    if (String(inputData).equals(String("OttoLove"))) {
      Otto.playGesture(OttoLove);

    }
    if (String(inputData).equals(String("OttoAngry"))) {
      Otto.playGesture(OttoAngry);

    }
    if (String(inputData).equals(String("OttoMagic"))) {
      Otto.playGesture(OttoMagic);

    }
    if (String(inputData).equals(String("OttoWave"))) {
      Otto.playGesture(OttoWave);

    }
    if (String(inputData).equals(String("OttoVictory"))) {
      Otto.playGesture(OttoVictory);

    }
    if (String(inputData).equals(String("OttoFail"))) {
      Otto.playGesture(OttoFail);

    }
    if (String(inputData).equals(String("OttoFart"))) {
      Otto.playGesture(OttoFart);

    }

  }

}

After I send 'forward' in serial port, exception occurs.

forward   

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Soft WDT reset

>>>stack>>>

ctx: cont
sp: 3ffffcc0 end: 3fffffc0 offset: 01a0
3ffffe60:  00000000 00000000 4bc6a7f0 00000000  
3ffffe70:  035d2f80 3ffee9a4 4010055c 0002e8cf  
3ffffe80:  00000000 41075fd0 00000000 3ffee818  
3ffffe90:  3ffee818 41075fd0 3ffee818 402014a0  
3ffffea0:  49153a0b bfe728d4 00000000 402015f0  
3ffffeb0:  3ffee778 41075fd0 00000000 402019cc  
3ffffec0:  41074090 3fffff50 3fffff40 00000000  
3ffffed0:  3fffff20 000003e8 3ffee778 3fffff40  
3ffffee0:  3fffff20 000003e8 3ffee778 40201a74  
3ffffef0:  3fffff50 3f800000 00000001 00000000  
3fffff00:  3ffe8a8f 805fa1fb 000a0d00 00000001  
3fffff10:  3ffee778 000003e8 3f800000 40201b7c  
3fffff20:  00000000 00000000 00000000 00000000  
3fffff30:  54442d18 bff921fb 54442d18 bff921fb  
3fffff40:  00000000 00000000 00000004 fffffffc  
3fffff50:  00000014 00000014 00000014 00000014  
3fffff60:  3fffdad0 3fffff80 3ffee768 3ffeeac4  
3fffff70:  3ffee778 3f800000 3ffee768 4020119a  
3fffff80:  77726f00 00647261 80000001 77726f00  
3fffff90:  00647261 80000000 3ffeea84 4010019d  
3fffffa0:  3fffdad0 00000000 3ffeea84 40203f48  
3fffffb0:  feefeffe feefeffe 3ffe84e0 40100f3d  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

After I send 'OttoLove ' in serial port, exception occurs.

⸮⸮OttoLove 

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Soft WDT reset

>>>stack>>>

ctx: cont
sp: 3ffffb40 end: 3fffffc0 offset: 01a0
3ffffce0:  52832580 3fe4e63c 3ffffd60 40594bc7  
3ffffcf0:  000005e0 00000020 40103895 3ffecfc0  
3ffffd00:  11c12f3a 00418937 11c12f3a 00000000  
3ffffd10:  11c12f3a 00000000 00418937 00000000  
3ffffd20:  00000000 4bc6a7f0 40100541 4bc6a7f0  
3ffffd30:  00000000 00000000 4bc6a7f0 00000000  
3ffffd40:  05415fe6 40104a77 4010055c 00048b91  
3ffffd50:  00000000 411231b8 00000000 3ffee818  
3ffffd60:  3ffee818 411231b8 3ffee818 402014a0  
3ffffd70:  774b339c 3fe371e9 00000000 402015f0  
3ffffd80:  3ffee778 411231b8 00000000 402019cc  
3ffffd90:  41121a48 3ffffe20 3ffffe10 00000000  
3ffffda0:  3ffffdf0 000005dc 3ffee778 3ffffe10  
3ffffdb0:  3ffffdf0 000005dc 3ffee778 40201a74  
3ffffdc0:  3ffffe20 40000000 00000002 00000001  
3ffffdd0:  3ffee180 804721fb 00000007 40000000  
3ffffde0:  00000010 00000001 fffffff5 40201d44  
3ffffdf0:  00000000 40568000 00000000 40568000  
3ffffe00:  00000000 00000000 382d7365 bff0c152  
3ffffe10:  00000000 00000000 0000000b fffffff5  
3ffffe20:  00000019 00000019 0000000f 0000000f  
3ffffe30:  3ffee778 000005dc 78362e41 3ffeeac4  
3ffffe40:  3fffdad0 00000001 3ffee778 3ffeeac4  
3ffffe50:  3fffdad0 00000001 3ffee778 4020272c  
3ffffe60:  00001413 3fffc6fc 1302e850 4bc6a7f0  
3ffffe70:  0000005a 0000005a 00000022 00000023  
3ffffe80:  0000005a 0000005a 0000002a 00000023  
3ffffe90:  0000005a 0000005a 00000037 00000023  
3ffffea0:  0000005a 0000005a 00000046 00000023  
3ffffeb0:  0000005a 0000005a 0000005a 0000006e  
3ffffec0:  00000046 00000046 0000005a 0000005a  
3ffffed0:  0000006e 0000006e 0000005a 0000005a  
3ffffee0:  0000005a 0000005a 00000046 0000006e  
3ffffef0:  0000006e 00000046 0000005a 0000005a  
3fffff00:  0000005a 0000005a 00000091 00000050  
3fffff10:  0000005a 0000005a 00000050 0000007a  
3fffff20:  0000005a 0000005a 00000091 0000007a  
3fffff30:  00000064 00000050 0000003c 00000078  
3fffff40:  0000006e 00000046 00000014 000000a0  
3fffff50:  3fffff8c 3fffff80 3fffff8c 402036b1  
3fffff60:  3fffdad0 3fffff80 3ffee768 3ffeeac4  
3fffff70:  3fffdad0 00000001 3ffee768 4020131e  
3fffff80:  6f747400 65766f4c 80000000 6f747400  
3fffff90:  65766f4c 80000000 3ffeea84 4010019d  
3fffffa0:  3fffdad0 00000000 3ffeea84 40203f48  
3fffffb0:  feefeffe feefeffe 3ffe84e0 40100f3d  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------
⸮⸮

I decoding the stack with Exception Decoder as below.

Decoding stack results
0x4010055c: millis() at E:\Mixly_WIN\Mixly_WIN\arduino\portable\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring.cpp line 188
0x402014a0: Oscillator::next_sample() at E:\Mixly_WIN\Mixly_WIN\arduino\portable\sketchbook\libraries\OttoNEW\Oscillator.cpp line 26
0x402015f0: Oscillator::refresh() at E:\Mixly_WIN\Mixly_WIN\arduino\portable\sketchbook\libraries\OttoNEW\Oscillator.cpp line 109
0x402019cc: Otto::oscillateServos(int*, int*, int, double*, float) at E:\Mixly_WIN\Mixly_WIN\arduino\portable\sketchbook\libraries\OttoNEW\Otto.cpp line 136
0x40201a74: Otto::_execute(int*, int*, int, double*, float) at E:\Mixly_WIN\Mixly_WIN\arduino\portable\sketchbook\libraries\OttoNEW\Otto.cpp line 153
0x40201b7c: Otto::walk(float, int, int) at E:\Mixly_WIN\Mixly_WIN\arduino\portable\sketchbook\libraries\OttoNEW\Otto.cpp line 221
0x4020119a: loop() at E:\Mixly_WIN\Mixly_WIN\arduino\portable\sketchbook\my-esp-otto-crashes/my-esp-otto-crashes.ino line 34
0x4010019d: esp_schedule() at E:\Mixly_WIN\Mixly_WIN\arduino\portable\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 125
0x40203f48: loop_wrapper() at E:\Mixly_WIN\Mixly_WIN\arduino\portable\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 197
Decoding stack results
0x40100541: millis() at E:\Mixly_WIN\Mixly_WIN\arduino\portable\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring.cpp line 185
0x4010055c: millis() at E:\Mixly_WIN\Mixly_WIN\arduino\portable\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring.cpp line 188
0x402014a0: Oscillator::next_sample() at E:\Mixly_WIN\Mixly_WIN\arduino\portable\sketchbook\libraries\OttoNEW\Oscillator.cpp line 26
0x402015f0: Oscillator::refresh() at E:\Mixly_WIN\Mixly_WIN\arduino\portable\sketchbook\libraries\OttoNEW\Oscillator.cpp line 109
0x402019cc: Otto::oscillateServos(int*, int*, int, double*, float) at E:\Mixly_WIN\Mixly_WIN\arduino\portable\sketchbook\libraries\OttoNEW\Otto.cpp line 136
0x40201a74: Otto::_execute(int*, int*, int, double*, float) at E:\Mixly_WIN\Mixly_WIN\arduino\portable\sketchbook\libraries\OttoNEW\Otto.cpp line 153
0x40201d44: Otto::crusaito(float, int, int, int) at E:\Mixly_WIN\Mixly_WIN\arduino\portable\sketchbook\libraries\OttoNEW\Otto.cpp line 496
0x4020272c: Otto::playGesture(int) at E:\Mixly_WIN\Mixly_WIN\arduino\portable\sketchbook\libraries\OttoNEW\Otto.cpp line 865
0x402036b1: String::invalidate() at E:\Mixly_WIN\Mixly_WIN\arduino\portable\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\WString.cpp line 140
0x4020131e: loop() at E:\Mixly_WIN\Mixly_WIN\arduino\portable\sketchbook\my-esp-otto-crashes/my-esp-otto-crashes.ino line 68
0x4010019d: esp_schedule() at E:\Mixly_WIN\Mixly_WIN\arduino\portable\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 125
0x40203f48: loop_wrapper() at E:\Mixly_WIN\Mixly_WIN\arduino\portable\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 197

How to fix this bug.Thanks.

cparrapa commented 3 years ago

Hi @408881465

Watchdog timer, what are you trying to make?

can you post pics of your robot in builders.ottodiy.com? Thanks

408881465 commented 3 years ago

I woulid like to crontrol OTTO Robot by sending serial port command.

The Wemos D1 mini board is below.

cparrapa commented 3 years ago

Have your tried using normal arduino nano?

408881465 commented 3 years ago

Hi @cparrapa ,

Thanks for your reply.

I have no arduino nano on hand ,so I have not tested it using normal arduino nano.Actually I would like to play OTTO with IOT, so I use Wemos D1 mini. It seems that the Otto.walk() and Otto.playGesture(OttoLove) functions don't feed the watchdog of ESP properly.

BR Tom

408881465 commented 3 years ago

Hi @cparrapa

After I added delay(10); in oscillateServos function, the Soft WDT reset bugs disappear.

void Otto::oscillateServos(int A[4], int O[4], int T, double phase_diff[4], float cycle=1){

  for (int i=0; i<4; i++) {
    servo[i].SetO(O[i]);
    servo[i].SetA(A[i]);
    servo[i].SetT(T);
    servo[i].SetPh(phase_diff[i]);
  }
  double ref=millis();
   for (double x=ref; x<=T*cycle+ref; x=millis()){
     for (int i=0; i<4; i++){
        servo[i].refresh();
     }
  }
  delay(10);
}