LoLin NodeMcu v3 and DRV8825

Last week I bricked a4988, so ordered DRV8825 this time.

Goal: To spin the Nema 17 using Wifi

I used the article

The only changes - supplying 5v into Vin and usage of D3, D4 instead of D1 and D2 for step and direction.

12V with 2.5A is the power source for DRV8825. and using a buck boost converter to get 5V to supply for NodeMcu, reset, sleep.

Ground from mains is supplied to buck boost and ground pin of DRV is connected to NodeMcu too.

[ 100microF capacitor is used at VMOT]

using board - NodeMcu 1.0 [ESP 12E Module]

Problems: Motor not spinning, I occasionally herd small sound from Nema 17, and also the heat sik on DEV is damn hot.

Please can you tell me what could be the problem? and how to spin my Nema 17 stepper

Code:

#include <ESP8266WiFi.h>        //I can connect to a Wifi
#include <ESP8266WebServer.h>   //I can be a server 'cos I have the class ESP8266WebServer available
#include <WiFiClient.h>

const char* ssid =
const char* password =
ESP8266WebServer server(80);    //Global object variable from the class ESP8266WebServer so we will be able to access it in our functions
//As argument for the constructor of this class, we will pass the port where the server will be listening to.
//Since 80 is the default port for HTTP, we will use this value, so we will not need to specify it in the URL
//when accessing to our ESP8266 server using a browser.


#define DIR_PIN    D3
#define STEP_PIN    D4
//const int dirPin = 5; //This pin corresponds to GPIO5 (D1) (Yellow wire) https://nodemcu.readthedocs.io/en/latest/en/modules/gpio/
//const int stepPin = 4; //This pin corresponds to GPIO4 (D2) (Orange wire)
int steps = 0; //This variable is related to the number of turns. If microstepping is disabled, 200 corresponds to a complete turn.
int stepDelay = 0; //This variable is the pulse duration in milliseconds and it is related to the rotation speed. Without microstepping, 1.8ยบ are stepDelay ms.
bool dir = HIGH; //Rotation direction. HIGH is clockwise.


void setup() {
  pinMode(DIR_PIN, OUTPUT);  // Pins are outputs
  pinMode(STEP_PIN, OUTPUT);

  delay(1000);
  Serial.begin(115200);           //I can debbug through the serial port

  // Configure NODEMCU as Access Point
  Serial.println("Configuring access point...");
  WiFi.softAP(ssid); //Password is not necessary
  IPAddress myIP = WiFi.softAPIP(); //Get the IP assigned to itself.
  Serial.print("AP IP address: "); //This is written in the PC console.
  Serial.println(myIP);

  server.on("/", handleRootPath); //I specify which code to execute when an HTTP request is performed to each path.
  //To do so, we call the on method on our previously declared server global object.
  //The most elegant method consists on defining a handling function somewhere in our code and passing it to the
  //on function alongside the URL that will trigger the execution of that function.
  //This line indicates that when an HTTP request is received on the root ("/") path,
  //it will trigger the execution of the handleRootPath function

  server.on("/Init", handleInit);   //Associate the handler function to the path "/Init".

  server.begin();                 //Let's call the begin method on the server object to start the server.
  Serial.println("HTTP server started");
}

void loop() {
  server.handleClient();          //To handle the actual incoming of HTTP requests, we need to call the handleClient method on the server object, on the main loop function.
}

void handleRootPath() {
  server.send(200, "text/plain", "Ready, NodeMcu.");
  //To define an answer to a request, I call the send method on the server object.
  //Although the method can be called with a different set of arguments, its simplest form consists on receiving
  //the HTTP response code (200 = OK), the content type and the content.
}

void handleInit() {// Handler. 192.168.XXX.XXX/c (One turn clockwise in one second)
  //Check this https://github.com/esp8266/Arduino/blob/4897e0006b5b0123a2fa31f67b14a3fff65ce561/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp#L365

  steps = 0;  //Motor stopped if the arguments are wrong.
  stepDelay = 0;
  String message = "Initialization with: ";

  if (server.hasArg("Dir")) {
    digitalWrite(DIR_PIN, server.arg("Dir") == "HIGH"); //This is a cunning way of checking the value of the argument Dir.
    message += "Direction: ";
    message += server.arg("Dir");
  }
  if (server.hasArg("Delay")) {
    stepDelay = (server.arg("Delay")).toInt(); //Converts the string to integer.
    message += " Delay: ";
    message += server.arg("Delay");
  }
  if (server.hasArg("Steps")) {
    steps = (server.arg("Steps")).toInt();
    message += " Steps: ";
    message += server.arg("Steps");
  }
  server.send(200, "text/plain", message); //It's better to return something so the browser don't get frustrated+ 
  
  for (int i = 0; i < steps; i++) { //Create a square wave signal with the incoming data.
    digitalWrite(STEP_PIN, HIGH);
    
    delayMicroseconds(stepDelay);
    yield();
    digitalWrite(STEP_PIN, LOW);
    delayMicroseconds(stepDelay);
    server.send(200, "text/plain", "count: "+i);
  }
   
}

One potential source of problems is the 3.3V signals of the NodeMCU vs. the 5V logic you probably use on the DRV8825. But as you forgot to add the necessary details it's a bit of guesswork.

wvmarle: One potential source of problems is the 3.3V signals of the NodeMCU vs. the 5V logic you probably use on the DRV8825. But as you forgot to add the necessary details it's a bit of guesswork.

Not sure I understand your answer? 3.3v signal vs 5v logic? and what necessary details are missing?

I will try to describe again:

12v 2.5 A power source supplied to DEV8825 [ attached 100mF capacitor]

As usual 4 motor pins

Dir, Step attached to 2 pins on NodeMcu [ I hope you can accept D2, D3 etc]

I attached a buck boost converter to take the 12V supply and convert it to 5V. I am feeding this to VIN of NodeMcu, and SLEEP, RESET pins of DRV8825.

Second Ground pin of DRV8825 [ not the one next to VMOT], is connected to NodeMcu GND pin next to VIN

Sketch is simple as in the link.

Usage - http://192.168.XXX.XXX/Init?Dir=HIGH&Delay=5&Steps=200

or http://192.168.XXX.XXX/Init?Dir=LOW&Delay=5&Steps=200

from a browser

There is no code tag to paste in reply.

krisferrari: Not sure I understand your answer? 3.3v signal vs 5v logic? and what necessary details are missing?

How about a schematic. A complete schematic of YOUR setup.

And I doubt you're using 100 mF capacitance. You probably mean 100 uF (= 0.1 mF).

I will look for some software that can help me create schematic. But in the mean time, please see attached

The link - http://electrica.uc3m.es/grobles/blog/?p=1384 has the diagream too section - Driver DRV8825

The capacitor shows 100μF

can I get some inputs?

I for one am still waiting for your schematic. See that it is correct for starters.

please see, if the attached is sufficient…or i will draw again!
[Note: the GND pin of DRV8825 is connected to GND of NodeMcu. The line/connection is invisible in pic]

so looks like not enough..problem with people who know

Nothing obviously wrong with the schematic or the layout itself.

Stepper driver broken maybe?

I'm not sure , if the problem is the buck boost converter. It creates 5V and 3Amps. Is this too much?

IPaddress/Init?Dir=HIGH&Delay=5&Steps=200 is turning the motor by 10 degrees? instead of 1 full rotation. Heat sink is burning hot [ not broken yet]

krisferrari: I'm not sure , if the problem is the buck boost converter. It creates 5V and 3Amps. Is this too much?

5V sounds good for an Arduino. 3A means you have ample supply available

I do assume you run the stepper at 12V.

wvmarle: 5V sounds good for an Arduino. 3A means you have ample supply available

I do assume you run the stepper at 12V.

Correct. VMOT is 12v [ 2.5amps] , but SLP and RST are supplied 5V 3A from buck boost

They're supplied 5V.

Those two pins take probably a few nA (the datasheet will give a more specific number).

wvmarle: They're supplied 5V.

Those two pins take probably a few nA (the datasheet will give a more specific number).

I agree that they may just need nA's, but my buck boost is telling me that it gives 5V and 3A. I am planning to use 1 power shource - 12v 2.5A, and use buck boost, to pull 5V from the same source.

Is this ok? Are there any converters that can supply less amps ?

You still don't get it.

The converter supplies only as many amps as is needed, up to the maximum available (and that's the 3A).

Just look at your house wiring. Mine has 64A fuses and a lot more than that available, but those 9W LED lights don't draw anything near that current. Why would a 5V supply behave any different?

I have sorted my issue. Bought a new a4988 and played with it , and it started working. Similar to the one in the image, but additionally supplying 5v to vin [ may have used different pins for step and direction, but not much different]

|500x387