Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By jrance
#71848 Hello,

First of all I wanted to say "hi!" as this is my first post here ;)

I've spend the entire day a trying to drive a NEMA 17 stepper motor with a NodeMCU board via an L298N driver.

When using an Arduino UNO board, the motor works perfectly, however when I try to run the same code on a NodeMCU board, it causes a hw wdt reset :(
ets Jan 8 2013,rst cause:4, boot mode:(3,6)

I've been looking in Google for a solution but no luck so far, I wasn't able to find anyone driving a NEMA 17 with a L298N driver with the Stepper.h library.

Has anyone here been able to drive such a motor with the same driver and library? I would really appreciate any kind of help.

Setup:
  • A Coil: D1 + D2
  • B Coil: D3 + D4
  • A PWM: D5
  • B PWM: D6
User avatar
By tele_player
#71849 A common cause for WDT reset is a loop which runs too long. No problem on Arduino, but won’t work on esp8266. If I recall correctly, doing anything for 50ms or more, without a call to yield() or delay(), will cause WDT reset.


Without knowing what code you’re running, it cannot be determined whether the trouble is in the sketch, or the library.
User avatar
By jrance
#71897 I was so frustrated I did not try to get it working again until now and... IT WORKS! :mrgreen:

Find below the code I used for the test:

Code: Select all#include <Stepper.h>

const int stepsPerRevolution = 200; 
Stepper myStepper(stepsPerRevolution, D1,D2,D3,D4); 

int enA = D5;
int enB = D6;

void setup() {
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  // establece la velocidad en 60rpm
  myStepper.setSpeed(60);
  // inicializa el puerto serial
  Serial.begin(9600);
}

void loop() {
  analogWrite(enA, 700);
  analogWrite(enB, 700);
 
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);
 
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500);
  analogWrite(enA, 0);
  analogWrite(enB, 0);
  delay(9000);
}


Thank you for your help anyway!!! ;)