WEMOS D1mini + 12 V Stepper Motor



  • Hey!
    I want to receive data on wemos and control the stepper motor (12V, 200x)
    With the help of the motor shield for wemos d1 mini and an external power supply for ma 12 V stepper motor, is it possible to control the motor or not?

    I have also a motorshield for arduino where I can control the stepper motor but the arduino hasn't got wifi of course. Is there a way to have arduino + wemos + motorshield (which is eventually plugged onto the arduino...) connected together?

    thanks and sorry for newbie questions.



  • The wemos motor shield is not programmed to handle stepper motors -- getting it to work with them would be a considerable effort in rewriting their firmware, so I think this option is out of the question for now.

    You can use the arduino motor shield together with the wemos d1 mini, by connecting the correct pins with wires. You don't need the Arduino board for that.



  • @deshipu hmmm...
    Wemos Motor Shield work with stepper motor - https://youtu.be/LwPcnVkebW4



  • @megazaic Interesting, do you have a link to the code being used there?



  • @deshipu On the forum that went into oblivion, someone also said "motor shield can not work with stepper motors".
    To which i replied that with the current firmware, i can control the stepper motor. and for half an hour there was a code

    #include <Wire.h>
    
    #define M_A 0
    #define M_B 1
    #define SHORT_BRAKE 0
    #define CCW  1
    #define CW   2
    #define STOP 3
    #define STANDBY 4
    uint8_t address;
    bool use_STBY_IO = false;
    uint8_t STBY_IO;
    
    
    void sf(uint32_t freq)
    {
      Wire.beginTransmission(address);
      Wire.write(((byte)(freq >> 16)) & (byte)0x0f);
      Wire.write((byte)(freq >> 16));
      Wire.write((byte)(freq >> 8));
      Wire.write((byte)freq);
      Wire.endTransmission();     // stop transmitting
      delay(100);
    }
    
    void sm(uint8_t motor, uint8_t dir, float pwm_val)
    {
      uint16_t _pwm_val;
      Wire.beginTransmission(address);
      Wire.write(motor | (byte)0x10);
      Wire.write(dir);
      _pwm_val = uint16_t(pwm_val * 100);
      if (_pwm_val > 10000) _pwm_val = 10000;
      Wire.write((byte)(_pwm_val >> 8));
      Wire.write((byte)_pwm_val);
      Wire.endTransmission();     // stop transmitting
    }
    
    void setup() {
      Serial.begin(115200);
      Serial.print("\nSerialBegin");
      Wire.begin();
      Serial.print("\nWireBegin");
      address = 0x30;
      sf(8000); // set freq
      Serial.print("\nSetFreq1000");
      sm(M_A, STOP, 0); sm(M_B, STOP, 0);
    }
    int del = 2;
    int pwm = 100;
    void loop() {
      delay(2000); Serial.print("\nOpen ");
      for (int i = 0; i < 200; i++) {
        sm(M_A, CW, pwm); sm(M_B, STOP, pwm); delay(del);
        sm(M_B, CW, pwm); sm(M_A, STOP, pwm); delay(del);
        sm(M_A, CCW, pwm); sm(M_B, STOP, pwm); delay(del);
        sm(M_B, CCW, pwm); sm(M_A, STOP, pwm); delay(del);
      }
      sm(M_A, STOP, 0); sm(M_B, STOP, 0); Serial.print("Stop");
      delay(2000); Serial.print("\nClose ");
      for (int i = 0; i < 200; i++) {
        sm(M_A, CW, pwm); sm(M_B, STOP, pwm); delay(del);
        sm(M_B, CCW, pwm); sm(M_A, STOP, pwm); delay(del);
        sm(M_A, CCW, pwm); sm(M_B, STOP, pwm); delay(del);
        sm(M_B, CW, pwm); sm(M_A, STOP, pwm); delay(del);
      }
      sm(M_A, STOP, 0); sm(M_B, STOP, 0); Serial.print("Stop");
    }
    
    

    Now that we have the source code, we can embed this function into shield controller.



  • @megazaic This is an interesting hack for sure, but what I would expect from this shield is to delegate all this looping to the microcontroller on the shield, instead of doing it on the esp8266 -- this is certainly possible with this hardware, all you need is a firmware that would support it.



  • @deshipu if all of a sudden i want to drive the stepper motor, i just will not use this motor shield.
    i will take stepper driver from 3D printer.


Log in to reply
 

Looks like your connection to WEMOS Forum was lost, please wait while we try to reconnect.