Here's an improved English translation of the text:
Hello everyone,
I hope you're doing well. I find myself in a situation with the DRV8876 component and I'm hoping you can help me. Thank you in advance.
Components:
- DRV8876
- ESP32
- 12V DC Motor
- Power supply
Objective: First, to control the motor's PWM from the code, and then to move on to a second challenge, which is to control the output current from the code.
Setup:
- GND: common
- VM pin of the DRV8876 connected to the power source (this pin is responsible for powering the motors) with an initial voltage of 5V
- VIN pin (responsible for powering the driver) with an initial voltage of 5V
Situation/Problem: When making the connections as shown in the image, there's a high current spike even though it's only 5V. Despite the DRV8876 being capable of handling more, it's also heating up significantly. I'm not sure what could be causing this.
Note: The circuit doesn't have any external components to protect against overheating.
sorry for the bad translation, I don't speak the language well
escribe o pega el códigoconst int PH_PIN = 22; // Pin PH del DRV8876
const int EN_PIN = 23; // Pin EN del DRV8876
int pwmValue = 0; // Valor inicial del PWM (0-255)
void setup() {
// Configurar los pines como salidas
pinMode(PH_PIN, OUTPUT);
pinMode(EN_PIN, OUTPUT);
// Inicializar comunicación serial
Serial.begin(115200);
Serial.println("Ingrese un valor de PWM (0-255):");
}
void loop() {
// Verificar si hay datos disponibles en el monitor serial
if (Serial.available() > 0) {
// Leer el valor ingresado en el monitor serial
int input = Serial.parseInt();
// Validar que el valor esté en el rango permitido (0-255)
if (input >= 0 && input <= 255) {
pwmValue = input;
Serial.print("Valor PWM actualizado a: ");
Serial.println(pwmValue);
// Actualizar el valor PWM en el pin EN
analogWrite(EN_PIN, pwmValue);
// Opcional: puedes ajustar la dirección del motor aquí si lo deseas
// digitalWrite(PH_PIN, HIGH); // Dirección 1
// digitalWrite(PH_PIN, LOW); // Dirección 2
} else {
Serial.println("Por favor, ingrese un valor válido entre 0 y 255.");
}
}
} aquí


