This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DRV8838: Motor not rotating in reverse direction

Part Number: DRV8838
Other Parts Discussed in Thread: DRV8837

I am using SAMD21 with adafruit feather M0 burned as bootloader to control the direction of DC motor via DRV8838, code to turn motor forward :  

*****************************************************  
const int  enablepin = 9;
const int phpin = 18;
const int nsleeppin = 17;
void setup() {​​​​​​​
  pinMode (enablepin, OUTPUT);
  pinMode (phpin, OUTPUT);
  pinMode (nsleeppin, OUTPUT);
}​​​​​​​
void loop() {​​​​​​​
  digitalWrite(phpin,HIGH);
  digitalWrite(nsleeppin,HIGH);
  digitalWrite(enablepin,HIGH);  
}​​​​​​​
********************************************************
code to turn motor in reverse :
*********************************************************
const int  enablepin = 9;
const int phpin = 18;
const int nsleeppin = 17;
void setup() {​​​​​​​
  pinMode (enablepin, OUTPUT);
  pinMode (phpin, OUTPUT);
  pinMode (nsleeppin, OUTPUT);
}​​​​​​​
void loop() {​​​​​​​
  digitalWrite(phpin,LOW);
  digitalWrite(nsleeppin,HIGH);
  digitalWrite(enablepin,HIGH);  
}​​​​​​​
************************************************************
using this code, the motor does start rotating forward, but when changing to digitalWrite(phpin, LOW); to rotate the motor in reverse, the motor does not rotate but stops, sort of vibration noise is heard from the motor instead.

I have checked with voltmeter, there is 3.3V on the uC pins shorted to enable & nsleep pin and 0V on uC pin which is shorted to ph pin of DRV8838, i also verified that DRV8838 is getting 3.3V at its VM & VCC pin and the enable & nsleep pins are at 3.3V & ph ph pin is at 0V, still the motor is not rotating in reverse direction. Tried replacing the DRV8838 but the same problem is still persisting even after replacing with two new fresh from the reels IC. The motor only rotates in forward direction.

  • Hi Manan,

    Thank you for posting to the motor drivers forum.

    I have a couple questions:

    1. Does the motor spin when starting in the reverse direction (PH=0) rather than in the forward direction?
    2. How much delay are you providing (if any) before reversing the motor direction?
    3. Do you have EN toggling or is it set to 0 always?
    4. Did you monitor the output current and VM/VCC during direction change?
  • Hello Pablo,

    1. The motor only spins in forward direction (PH=0) and does not spin in reverse direction (PH=1). No the motor does not spin when started in reverse direction (PH=1) & only spins when started in forward direction (PH=0)

    2. I have tried with various delays ranging from 1s to 10s and in both combination, staring with forward (PH=0) & reverse (PH=1).

    3. Yes i have EN = 1 always.

    4. When motor is spinning in forward direction (PH=0) the motor sinks 0.05A but as soon as direction changes to reverse (PH=1) the current sinked by motor is 0A, and voltage at VM & Vcc is 3.3V all the times, but to measure the voltage of VM & VCC i measured the voltage across capacitors C21 & C22 as shown in the layout.

  • Hi Manan,

    Thank you for answering my questions.

    Have you checked that the motor is bi-directional? if it is uni-directional, it would explain why it only rotates in one direction. I'm sure you have checked this but I just want to confirm.

    If you keep EN=1 and only change PH to change direction, I expect the motor driver to properly change the polarity across the output terminals to reverse current flow in the motor. Can you try removing the motor from the outputs and repeating the same experiment? measure the voltage at OUT1 and OUT2 in both forward and reverse direction? I want to verify if the driver is properly changing the output states.

  • Hello Pablo,

    The motor is Bi-directional.

    Yes, i keep EN=1 and only change PH to change direction, tried the experiment you suggested, removed the motors, and measured the voltage while changing direction, when the motor spins forward (PH=1) I get positive 3.3V when the positive probe of voltmeter is connected to OUT 2 pin & negative probe is connected to OUT 1 pin on DRV8838. When the direction changes that is PH=0, voltmeter displays 0V instead of -3.3V. Also measured the current when motor spins forward i get the reading of 50mA but when i try to run motor in reverse, ammeter reads 0A.

  • Hi Manan,

    Did you verify the EN and PH voltage values using a multimeter when you performed the experiment? what were the values when motor direction is in reverse?

    If the EN and PH logic follows table 2 of the datasheet, then we'll have to check if the unit is having issues. Can you try switching the current DRV8838 IC with a new one and retry the experiment?

  • Hi Manan,

    Any updates? were you able to perform the experiment I suggested?

  • Hello Pablo,

    Sorry for the late reply, yes i had perform the experiment you have stated that is i did verify the EN & PH voltages using multimeter , while changing the direction of the motor, EN voltage was always 3.3V & PH voltage was 0V while spinning the motor in forward direction & when PH voltage was 3.3V the motor was not spinning in reverse direction.

    Also replaced the IC and performed all the above discussed experiments and got the same result.

    But, i discovered really thing, i was able to reverse the motor, by not following the truth table mentioned in the data sheet, code for reversing the motor :

    const int enablepin = 9;
    const int phpin = 18;
    const int nsleeppin = 17;

    void setup()
    {
      Serial.begin(115200);
      pinMode (enablepin, OUTPUT);
      pinMode (phpin, OUTPUT);
      pinMode (nsleeppin, OUTPUT);
    }

    void loop()
    {  
      if (Serial.available() > 0)
      {
        int inByte = Serial.read();
        switch (inByte)
        {
          case '0': // Switch statement to Stop the motor
          digitalWrite(nsleeppin,HIGH);
          digitalWrite(enablepin,HIGH);
          digitalWrite(phpin,HIGH);   
          Serial.println("BRAKE");
          break;

          case '1': // Switch statement to spin the motor in Forward direction
          digitalWrite(nsleeppin,HIGH);
          digitalWrite(enablepin,HIGH);
          digitalWrite(phpin,LOW);
          Serial.println("FORWARD");
          break;

          case '2': // Switch statement to spin the motor in Reverse direction
          digitalWrite(nsleeppin,HIGH);
          digitalWrite(enablepin,LOW);
          digitalWrite(phpin,HIGH);
          Serial.println("REVERSE");
          break;

    }

    }

    }

    As you can see from the code i was able to reverse the motor by pulling down the enable pin to 0V, i mean, yes, this does not make sense, but voila the motor is now spinning in both the direction and checked the voltage on OUT 1 & OUT 2 pins, for forward direction when positive probe is on OUT1 and GND probe of multimeter on OUT 2 the voltage reading is -3.3V and for motor spinning in reverse direction the voltage reading is 3.3V. I don't know what to make of this.

  • Hi Manan,

    Thank you for the update.

    Are you sure that the device you have is the DRV8838? As you can see in the datasheet, the DRV8837 is the PWM interface variant of the DRV8838. The truth table for the PWM interface seem to align with the Code logic.

  • Hi Manan,

    Any updates? Has your issue been resolved?

  • Hi Pablo,

    I am quite positive it is DRV8838 and not DRV8837, i mean i am able to run the motor but with logic being inverse.

    Thanks 

  • Yes i have ordered DRV8838, here is the link from where i had ordered it : 

    lcsc.com/.../Motor-Drivers_Texas-Instruments-DRV8838DSGR_C86667.html

  • Manan,

    Got it. thanks for confirming.

    If that's the case, then I am very confused as to why changing the logic in the code fixed the issue. As long as the input signals follow the truth table for forward and reverse direction, the motor should be able to spin both ways. In the previous replies you have confirmed that the logic values of the input signals aligned with the  truth table but only spins in the forward direction. You also confirmed that replacing the IC does not help so we can't definitely blame a single bad IC as the cause of the issue.Most likely, the problem might be with the code implementation.

    By the way, did the EN and PH values change when you modified the code?

  • Hi Pablo,

    I got the inventory checked and it turns out it was indeed drv8837 and not 38, made a sourcing error.

    So sorry about it.

    Thanks for all the help you have provided.

    Regards,

    Manan Mehta