Connect esp32 to vid2805 using DRV8825

Hi folks,

I need some help about i have connected a VID2805 (5 volts stepper motor) to my esp32 using a DRV8825 to do that i used the wiring scheme from here

I have also connected the ground from my esp32 to the ground of the 12v power supply.
I have set the vref to the lowest value.

And finally below is the code i use.

#include <MobaTools.h>

#define MOTOR1_STEP_PIN 14
#define MOTOR1_DIR_PIN 12

const int stepsPerRevolution = 1090; // 0.33° per step = 360*0.33 = 1090

MoToStepper motor1( stepsPerRevolution, STEPDIR );

int targetPosition = 360;

void setup() {
   Serial.begin(115200);
    motor1.attach(MOTOR1_STEP_PIN, MOTOR1_DIR_PIN);
    motor1.setSpeed(1000);   
    motor1.setRampLen( 100 ); 
    motor1.moveTo(0);
    motor1.setZero();


}

void loop() {
    if (!motor1.moving()) {
        Serial.println("Motor not moving : ");
        Serial.println(targetPosition);
        
        if (targetPosition > 0) {
          targetPosition = -360;
        } else {
          targetPosition = 360;
        }
        delay(100);
        motor1.moveTo(targetPosition);
    }
}

The motor do the job sometimes ... sometimes the motor do two or more turns instead of going backwards ... sometimes it seems like it move forward then go backward one step then go forward ... Well not reliable at all.

Please can someone help me ?

That's not the way to present information. Post it here, as a picture.

Don't. Only logic grounds should be connected.

Why? Set it to a value that corresponds to a desired stepper current.

Hi and thanks.

Here is the picture :

I have removed the ground, but still the same.

To set the vref : Imax / 2 = 0,015 / 2 = 0.0075 V = 7.5 Millivolts
Very hard to set with the potentiometer

Sorry but I don't have those parts in my hand. The coloured lines to positions are useless. Schematics show the logic names of the pins.

You need to know the current measuring resistor. Why set the current to 15 mA? That looks like useless. No torque at all.
Please post a link to the datasheet of that stepper!

Here is a more detailed scheme.
Step is on GPIO14 and dir on GPIO12

0J4233.600

Here is the only spec sheet i own :

And here is a detailed specs :

VID28 Series Stepper Motor

This is a very special dual stepper for display instruments. The coils are low current / high impedance, and I doubt that the DRV8825 is a suitable driver for this kind of steppers, The DRV8825 is designed for low impedance steppers. But I have no experience with this kind of steppers.
Are you shure you connected the coils correctly?. There are 4 coils, bause the device contains two independet steppers.

setSpeed(1000); means 100 rev/min or - with 1090 steps/rev - 1816 steps/sec. That's far beyond the capabilities of that steppers. From the datasheet it's max 600 steps/sec with acceleration and 200 steps/sec without.

Common H-bridges seem more suited for these steppers than a DTV8825.
Adafruit uses the TB6612.
Leo..

Hi and thanks,

  • Yes the wiring is good, there is 4 coils with 2 pins per coil.

  • For the speed, i will try to set different speed :
    200 steps / sec = 1 step / 0.005 sec
    1090 step * 0.005 = 5.45 sec / revolution

I have tried this code :

#include <MobaTools.h>

#define MOTOR1_STEP_PIN 14
#define MOTOR1_DIR_PIN 12

const int stepsPerRevolution = 1090; // 0.33° per step = 360*0.33 = 1090

MoToStepper motor1( stepsPerRevolution, STEPDIR );


void setup() {
   Serial.begin(115200);
    motor1.attach(MOTOR1_STEP_PIN, MOTOR1_DIR_PIN);
    motor1.setSpeedSteps( 2000, 200 ); // speed in steps / 10 secs , ramplen
    motor1.setZero(0, 1090);


}

void loop() {
  Serial.println("clockwise");
  motor1.rotate(1);
  delay(1800);
  
  // step one revolution in the other direction:
  Serial.println("counterclockwise");
  motor1.rotate(-1);
  delay(1800);
}

So i can hear the sound of each step but the motor not moving.
Motor moving but going same problem ...

I have a Drv8833 maybe it's better for such motor ?

For some reason i realize that the motor1.rotate(-1); part of the code is a problem it turn good if i let motor1.rotate(1); but when i change direction it's like the motor wanted to go both direction

This stepper seems to need a 6-step sequence.
I think most stepper libraries use a 4-step sequence, or 8, 16, 32 etc.
Maybe @MicroBahner can shed some light on that. I think he wrote MobaTools.
The sequence I wrote for a 28BYJ-48 stepper surely did use a 4, 8 sequence.
Leo..

Yes, looking at the datasheet it seems so. But I don't have any experience with these kind of steppers. When using the DRV8825, the library has no influence on the step sequence, it only creates step and dir signals. When using a H-bridge it should be possible to write a test sketch that creates the steps exacly according to the datasheet. I'm also not quite shure if the stepper is able to rotate continuously. This would even not be necessary for the intended use.

From the datasheet:

  • Low current consumption: less than20mA, 5V, 2X100mW.

Should be even possible to drive them directly from ouput pins :thinking:
( with flyback diodes)

Yes, the coils seem to be 280 ohm, and 18mA is not a problem for an Uno.
Adding eight 1N5819 diodes is a wise move.

The stepper.h library seems to only cater for 4-sequence and 10-sequence motors.
Maybe some clever kid (not me) can add a custom 6-sequence to that.
Leo..

Yes it's possible to drive it from a uno but i use esp32 which cannot provide 5v on pin.
I should also say that so far i try to make only one part of the motor to turn (so 2 coils)

From my understanding Drv8833 is a H bridge, i have connected it using below scheme :
Sans titre

I set IN1 to IN4 on ESP32 GPIO 12,13,14,27 and OUT1 to OUT4 on the 4 pins of one motor but nothing happend

The stepper.h library does.
But it only has a 4-step sequence attached to a 4-wire motor.
this
stepMotor(this->step_number % 4);
and this

  if (this->pin_count == 4) {
    switch (thisStep) {
      case 0:  // 1010
        digitalWrite(motor_pin_1, HIGH);
        digitalWrite(motor_pin_2, LOW);
        digitalWrite(motor_pin_3, HIGH);
        digitalWrite(motor_pin_4, LOW);
      break;
      case 1:  // 0110
        digitalWrite(motor_pin_1, LOW);
        digitalWrite(motor_pin_2, HIGH);
        digitalWrite(motor_pin_3, HIGH);
        digitalWrite(motor_pin_4, LOW);
      break;
      case 2:  //0101
        digitalWrite(motor_pin_1, LOW);
        digitalWrite(motor_pin_2, HIGH);
        digitalWrite(motor_pin_3, LOW);
        digitalWrite(motor_pin_4, HIGH);
      break;
      case 3:  //1001
        digitalWrite(motor_pin_1, HIGH);
        digitalWrite(motor_pin_2, LOW);
        digitalWrite(motor_pin_3, LOW);
        digitalWrite(motor_pin_4, HIGH);
      break;
    }
  }

in the stepper.cpp seem to be relevant.
I think that needs to be changed to a 6-step sequence to make this motor work.
Leo..

Not with a DRV8825. This driver only has step and dir inputs. The step sequence is defined internally by the driver. Only with a simple H-bridge the step sequence is defined by the software. Then of course you can change it by changing the library or your own sketch, if you don't use a library.

Btw, the stepper.h is not designed to work with a step/dir driver.

This guy has connected a vid2805 to an arduino without modifying library code : https://www.youtube.com/watch?v=_yhyu2qyVAw

And what does the sketch you used look like?