BTS7960 (PWM) 1 of 2 DC motor not spinning ESP32S3

Define Motor A right motor
Define Motor B (problem) left motor
Hi ,I have been trying to control wheels smart car I used Blynk control motor by digitalWrite() but seem like motor B spin faster and reaction faster than motor A that's make my car can't go straight then i move to Arduino IOT cloud .
I need to use PWM control and other reason about sent iPhone value to board.

Component :

Picture of car


Situation 01
===No using DFR0379===
Motor A & B spinning After 1~3 minutes only Motor B stop spinning like power off.
Reconnect battery only Motor A still spinning like a normal .
Disconnect battery and USB board leave overnight 8 hours ++ then connect battery and usb board. Motor A spinning & Motor B stop nothing are different even reconnect both GND Motor.
Monitoring voltage by touch M+ M- pin of BTS7960 while active .

  1. motor A = 0.0 V (spinning)
  2. motor B = 3.0 - 5.0 V (no spinning)

My then imagination was Like a liquid, it freezes and refuses to flow down. but Why it is 3.4 V?
Remove Motor A nothing change.
Remove BTS7960 of A nothing change.
---Yep i remain only B now---
Reconnect Battery and USB however B neither spinning nor active at all.
I instantly direct connect Battery(LifePO4 and 5V pack) to Motor B = no spinning.
Leave it for 1 to 20 minutes direct it again Yes it is spinning like normal.
If back to dual wheel It is keeping problem like this.

Situation 02
===Similar step===
Using DFR0379 with LifePO4 but Amp output just 3A and Voltage output is 12.5 Voltage can monitor it by pushbutton built-in module.
When motor B stop I just shaking GND of Motor B or reconnect, Just I did these and it came back to work however only spinning <1 minutes
Yep take off take off GND B \ (=w=" )

What i know
ledcWrite and analogWrite got the same result
When i change to analogWrite ,The Responding turning and stopping work in the same rhythm.
When the car has a problem, the wheels stop. The car does not touch the ground or have any load. It was found while i'm testing code.
I separate the operation of both motors. The motor works normally.
Specifically, motor B, I let it run for more than 5 minutes and it's motor starts to warm up. It still hasn't had any problems.


The ESP32S3 is slightly warmer than the motor, but the black top of the BTS7960 is not warm at all.
Direct connection of both motors, in the case of CCW CW, by swapping the battery polarity. everything is fine.
I used Potentiometer to send only PWM for speed but not control the direction of rotation of both wheels. It's fine.
If controlled with a button from the App, press it 2-3 times forward turnleft etc (change PWM value), Motor B will stop turning immediately. Same problem as mentioned above.
Soldering motor B

Code

#include "thingProperties.h"
//ล้อซ้าย L MOTOR
#define IN3 41 //RPWM
#define IN4 42 //LPWM

//ล้อขวา R MOTOR
#define IN1 39 //RPWM
#define IN2 40 //LPWM



void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
  
  pinMode(IN3, OUTPUT); //RPWM
  pinMode(IN4, OUTPUT); //LPWM
  pinMode(IN1, OUTPUT); //RPWM
  pinMode(IN2, OUTPUT); //LPWM

  // สั่งให้มอเตอร์หยุด
  analogWrite(IN3, 0); //RPWM
  analogWrite(IN4, 0); //LPWM
  analogWrite(IN1, 0); //RPWM
  analogWrite(IN2, 0); //LPWM
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  testwheel();
  
}

void testwheel() {
  
    //=====================================================
  
  // Accelerate forward
  digitalWrite(IN3, LOW); //RPWM L motor
  digitalWrite(IN2, LOW); //LPWM R motor
  for (int i = 0; i < 200; i+=2) {
    analogWrite(IN4, i); //LPWM L motor
    analogWrite(IN1, i); //RPWM R motor
    delay(20);
  }
  delay(500);

  // Slow down forward
  for (int i = 200; i >= 0; i-=2) {
    analogWrite(IN4, i); //LPWM L motor
    analogWrite(IN1, i); //RPWM R motor
    delay(20);
  }
  delay(500);
  
  //=====================================================

  // Accelerate backward
  digitalWrite(IN4, LOW); //LPWM
  digitalWrite(IN1, LOW); //RPWM
  for (int i = 0; i < 200; i++) {
    analogWrite(IN3, i); //RPWM
    analogWrite(IN2, i); //LPWM
    delay(20);
  }
  delay(500);

  // Slow down backward
  for (int i = 200; i >= 0; i--) {
    analogWrite(IN3, i); //RPWM
    analogWrite(IN2, i); //LPWM
    delay(20);
  }
  delay(500);
  
  //=====================================================
  
  // Accelerate turnleft
  digitalWrite(IN4, LOW); //RPWM L motor
  digitalWrite(IN2, LOW); //LPWM R motor
  for (int i = 0; i < 150; i+=2) {
    analogWrite(IN3, i); //LPWM L motor
    analogWrite(IN1, i); //RPWM R motor
    delay(20);
  }
  delay(500);

  // Slow down turnleft
  for (int i = 150; i >= 0; i-=2) {
    analogWrite(IN3, i); //LPWM L motor
    analogWrite(IN1, i); //RPWM R motor
    delay(20);
  }
  delay(500);
  
  
  //=====================================================
  
  // Accelerate turnright
  digitalWrite(IN3, LOW); //RPWM L motor
  digitalWrite(IN1, LOW); //LPWM R motor
  for (int i = 0; i < 150; i+=2) {
    analogWrite(IN4, i); //LPWM L motor
    analogWrite(IN2, i); //RPWM R motor
    delay(20);
  }
  delay(500);

  // Slow down turnright
  for (int i = 150; i >= 0; i-=2) {
    analogWrite(IN4, i); //LPWM L motor
    analogWrite(IN2, i); //RPWM R motor
    delay(20);
  }
  delay(500);
  
  
  //=====================================================
}

void onIgpsChange() {
  
}

void onIcompassChange() {
  
}


/*
  Since Push is READ_WRITE variable, onPushChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onPushChange()  {
  // Add your code here to act upon Push change
}

Question and wonder

  • Type of wire that connect motor,driver,battery. about to change to 14AWG instead.
  • GND loop problem but i used to connect Battery GND to ESP32 GND.
  • Voltage in motor due to leave it rest for few minutes so that it can work.
  • How else do I need to modify my root cause method? I don't have tools.
  • Some video BTS7960 problem - Google Drive
  • Or where did I go wrong?
    appreciate for your kind help

Schematic?

Sorry Can I use that hand-drawn image instead? This is my first time ever doing something like this.
Or is there a simple example for me to follow?

Looks like you're using breadboards for power distribution..
loose em, especially on the motors..
you're buck converter 20W and each motor is 20W?? don't sound right too me..
also need to invest in a terminal block breakout for the esp..
all wires should be short and neat..
quick look at the code, got to loose all the delays..
and why by all the Gods did you do this??

  pinMode(IN3, OUTPUT); //RPWM
  pinMode(IN4, OUTPUT); //LPWM
  pinMode(IN1, OUTPUT); //RPWM
  pinMode(IN2, OUTPUT); //LPWM

Your InS are OutS??
and yes, I agree..

then imagination was Like a liquid, it freezes and refuses to flow down. 

but regardless, sounds like a current issue..
wires are messy, start by cleaning em up..

good luck.. ~q

1 Like

Sure, you could draw a schematic on paper and post the image here.

Also, running motor power through a beadboard is not recommended (post#4).

1 Like

Make a test as: Disconnect motor A and connect motor B and run.
Any action? If there is, Your motor power supply us not up to the task.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.