Bonjour,
Je galère depuis plusieurs jours pour faire fonctionner des moteurs DC avec Arduino et différentes cartes (L293D, mini L293D puis DRV8833). Après avoir vérifier les connexions plusieurs fois, je ne suis jamais arrivé à faire tourner aucun moteur. J'ai 2 types de moteurs :
-
Moteur avec réduction à engrenage en 6V et inférieur à 0.6A
-
Moteur DC 3V et 0.2A de chez Yangfei
Les cartes :
- L293D
- DRV8833
Je me suis mis sur des DRV8833 car le moteur que je souhaite réellement utilisé (avec réduction) est en 6V et les l293D ne sorte pas cette valeur.
Voici mon montage
et mon programme :
// Define the control inputs
#define MOT_B1_PIN 10
#define MOT_B2_PIN 9
void setup(void)
{
// Set all the motor control inputs to OUTPUT
pinMode(MOT_B1_PIN, OUTPUT);
pinMode(MOT_B2_PIN, OUTPUT);
// Turn off motors - Initial state
digitalWrite(MOT_B1_PIN, LOW);
digitalWrite(MOT_B2_PIN, LOW);
// Initialize the serial UART at 9600 baud
Serial.begin(9600);
}
void loop(void)
{
// Generate a fixed motion sequence to demonstrate the motor modes.
// Ramp speed up.
for (int i = 0; i < 11; i++) {
spin_and_wait(25*i, 25*i, 500);
}
// Full speed forward.
spin_and_wait(255,255,2000);
// Ramp speed into full reverse.
for (int i = 0; i < 21 ; i++) {
spin_and_wait(255 - 25*i, 255 - 25*i, 500);
}
// Full speed reverse.
spin_and_wait(-255,-255,2000);
// Stop.
spin_and_wait(0,0,2000);
// Full speed, forward, turn, reverse, and turn for a two-wheeled base.
spin_and_wait(255, 255, 2000);
spin_and_wait(0, 0, 1000);
spin_and_wait(-255, 255, 2000);
spin_and_wait(0, 0, 1000);
spin_and_wait(-255, -255, 2000);
spin_and_wait(0, 0, 1000);
spin_and_wait(255, -255, 2000);
spin_and_wait(0, 0, 1000);
}
/// Set the current on a motor channel using PWM and directional logic.
///
/// \param pwm PWM duty cycle ranging from -255 full reverse to 255 full forward
/// \param IN1_PIN pin number xIN1 for the given channel
/// \param IN2_PIN pin number xIN2 for the given channel
void set_motor_pwm(int pwm, int IN1_PIN, int IN2_PIN)
{
if (pwm < 0) { // reverse speeds
analogWrite(IN1_PIN, -pwm);
digitalWrite(IN2_PIN, LOW);
} else { // stop or forward
digitalWrite(IN1_PIN, LOW);
analogWrite(IN2_PIN, pwm);
}
}
/// Set the current on both motors.
///
/// \param pwm_A motor A PWM, -255 to 255
/// \param pwm_B motor B PWM, -255 to 255
void set_motor_currents(int pwm_A, int pwm_B)
{
set_motor_pwm(pwm_A, MOT_B1_PIN, MOT_B2_PIN);
// Print a status message to the console.
Serial.print("Set motor A PWM = ");
Serial.println(pwm_A);
}
/// Simple primitive for the motion sequence to set a speed and wait for an interval.
///
/// \param pwm_A motor A PWM, -255 to 255
/// \param pwm_B motor B PWM, -255 to 255
/// \param duration delay in milliseconds
void spin_and_wait(int pwm_A, int pwm_B, int duration)
{
set_motor_currents(pwm_A, pwm_B);
delay(duration);
}
Programme de test trouvé sur internet (pour sécuriser mon test).
Le problème est donc le suivant :
Quelque soit la carte, quelque soit le moteur, ces derniers ne tournent jamais. Pourtant, en les connectant directement sur les pin 5V et GND de l'arduino pour tester, ils fonctionnent bien.
Quand je teste le voltage en sortie, j'ai toujours zéro, nada, rien, 0, etc. En entrée, depuis une pile 9v, j'ai bien mes 9v. Le module Arduino qui est alimenté en Vin et GND par la même pile (mais le problème existe également quand les deux cartes sont alimentées séparément) j'ai bien 5v sur la pin 5V.
Je ne sais plus quoi faire pour faire tourner ces p...... de moteurs.
Si vous avez des idées, je suis preneur.
Pour information, mon projet actuel est de réaliser un véhicule télécommandé (télécommande de téléviseur) tout en bois avec 1 moteur DC pour la motricité et un servo moteur pour la direction (qui fonctionne très bien celui-ci).
Merci à vous












