Motor drive controlled by ESP32 (Arduino)

421 Views Asked by At

I am testing a custom motor drive (small 6V DC motor) controlled by an ESP32 using Arduino code. The direction A and B are controlled by High/Low digital writes on GPIO pins 16 & 17. Using an NPN transistor (NPN transistor - BC847 - datasheet) and a (dual n/p mosfet IRF7105 - datasheet).

The speed is controlled by PWM (ledc) on pin 26 with a mosfet: (IRLML2502 n-channel mosfet datasheet)

Motor Drive - schematic

But the results are not consistent, when I set A or B high and PWM at 100%, I would expect close to 6V on the motor pins (1 and 2). Sometimes this is indeed the case, but sometimes I only measure 3.7V. When the testpoint T6 is shorted to ground, the 6V is reached. I am not even sure where the different voltage goes "missing", I measured the following voltages with my DMM (no oscilloscope available unfortunately).

  • M1 - M2: 3.7V
  • M1 to GND: 0V
  • M2 to 6V: 6V

Is there something I am missing in the schematic or in the way I drive this with the ESP32?

1

There are 1 best solutions below

1
On

Arduino.jpg

 #include <Stepper.h>
    
    int stepCount = 0;
    Stepper Moteur=Stepper(5,6,7);
    
    void setup(){
      Serial.begin(9600);
    
    }
    void loop() {
      Moteur.step(2000);
      Serial.print("steps:");
      Serial.print(-stepCount);
      stepCount++;
      delay(0);
    }