Stepper Motor

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
theju
New user
Posts: 4
Joined: 29 May 2016, 10:14

Stepper Motor

#1 Post by theju » 29 Nov 2016, 14:15

Is it possible to include control off a stepper motor ?

In earlier version, I use this in P001_switch :

Code: Select all

        if (command == F("stepper"))
        // Par1 = GPIO; Par2 = count ;Par3 = delay
        
        {
          success = true;
          if (event->Par1 >= 0 && event->Par1 <= 16)
          {
            int i = 0;
            for( i=1; i<event->Par2; i++){
              pinMode(event->Par1, OUTPUT);
              digitalWrite(event->Par1, 1);
              delay(event->Par3);
              digitalWrite(event->Par1, 0);
              delay(event->Par3);
            }
            
            setPinState(PLUGIN_ID_001, event->Par1, PIN_MODE_OUTPUT, 0);
            log = String(F("SW   : STEP ")) + String(event->Par2);
            addLog(LOG_LEVEL_INFO, log);
            SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_001, event->Par1, log, 0));
          }
        }
If somebody better than me in prog can include something like this (maybe add direction ?) it would be very appreciate !

Thanks
Theju

majklovec
Normal user
Posts: 10
Joined: 12 Jul 2016, 07:47

Re: Stepper Motor

#2 Post by majklovec » 06 Dec 2016, 03:09

Code: Select all


#include <Arduino.h>

//#######################################################################################################
//############################# Plugin 106: Stepper <info@sensorio.cz####################################
//#######################################################################################################
#define PLUGIN_106
#define PLUGIN_ID_106        106
#define PLUGIN_NAME_106       "Aktuátory: Krokový motor"
#define PLUGIN_VALUENAME1_106 ""

#include <AccelStepper.h>
int max_stepper_speed = 1000000;
int stepper_speed = 40000;

int stepper_accel = 15000;
int timelapse_mins = 60;
long init_pos = 0;
long current_pos = 0;
long steps = 2000;
int sleepTime = 10; // sec
bool accel_enabled = true;
bool isStop = false;
int enable_pin = 12;
long actualTime;

AccelStepper *stepper;

boolean Plugin_106(byte function, struct EventStruct *event, String& string)
{
  boolean success = false;

  switch (function)
  {

    case PLUGIN_DEVICE_ADD:
      {
        Device[++deviceCount].Number = PLUGIN_ID_106;

        Device[deviceCount].Type = DEVICE_TYPE_TRIPLE;
        Device[deviceCount].VType = SENSOR_TYPE_LONG;
        Device[deviceCount].Ports = 0;
        Device[deviceCount].PullUpOption = false;
        Device[deviceCount].InverseLogicOption = false;
        Device[deviceCount].FormulaOption = false;
        Device[deviceCount].ValueCount = 1;
        Device[deviceCount].SendDataOption = true;
        Device[deviceCount].TimerOption = false;
        Device[deviceCount].GlobalSyncOption = true;

        break;
      }

    case PLUGIN_GET_DEVICENAME:
      {
        string = F(PLUGIN_NAME_106);
        break;
      }

    case PLUGIN_GET_DEVICEVALUENAMES:
      {
        strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_106));
        break;
      }
    case PLUGIN_WEBFORM_LOAD:
      {
        char tmpString[128];
        sprintf_P(tmpString, PSTR("<TR><TD>not ENABLE:<TD><input type='text' name='taskdevicepin1' value='%u'>"), Settings.TaskDevicePin1[event->TaskIndex]);
        string += tmpString;
        sprintf_P(tmpString, PSTR("<TR><TD>STEP:<TD><input type='text' name='taskdevicepin2' value='%u'>"), Settings.TaskDevicePin2[event->TaskIndex]);
        string += tmpString;
        sprintf_P(tmpString, PSTR("<TR><TD>DIR:<TD><input type='text' name='taskdevicepin3' value='%u'>"), Settings.TaskDevicePin3[event->TaskIndex]);
        string += tmpString;
        success = true;
        break;
      }

    case PLUGIN_TEN_PER_SECOND:
      {

        if (stepper) {
          if (isStop) {
            stepper->stop();
            //Serial.println("stopped");
          }
          else if (!isStop && stepper->distanceToGo() != 0) {
            //Serial.println("running");
            if (!accel_enabled)
              stepper->runSpeed();
            else if (accel_enabled)
              stepper->run();

            actualTime = millis();

            UserVar[event->BaseVarIndex] = stepper->currentPosition();
          }
        }

        if (millis() - actualTime > sleepTime * 1000) {
          disableStepper();
        }


        success = true;
        break;
      }

    case PLUGIN_INIT:
      {
        LoadTaskSettings(event->TaskIndex);

        Serial.print("pin1: ");
        Serial.print(Settings.TaskDevicePin1[event->TaskIndex]);
        Serial.print(", pin2: ");
        Serial.println(Settings.TaskDevicePin2[event->TaskIndex]);
        Serial.print(", pin3: ");
        Serial.println(Settings.TaskDevicePin3[event->TaskIndex]);

        enable_pin = Settings.TaskDevicePin1[event->TaskIndex];

        if (Settings.TaskDevicePin3[event->TaskIndex] && Settings.TaskDevicePin2[event->TaskIndex]) {
          stepper = new AccelStepper(1, Settings.TaskDevicePin2[event->TaskIndex], Settings.TaskDevicePin3[event->TaskIndex]);
          stepper->setMaxSpeed(max_stepper_speed);
          stepper->setSpeed(stepper_speed);
          stepper->setAcceleration(stepper_accel);
          stepper->setCurrentPosition(stepper->currentPosition ());
          Serial.println("current_position");
          Serial.println(stepper->currentPosition());
          success = true;
        }
        break;
      }
    case PLUGIN_WRITE:
      {
        String command  = string;
        int value = -1;

        int argIndex = command.indexOf(',');
        if (argIndex) {
          command = command.substring(0, argIndex);

          processGetRequest(command, event->Par1);
        }

        success = true;
        break;
      }

    case PLUGIN_READ:
      {
        success = true;
        break;
      }

  }
  return success;
}

void moveSlider(String direction) {
  enableStepper();
  isStop = false;
  if (direction.equals("left")) {
    Serial.println("moving left");
    //stepper->setSpeed(speed);
    stepper->setSpeed(-stepper_speed);
    stepper->move(-steps);
  }
  else if (direction.equals("right")) {
    long start_pos = stepper->currentPosition();
    Serial.println("moving right");
    stepper->setSpeed(stepper_speed);
    stepper->move(steps);
  }

  else if (direction.equals("reset")) {
    Serial.println("reset to 0");
    stepper->setSpeed(-stepper_speed);
    stepper->move(-stepper->currentPosition());
  }
}
void changeSpeed(float mot_speed) {
  stepper_speed = mot_speed;
  stepper->setAcceleration(mot_speed / 4);
  Serial.println(stepper_speed);
}

void timelapse(String direction) {
  float timelapse_speed =  36.0f / (timelapse_mins / 60.0f);
  Serial.println(timelapse_speed);
  if (timelapse_speed > max_stepper_speed)
    timelapse_speed = max_stepper_speed;

  isStop = false;
  enableStepper();
  if (direction.equals("left")) {
    stepper->setSpeed(timelapse_speed);
    stepper->move(steps);
  }

  else if (direction.equals("right")) {
    stepper->setSpeed(-timelapse_speed);
    stepper->move(-steps);
  }
}
void processGetRequest(String name, int value) {
  Serial.println(name);
  if (name.equals("left")) {
    moveSlider("left");
  }
  else if (name.equals("right")) {
    moveSlider("right");
  }
  else if (name.equals("speed"))
    changeSpeed(value);

  else if (name.equals("stop")) {
    Serial.println("stopping");
    isStop = true;
  }
  else if (name.equals("reset_pos")) {
    moveSlider("reset");
    isStop = false;
  }

  else if (name.equals("steps")) {
    steps = value;
  }
  else if (name.equals("recalibrate")) {
    stepper->setCurrentPosition(0);
    Serial.println(stepper->currentPosition());
  }
  else if (name.equals("timelapse_right")) {
    timelapse("right");
  }
  else if (name.equals("timelapse_left")) {
    timelapse("left");
  }
  else if (name.equals("mins")) {
    timelapse_mins = value;
  }

  else if (name.equals("accel_enabled")) {
    accel_enabled = value;
  }

  else if (name.equals("set_accel")) {
    stepper->setAcceleration(value);
  }
}

void disableStepper() {
  digitalWrite(enable_pin, 1);
}

void enableStepper() {
  digitalWrite(enable_pin, 0);
}


Last edited by majklovec on 12 Dec 2016, 06:39, edited 1 time in total.

theju
New user
Posts: 4
Joined: 29 May 2016, 10:14

Re: Stepper Motor

#3 Post by theju » 06 Dec 2016, 09:11

Hi majklovec,

Thank you for your answer

Unfortunately, I'm not able to compile your plugin. Maybe a definition missing in the main file ?

Code: Select all

ESPEasy/_P106_Stepper.ino: In function 'boolean Plugin_106(byte, EventStruct*, String&)':
_P106_Stepper:40: error: 'DEVICE_TYPE_TRIPLE' was not declared in this scope
         Device[deviceCount].Type = DEVICE_TYPE_TRIPLE;
                                    ^
_P106_Stepper:78: error: 'PLUGIN_BACKGROUND' was not declared in this scope
     case PLUGIN_BACKGROUND:
          ^
exit status 1
'DEVICE_TYPE_TRIPLE' was not declared in this scope
Regards,
Theju

timsson
Normal user
Posts: 77
Joined: 25 Mar 2016, 22:00

Re: Stepper Motor

#4 Post by timsson » 06 Dec 2016, 10:45

+1

majklovec
Normal user
Posts: 10
Joined: 12 Jul 2016, 07:47

Re: Stepper Motor

#5 Post by majklovec » 07 Dec 2016, 02:41

Yes, add

to espeasy.ino

Code: Select all

#define DEVICE_TYPE_TRIPLE 5
And to webserver.ino to function;

Code: Select all

void handle_devices() 
after

Code: Select all

      if (Device[DeviceIndex].Type == DEVICE_TYPE_DUAL)
      {
        Settings.TaskDevicePin1[index - 1] = taskdevicepin1.toInt();
        Settings.TaskDevicePin2[index - 1] = taskdevicepin2.toInt();
      }
ADD THIS:

Code: Select all

      if (Device[DeviceIndex].Type == DEVICE_TYPE_TRIPLE)
      {
        Settings.TaskDevicePin1[index - 1] = taskdevicepin1.toInt();
        Settings.TaskDevicePin2[index - 1] = taskdevicepin2.toInt();
        Settings.TaskDevicePin3[index - 1] = taskdevicepin3.toInt();
      }

theju
New user
Posts: 4
Joined: 29 May 2016, 10:14

Re: Stepper Motor

#6 Post by theju » 07 Dec 2016, 08:46

Thank you for your response.

I need to add

Code: Select all

#define PLUGIN_BACKGROUND                  20
in ESPEasy.ino and now compilation is correct.

I will try ASAP tu use it.

Regards,
Theju

majklovec
Normal user
Posts: 10
Joined: 12 Jul 2016, 07:47

Re: Stepper Motor

#7 Post by majklovec » 12 Dec 2016, 06:39

I believe that changing PLUGIN_BACKGROUND to PLUGIN_TEN_PER_SECOND in the source (in the case section) will do the job.

Just to get sure you need to have some stepper driver A4988, DRV8825 ... often used in RepRap 3D printers and connect "not ENable", STEP and DIR to the selected pins.

Image

DIYEd
New user
Posts: 1
Joined: 04 Jan 2017, 09:58

Re: Stepper Motor

#8 Post by DIYEd » 04 Jan 2017, 10:03

Compile did work without any errors. But what HTTP requets to send to control this steppermotor?

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Stepper Motor

#9 Post by Domosapiens » 29 Mar 2017, 00:45

YES!!
My baby makes its first steps!

DIYEd,
did you find HTTP request capabilities ?
Can you please share?

What I find out by code reading, are the following terminal commands:

Code: Select all

Adjustments:

accel_enabled,<boolean>		(0,1)
speed,<value> 			(call to changeSpeed, adjust speed to value, sets acceleration to <value>/4)
set_accel,<value> 		(overwritten by speed. so order is important)
recalibrate			(set the current position as 0 position)
steps,<value>			(prepare the number of steps)
mins,<value> 			(prepare timelaps rotation in minutes)

Execution:

left    			(call to moveSlider left, go, with -stepper_speed and #steps)
right  				(call to moveSlider right, with stepper_speed and #steps)
stop 				(break current operation?)
reset_pos 			(call to moveSlider reset: go to 0 position with  –stepper_speed)
timelapse_right	 		(timelaps rotation in #mins for #steps)
timelapse_left 			(timelaps rotation in #mins for #steps)
@majklovec,
can you shine your light?
Last edited by Domosapiens on 30 Mar 2017, 00:49, edited 1 time in total.
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Stepper Motor

#10 Post by Domosapiens » 29 Mar 2017, 23:20

HTTP request capabilities?
I checked a few ..and found:
http://<your_IP>/control?cmd=stop
http://<your_IP>/control?cmd=speed,<value>
http://<your_IP>/control?cmd=left
are working!

So no Device/Task name is involved.

That brings me to the question:
How to control 2 stepper motors?

Any help?
Domosapiens
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

neykov_t
Normal user
Posts: 15
Joined: 21 Jan 2017, 22:10

Re: Stepper Motor

#11 Post by neykov_t » 26 May 2017, 16:26

Hi friends,
can you share please compiled plugin ? Thank you

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Stepper Motor

#12 Post by Domosapiens » 28 May 2017, 11:57

@Neykov_t

My current Lab version including a 4M binary,

https://we.tl/OtR1GnKOWd
(avail for 7 days)

Based on majklovec's _P106, I have created my local versions named _P107 and _P108.
- based on ESPEasy_v2.0.0-dev7, 4M version
- based on _P106, timelaps functions removed
- Controls 2 steppers: Ostep and Cstep (for Open and Close)
- Running 50x per second, non blocking for other Tasks
- Ostep and Cstep exclude each other (one disables the other)
- Instantiate Task: Ostep or Cstep or both
- Replace the strange values (why are they there??) by your GPIO numbers
- Safe GPIO's are 14,12,13,8,4,5
- Fill-in an IDX number
- Commands called by <IP>/command?cmd=<Cstep/Ostep>,<command>,<value>
Example:
http://<IP>/control?cmd=Ostep,speed,30
http://<IP>/control?cmd=Cstep,left

I used my programmers experience of 35 year ago.
Elegant code? Not at all!
Proof of correctness? No. (Is this still learned at university?)
Marginally tested, but it works.
Support? No support.
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

hoods
New user
Posts: 3
Joined: 27 Feb 2018, 21:53

Re: Stepper Motor

#13 Post by hoods » 27 Feb 2018, 22:02

@Domosapiens, any chance to share your custom plugin (again).
I would like to control a single stepper using a DRV8825.

I've tried to build the plugin my own based on the proposed modification mentioned by majklovec but with the recent sources of ESPEasy compile fails.

Thanks in advance, hoods

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Stepper Motor

#14 Post by Domosapiens » 27 Feb 2018, 22:19

Here you go:
https://we.tl/sndfkRec0q
(avail for 7 days)
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

mstjerna
Normal user
Posts: 10
Joined: 17 Jan 2018, 16:43

Re: Stepper Motor

#15 Post by mstjerna » 12 Mar 2018, 21:48

The link is expiered. Could you please share it again :roll:
Thanks

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Stepper Motor

#16 Post by Domosapiens » 12 Mar 2018, 22:02

https://we.tl/vjC6hhH6tL
7days means ... 7days :)
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

mstjerna
Normal user
Posts: 10
Joined: 17 Jan 2018, 16:43

Re: Stepper Motor

#17 Post by mstjerna » 13 Mar 2018, 10:49

Many thanks!
Just a question, why not make it an "official plugin" on the playground so everyone just can cherry-pick it to their build?
I didn't find it on the playground area...
https://github.com/letscontrolit/ESPEas ... Playground

mstjerna
Normal user
Posts: 10
Joined: 17 Jan 2018, 16:43

Re: Stepper Motor

#18 Post by mstjerna » 14 Mar 2018, 14:31

Hi

I looked at your code and successfully uploaded the pre-compiled version.

There are some cheep motors from China for $1
http://robocraft.ru/files/datasheet/28BYJ-48.pdf

These are 4-phase unipolar and running directly on 4 GPIO with a simple ULN2003 driver between.
I see that you use the library: AccelStepper.h in your code.
I found a modified version of this including my motor so I was thinking of modifying your plugin with this custom build of the AccelStepper.
https://forum.arduino.cc/index.php?topic=194671.0

One question I have thou, when you have your motor running on the ESP, is it blocking all other functions while running? Can you stop the motor while running?

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Stepper Motor

#19 Post by Domosapiens » 14 Mar 2018, 18:19

The while loop code contains yield();
So I think it is non-blocking.
Stop? ... just give it a try ;)

My coding skills are more than 40 years old,
so I hardly understood what I have modified.
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Stepper Motor

#20 Post by Domosapiens » 15 Mar 2018, 21:05

System design is the right balance between mechanics,electrics and software.

I think the A4988 driver is much simpler (1 control signal step) then the ULN2003 and less load for ESP.
874385874_830-images.jpg
874385874_830-images.jpg (50.41 KiB) Viewed 42780 times
The 28BYJ-48 motor can run with the A4988 after a small motor modification:

Image
See:
http://www.jangeox.be/2013/10/change-un ... polar.html

I tried it, it works, but this motor was too slow for my application: a curtain of 4 meters.
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

mstjerna
Normal user
Posts: 10
Joined: 17 Jan 2018, 16:43

Re: Stepper Motor

#21 Post by mstjerna » 16 Mar 2018, 13:45

Well if you want to discuss hardware / software...
https://circuitdigest.com/electronic-ci ... or-circuit

Why not then add a external PWM and only controll Direction/Enable with the ESP12?
555 timer is like $0,5 :-)

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Stepper Motor

#22 Post by Domosapiens » 16 Mar 2018, 15:38

Strange answer ..
With a small electronic modification and an intelligent A4988 driver you can use the software you asked me for (without overloading the ESP).
As TD-er commented here: https://github.com/letscontrolit/ESPEas ... -373406715
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Stepper Motor

#23 Post by TD-er » 17 Mar 2018, 11:53

Also know a bit of the electronics and why things are limited somehow.
The thing is, a stepper motor is driven by current, not by voltage. This may sound a bit strange, but let me explain.
If you disable the current through the stepper motor coil, it will produce some voltage, which is opposite to the voltage applied previously.
For slow stepping, this doesn't matter.
But for faster steps, this will decrease the current through the coil and thus the strength of the magnetic field of the coil.
Above some step frequency it is no longer to keep up and you will loose steps, stall or even make some reverse steps.

This depends on the load of the stepper, the voltage applied and some other factors.

Some more sophisticated stepper motor drivers support a sense resistor to measure the current through the coil and limit the current (to prevent heating up the motor).
This allows to use a much higher voltage and thus higher step frequencies.
The A4988 is such a more sophisticated stepper motor driver, used often in 3D printers.

If you're running at the same step frequency always and also disable the current through the stepper when not moving, you could use a (much) higher voltage, even when using a very simple stepper motor driver like the 2003. (make sure you don't exceed the max current and voltage of the driver)
Just watch the temperature closely when determine the desired stepper speed and do these tests with the actual load of the stepper motor.
You could also make a power supply for the stepper which limits the current automatically to something like 100 mA. I think that's the safest way.

mstjerna
Normal user
Posts: 10
Joined: 17 Jan 2018, 16:43

Re: Stepper Motor

#24 Post by mstjerna » 20 Mar 2018, 11:26

@Domosapiens

Thanks, I have already seen the modification for the motor in another forum. I may go in this direction, but they also pointed out that you loose torque. I am afraid that the motor will not manage to drive a roller-blind.
What's your experience of this modification? I have the 12v versions.

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Stepper Motor

#25 Post by Domosapiens » 20 Mar 2018, 18:25

I never used it without modification, so I don't know the difference.
It fulfilled my requirement of 7N but too slow for my 4 meter curtain (iirc 1.5 minutes).
This one is my selection:
https://www.ebay.com/itm/1PCS-Used-27mm ... 282f328fa0
Has metal gears instead of plastic.
And works with Stepper-Driver-A4988 https://nl.aliexpress.com/item/5pcs-lot ... 62c6uYD24x
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

hoods
New user
Posts: 3
Joined: 27 Feb 2018, 21:53

Re: Stepper Motor

#26 Post by hoods » 21 Mar 2018, 22:12

Guys,

hope you can help me.
I have setup a Wemos D1 mini + DRV8825 + Nema 17 (17HD40005-22 b).
Wires are connected as shown in post #7:
ENABLE -> D5
Step -> D6
Dir -> D7
12VDC / 6A Power supply:
+ -> VMOT
- -> GND
100 µF cap between + and -
RESET + SLEEP are connected to 3,3V from ESP

I have successfully compiled the ESPEasy firmware (ESPEasy_mega-20180302) incl. the plugin from Domosapiens and also tested a second version of the firmware with the original P106 plugin. Both ESPEasy versions have the same behavior after configuring the Plugin in the Web-IF of ESPEasy.

Vref of the motor driver before has been configured to 600mV.

Unfortunately I do not have any experience with stepper motors so I start to ask myself, what values I have to define for my stepper in the plugin sources.
I've tested a lot with values like:
max_stepper_speed = 32000;
stepper_speed = 32000;
stepper_accel = 16000;
steps = 800;

According to the spec my stepper runs max 8000 pps (pulse per sec) and 200 pulses/rev.

The problem is, it starts to move but only very slow and it's more like stuttering it's way forward. I'm not able to change the speed with parameters set_accel, steps, speed.
http://esp09.fritz.box/control?cmd=speed,2000
http://esp09.fritz.box/control?cmd=left

I played already with Vref but the situation stays the same. Next I've used a very simple stepper code with an Arduino UNO only connected 5V, GND, Pins 8 and 9 and voila it turns as expected with a decent speed.

Arduino code:

Code: Select all

/* stepper motor control code for DRV8825
 * 
 */

 // define pin used
 const int stepPin = 9;
 const int dirPin = 8;
 
 void setup() {
 // set the two pins as outputs
  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);

}

void loop() {
digitalWrite(dirPin,HIGH); //Enables the motor to move in a perticular direction
// for one full rotation required 200 pulses
for(int x = 0; x < 200; x++){
  digitalWrite(stepPin,HIGH);
  delayMicroseconds(500);
  digitalWrite(stepPin,LOW);
  delayMicroseconds(500);
}
delay(1000); // delay for one second


digitalWrite(dirPin,HIGH); //Enables the motor to move in a opposite direction
// for three full rotation required 600 pulses
for(int x = 0; x < 600; x++){
  digitalWrite(stepPin,HIGH);
  delayMicroseconds(500);
  digitalWrite(stepPin,LOW);
  delayMicroseconds(500);
}
delay(1000); // delay for one second
}
Why it is that slow if I use the ESP and how do I have to properly configure the parameters in the plugin sources. At the moment I'm a bit lost, would be great if someone can help me to sort that out.

Thanks in advance, Sven

luisfcosta
New user
Posts: 8
Joined: 20 May 2017, 07:23

Re: Stepper Motor

#27 Post by luisfcosta » 03 Jun 2018, 06:25

Hi there!

@Domosapiens, did you use the default settings (for the AccellStepper library) or some specific ones for the 28BYJ
And if I may, which values you used for the 2phase - 6wires? (https://www.ebay.com/itm/1PCS-Used-27mm ... 282f328fa0)
It's a bit tricky to find the right balance and get the most of these little motors.
I am trying to move 2m long Ikea roller blinds.

Thanks and great work on the libraries!

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Stepper Motor

#28 Post by Domosapiens » 03 Jun 2018, 20:48

My project is still dormant ..
What I remember
Use
A+ and A-
B+ and B-
Other wires not connected.

I just fiddled with the parameters, nothing special.
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

User avatar
EDsteve
Normal user
Posts: 61
Joined: 11 May 2018, 21:13

Re: Stepper Motor

#29 Post by EDsteve » 18 Jun 2018, 21:07

Hey,

i am using the code from the fist page of this thread. Compiling and uploading OK.
When i try to add the motor plugin i get this error:
Capture.PNG
Capture.PNG (32.44 KiB) Viewed 42656 times
Is that something i can ignore? Doesn't look like it. Am i the only one with this error?
Would be thankful for an advice.

Thank you
ED

Monster Beat
New user
Posts: 4
Joined: 03 Nov 2016, 23:13

Re: Stepper Motor

#30 Post by Monster Beat » 10 Aug 2018, 16:29


Is there anybody using it with actual mega firmware?
there is less about stepper motors in the forum nobody usig it?


Monster Beat
New user
Posts: 4
Joined: 03 Nov 2016, 23:13

Re: Stepper Motor

#31 Post by Monster Beat » 10 Aug 2018, 17:02

EDsteve wrote: 18 Jun 2018, 21:07
Capture.PNG

Is that something i can ignore? Doesn't look like it. Am i the only one with this error?
Would be thankful for an advice.

Thank you
ED

Same Problem here...

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Stepper Motor

#32 Post by Domosapiens » 07 Jul 2019, 17:27

30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

Monster Beat
New user
Posts: 4
Joined: 03 Nov 2016, 23:13

Re: Stepper Motor

#33 Post by Monster Beat » 07 Jul 2019, 21:32

Thank you!

I will test it :)

sparkes
Normal user
Posts: 14
Joined: 25 Feb 2018, 20:57

Re: Stepper Motor

#34 Post by sparkes » 11 Sep 2020, 15:19

Does anyone have this working?

I've got a TB6612 stepper motor controller but I can't get this plugin to work?

I could do with a wire diagram and an example.

mkhaled
New user
Posts: 4
Joined: 10 Mar 2021, 00:52

Re: Stepper Motor

#35 Post by mkhaled » 10 Mar 2021, 01:06

Hello,

I have been using nodeMCU for a couple of weeks now and I am able to control Leds using switches and potentiometer.
I am trying to control a stepper motor with the nodeMCU (with esp8266) and openhab. Can someone help me with this?

Could someone please provide the custom plugin? The 7 day duration has obviously expired, @Domosapiens

At a beginner level, can someone please explain how exactly to add a custom plugin to the firmware?

Any help and suggestions would be highly appreciated. Thank you!

croftsquirrel
New user
Posts: 1
Joined: 23 Jun 2022, 09:55

Re: Stepper Motor

#36 Post by croftsquirrel » 23 Jun 2022, 10:04

I'm struggling to compile ESPEasy_v2.0.0-dev7_Cstep_Ostep_firmware from around 2017 into latest ESPEasy releases. Full of errors when trying to build.

@Domosapiens please can you give us some pointers on how to successfully build on latest releases. What needs to change in the P107/P108 and ESPEasy.ino files? What else needs changing?

Your help is much appreciated.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Stepper Motor

#37 Post by TD-er » 23 Jun 2022, 10:33

Why are you trying to build a firmware of 5 years ago?
What do you need, that isn't present in the current builds?

Please share a link to the plugins you need to build.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 30 guests