Blynk freezes - Soft WDT reset - when working with a stepper motor

Добрый вечер.

Подскажите что доделать, чтобы в момент работы шагового двигателя (30 секунд и более) Blynk не подвисал и не вылетал с ошибкой - Soft WDT reset

Вот часть моего кода:


Good evening.

Tell me what to finish, so that when the stepper motor is running (30 seconds or more), Blynk does not move or fly with an error - Soft WDT reset

Here is part of my code:

BLYNK_WRITE(V0)   // Кнопка
{
  if (param.asInt() == 1 && oldposition == 0) // Проверяе закрывать если было открыто
  {
    oldposition = param.asInt();
    EEPROM.write(0, oldposition); // Записываем в память последнее положение
    EEPROM.commit();

    gostep(1000);
  }

  if (param.asInt() == 0 && oldposition == 1) // Проверяем открывать если было закрыто
  {
    oldposition = param.asInt();
    EEPROM.write(0, oldposition); // Записываем в память последнее положение
    EEPROM.commit();
    gostep(-1000);
  }
}


void gostep (int stepper)
{
  myStepper.step(stepper);
}

Dobro veče i tebi i dobrodošao na forum.

WDT reset je vezan gotovo isključivo za greške u kodu, a da bi do tih grešaka mogli da dođemo, opet moraš da nam daš dovoljno podataka: info o platformi koja se koristi, za početak, i propisno formatiran kod mogli bi dosta da pomognu i tebi, i nama. Uz obaveznu upotrebu engleskog, naravno, kako bi svi mogli da shvatimo o čemu se radi.

Hope that helps a lot!

Platform - Wemos D1 mini
On this Board, stepper motor works fine. But as soon as I connect to Blynk, Blynk hangs. Hangs at the very moment of engine operation

Is there something else in void loop except Blynk.run and/or timers? What do you see in Serial monitor when Wemos hangs? Pls paste whole code, it would be much easier.

#define BLYNK_PRINT Serial
#include <EEPROM.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Stepper.h>


const int stepsPerRevolution = 64;  //кол-во шагов на оборот
Stepper myStepper(stepsPerRevolution, 14, 12, 13, 15);

char auth[] = "";
char ssid[] = "";
char pass[] = "";

int oldposition; // Поледнее положение: 1 - открыто; 0 - закрыто; BUILTIN горит при закрытом положении.


void setup()
{
  
  Serial.begin(9600);
  Serial.println("Start...");
  pinMode(BUILTIN_LED, OUTPUT);
  digitalWrite(BUILTIN_LED, HIGH);
  EEPROM.begin(4);
  oldposition = int(EEPROM.read(0));  // Читаем значение из памяти о последнем положении
  Blynk.begin(auth, ssid, pass);
  myStepper.setSpeed(300);
}

void loop()
{
  Blynk.run();

}


BLYNK_CONNECTED() {
  //Blynk.syncAll();
}

BLYNK_WRITE(V0)   // Кнопка
{
  if (param.asInt() == 1 && oldposition == 0) // Проверяе закрывать если было открыто
  {
    oldposition = param.asInt();
    EEPROM.write(0, oldposition); // Записываем в память последнее положение
    EEPROM.commit();

    gostep(1000);
  }

  if (param.asInt() == 0 && oldposition == 1) // Проверяем открывать если было закрыто
  {
    oldposition = param.asInt();
    EEPROM.write(0, oldposition); // Записываем в память последнее положение
    EEPROM.commit();
    gostep(-1000);
  }
}

// ************************* //

BLYNK_WRITE(V10)  // Таймер
{
  digitalWrite(BUILTIN_LED, !digitalRead(BUILTIN_LED));

  if (param.asInt() == 1 && oldposition == 0) // Проверяе закрывать если было открыто
  {
    oldposition = param.asInt();
    EEPROM.write(0, oldposition); // Записываем в память последнее положение
    EEPROM.commit();
    gostep(1000);
  }

  if (param.asInt() == 0 && oldposition == 1) // Проверяем открывать если было закрыто
  {
    oldposition = param.asInt();
    EEPROM.write(0, oldposition); // Записываем в память последнее положение
    EEPROM.commit();
    gostep(-1000);
  }

}

void gostep (int stepper)
{

  Serial.print("Steeper go - ");
  Serial.println(stepper);
  myStepper.step(stepper);
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  digitalWrite(8, LOW);
}

Ok ? Found quotes :wink:

3 Likes

@atas80 Please format your code in your last post… I already did your first one, your turn now :wink:

Blynk - FTFC

I don’t know how to do it on a MAC

[257] Connecting to ZyXEL_KEENETIC_GIGA_
[4760] Connected to WiFi
[4760] IP: 192.168.2.44
[4760] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.10 on Arduino

[5001] Connecting to blynk-cloud.com:8442
[5277] Ready (ping: 0ms).
Steeper go - -1000

Soft WDT reset

ctx: cont 
sp: 3ffefc90 end: 3ffeffd0 offset: 01b0

>>>stack>>>
3ffefe40:  0000000a 3ffeecc4 3ffeeee0 40204634  
3ffefe50:  3ffeecc4 0000012d 3ffeecc8 4020430b  
3ffefe60:  3ffeecc4 3ffeeee0 fffffc18 4020231c  
3ffefe70:  402231fe 00000000 3ffeed44 402023d1  
3ffefe80:  3ffeecf4 3ffeff16 00000000 40202ac4  
3ffefe90:  00000000 00000000 00000001 00000006  
3ffefea0:  3ffeff15 00000001 00000001 40203c15  
3ffefeb0:  3ffefe00 3ffeed2c 00000030 3ffeff15  
3ffefec0:  3fff7776 3ffeed2c 3ffeefb0 3ffeff10  
3ffefed0:  00000006 3ffeff10 40204afc 3ffeefb0  
3ffefee0:  00000000 3ffeff10 00000000 3ffeff10  
3ffefef0:  00000000 3ffeff10 3ffeecf4 40202e3c  
3ffeff00:  00000000 00000005 3ffeecf4 40202b9c  
3ffeff10:  30007776 3f003000 3ffeef9c 00000030  
3ffeff20:  39323763 00000039 3ffeefb0 06248f14  
3ffeff30:  00000000 3ffeef9c 3ffeefb0 3ffeed18  
3ffeff40:  00000006 00000001 40204afc 3ffeefb0  
3ffeff50:  3ffefb50 3ffeed18 00000000 00000001  
3ffeff60:  00000000 3ffeed18 3ffeecf4 40203092  
3ffeff70:  00000000 3ffeeee0 3ffeeee0 3ffeef9c  
3ffeff80:  00000000 3ffeea80 3ffeea80 40202752  
3ffeff90:  3ffe834c 3ffeed44 3ffeef94 3ffeef9c  
3ffeffa0:  3fffdad0 00000000 3ffeef94 402031cb  
3ffeffb0:  3fffdad0 00000000 3ffeef94 40204b48  
3ffeffc0:  feefeffe feefeffe 3ffeefb0 40100718  
<<<stack<<<

@atas80 why did you buy a MAC? Perhaps ask a friend with a PC to format your code.

1 Like

It has nothing to do with your type of PC… you edit your post above…



And add in the required characters at the beginning and end of your copy/pasted code

hack the Stepper.h library to add:

delay(0);

or

yield();

Blynk - FTFC

This is actually an image of mac keyboard. Just look closely.

In file included from /Users/dima/Documents/Arduino/Blinds_28BYJ_Blynk/Blinds_28BYJ_Blynk.ino:5:0:
/Applications/Arduino.app/Contents/Java/libraries/Stepper/src/Stepper.h:122:6: error: expected constructor, destructor, or type conversion before '(' token
 delay(0);
      ^
exit status 1
Ошибка компиляции для платы WeMos D1 R2 & mini.

Where exactly write delay (0) Stepper. h?

in the cpp file:

  while (steps_left > 0)
  {
    delay(0);
    unsigned long now = micros();
1 Like

Unknown

Everything works as it should!

1 Like

On another note…
You will burn through your eeprom the way you use it :stuck_out_tongue:
It has limited writes. I suggest you try to sync a virtual pin with your “oldposition” instead, and if you are not connected to Blynk then and only then use eeprom instead :stuck_out_tongue:.
Reads from eeprom don’t burn the memory.

if (Blynk.connected()) 
  Blynk.virtualWrite(save_vPin, oldposition);
else
{
    EEPROM.write(0, oldposition);
    EEPROM.commit();
} 

You need to work out quirks like which space was saved last as to know which to use of course.
But see this as a hint in a direction :stuck_out_tongue_winking_eye:

Got you. Thanks for the hint. In the past, project and working EEPROM. Has been working for a year!

A number that pops up is 100,000 write-cycles, whilst that may seem so far away from your code right now,
if you continue that path you might just want to… save a little more… save a little more often … and then… one hot summer day KABOOM! And your device is toast, or atleast its memory :stuck_out_tongue_winking_eye:

So while you are not in any super danger right now I thought I’d just enlighten you ! :slight_smile:

Also for strictly saving values to virtual pins I suggest using those at the far end, if not defined for more then, those at V34-35.
The moment you add widgets that use a virtual pin the save value is nulled, so for storing data best use pins that will not have widgets assigned to them!