Drv8835 - Sending Low then High

Hi,

Still kind of new to working we motor drivers.

Code is at the bottom

Background:
I’m using a pi pico 2 w - https://www.raspberrypi.com/documentation/microcontrollers/pico-series.html#pico-2-family - powered over USB

along side with the DRV8835 - Pololu - DRV8835 Dual Motor Driver Carrier - VIN and GND are connected to a supply at 3.7v and limited at 2.5amps

I’ve connected the pi pico 2 to the drv8835 as described the documentation.

Problem(s):

  1. If the power supply is on before the micro controller the program fails - I hear an audible buzzing from the micro controller but the motor does not spin. There is a small draw of current.
  2. The program works initially when the microcontroller is turned on before the power supply. The motor spins and I see a nominal draw of current. After setting SPEED_OFF, when SPEED_SLOW is set - I hear an audible buzzing from the micro controller but the motor does not spin. There is a small draw of current.

I would expect to be able to set pwm to 0 and be able to then > 0 value later on. I’ve also tested this with the DRV8833 and I’m experiencing the same issue. I’ve successfully tested this on the MP6550 and it does just fine.

Let me know if I can elaborate anywhere. Appreciate any help and feedback.

#include "pico/stdlib.h"
#include "hardware/pwm.h"

#define MOTOR_GPIO 0  // GPIO pin connected to motor PWM input



// PWM duty cycle values (0-65535 for 16-bit resolution)
#define SPEED_OFF 0
#define SPEED_SLOW (65535 / 4)  // 25% duty cycle
#define SPEED_FAST (65535 * 3 / 4)  // 75% duty cycle

void setup_motor_pwm(uint gpio) {
    gpio_set_function(gpio, GPIO_FUNC_PWM);
    uint slice_num = pwm_gpio_to_slice_num(gpio);
    pwm_set_wrap(slice_num, 65535);  // Set top of PWM counter
    pwm_set_enabled(slice_num, true);
}

void set_motor_speed(uint gpio, uint16_t duty_cycle) {
    uint slice_num = pwm_gpio_to_slice_num(gpio);
    pwm_set_chan_level(slice_num, pwm_gpio_to_channel(gpio), duty_cycle);
}

int main() {
    stdio_init_all();
    setup_motor_pwm(MOTOR_GPIO);

    while (true) {
        set_motor_speed(MOTOR_GPIO, SPEED_SLOW);
        sleep_ms(5000);

        set_motor_speed(MOTOR_GPIO, SPEED_FAST);
        sleep_ms(5000);

        set_motor_speed(MOTOR_GPIO, SPEED_OFF);
        sleep_ms(5000);
    }

    return 0;
}```

Hello.

Could you post more details about your setup, including what power supply and motor you are using as well as what (if any) load is on your motor? Also, could you post some pictures of your setup that show all of your connections?

Brandon

Power Supply: Amazon.com

Motors: Amazon.com

Wiring:
Pi pico 2 GND ↔ GND
Pi pico 2 3.3v OUT ↔ VCC
Pi pico 2 GP0 ↔ B2/BENABLE
Pi pico 2 GND ↔ B1/BPHASE
Power Supply (-) ↔ GND
Power Supply (+) ↔ VIN
8520 Motor (White Wire) ↔ BOUT2
8520 Motor (Black Wire) ↔ BOUT1

Photos




Also no load on the motor - aka no props on it, this is for a micro drone.

I thought I would try:

Pi pico 2 3.3v OUT ↔ B1/BPHASE

When i send GP0 to a duty cycle of 65535 - essentially GPIO HIGH. I see the behavior of the motor braking. Then I send it (65535 / 2) - which I expect the motors to spin back up, but they don’t and I hear an audible buzzing.

Could you try removing the motors and tying the BIN1 and BIN2 pins high and low while measuring the voltage across the B-channel motor outputs? When one pin is high and the other is low, you should see the VIN voltage across the respective motor outputs.

If that seems to be working correctly, could you try connecting your motors again? Then, if they still do not run as expected, it might be that they are trying to draw too much current (and causing the DRV8835’s current limiting to kick in), in which case you can try lowering the supply voltage to something like 2.5V to see if that makes any difference.

Brandon

I goofed up and mis-wired my DRV8835 as I was debugging so I have to order some more… But I do have a DRV8833 and I can test on that and it was experiencing the same issue. I don’t have a volt meter readily accessible - so I’ll post that tomorrow.