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 :
- ESP32-S3-DEVKITC-1-N32R8V
ESP32-S3-DEVKITC-1-N32R8V Espressif Systems | Development Boards, Kits, Programmers | DigiKey - BTS7960 motor driver
- DC motor (RS PRO Brushed Geared, 19.8 W, 12 V dc, 3024 gcm, 537 rpm, 6mm Shaft Diameter)
RS PRO Brushed Geared, 19.8 W, 12 V dc, 3024 gcm, 537 rpm, 6mm Shaft Diameter | RS (rs-online.com)
- LiFePO4 12Voltage (13.3V) 7AH
- DFR0379 (20W ADJUSTABLE DC-DC BUCK CONVER)
DFR0379 DFRobot | Development Boards, Kits, Programmers | DigiKey
- Battery capacity voltage 6V - 24V
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 .
- motor A = 0.0 V (spinning)
- 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