[Solved] DRI0001 DC motor control
Hi,
My project is to control a DC motor using an Arduino UNO, the DRI0001 shield from DFRobot described here:
https://www.dfrobot.com/wiki/index.php/ ... :_DRI0001)
and a remote recevier/remote control.
I have inserted some instructions to print a comment to the serial monitor when it enters in the section of the program that is supposed to make the motor to turn, in order to be sure that the program passes through the appropriate lines. The Motor is supposed to require 100mA, so the Arduino is powered via the USB, I do not believe that an external Power Supply is required (?).
Here is the Void Motor definition, just copied from the DFRobot site (just ignore the comments in French):
Do you have an idea ??
Thank you
My project is to control a DC motor using an Arduino UNO, the DRI0001 shield from DFRobot described here:
https://www.dfrobot.com/wiki/index.php/ ... :_DRI0001)
and a remote recevier/remote control.
I have inserted some instructions to print a comment to the serial monitor when it enters in the section of the program that is supposed to make the motor to turn, in order to be sure that the program passes through the appropriate lines. The Motor is supposed to require 100mA, so the Arduino is powered via the USB, I do not believe that an external Power Supply is required (?).
Here is the Void Motor definition, just copied from the DFRobot site (just ignore the comments in French):
Here is the void setup section copied fro the DFRobot website:int EN1 = 6; // affecte la valeur 6 à EN1, et EN1 est la sortie utilisée pour la sortie PWM numéro 6 plus bas
int EN2 = 5; // affecte la valeur 5 à EN2
int IN1 = 7; // affecte la valeur 7 à IN1
int IN2 = 4; // affecte la valeur 4 à IN2
void Motor1(int pwm, boolean reverse) { // La valeur de PWM sera définie au moment de l'appel à cette fonction
// et la valeur de la variable booléenne 'reverse' sera à true ou false selon le sens
// de rotation que l'on voudra lors de l'appel de cette fonction
analogWrite(EN1, pwm); //set pwm control, 0 for stop, and 255 for maximum speed
if (reverse) {
digitalWrite(IN1, HIGH); // si vrai on passe la sortie digital 7 (contrôlant la direction) à la valeur 1
// et on fait donc tourner le moteur dans le sens normal en mettant IN1 à HIGH
// MAIS si 'reverse' est vrai, ça voudrait dire l'inverse : à tester !!
}
else {
digitalWrite(IN1, LOW); // si faux on passe la sortie digitale 7 à la valeur 0 et le mouteur tourne donc en arrière
}
}
and here is the section supposed to make the motor to turn:void setup()
{
int i; // Début initialisation pour le Shield Motor
for (i = 4; i <= 7; i++) //For Arduino Motor Shield
pinMode(i, OUTPUT); //set digital pins 4,5,6,7 to output mode
Serial.begin(9600); // Démarre le transmetteur série pour voir les résultats sur PC //Fin initialisation pour le Shield Motor
irrecv.enableIRIn(); //
irrecv.blink13(true);
I see on the Serial Monitor that the program does enter in this last section when the proper code is received from the IR Remote, BUT the motor doesn't turn, never, not a single move !if(results.value==0xFD807F){ // "FD807F" correspond au Bouton VOL+ de la Télécommande DFRobot DFR0107 utilisée: les codes ont été trouvés au précédent Tuto 10
// au cours duquel il a lu la valeur reçue par le capteur IR quand il appuyait sur le Bouton 1
// ATTENION: bien mettre 0x devant FD807F car sinon l'Arduino ne comprends pas que c'est un code hexadécimal...
// il faut ici faire tourner le moteur 1 dans le sens normal, mais insérer un BREAK dans une loop pour un délai
// On envoie le message début moteur 1 pour voir si le programme arrive jusqu'ici !
Serial.println("Debut motor 1 avec Vol+:"); // puis on actionne le moteur
Motor1(300, true); // Move ahead, replace 100 with the PWM value of your choice
delay (500); // fait tourner le moteur pendant 300ms puis passe à l'instruction suivante
Motor1(0, true); //doit théoriquement arrêter le Motor1
Serial.println("Fin motor 1 avec Vol+:");
}
Do you have an idea ??
Thank you
2018-09-02 01:32:31 I have found the cause, the problem is due to an error in the Shield documentation from DFRobot:
On this page:
https://www.dfrobot.com/wiki/index.php/ ... :_DRI0001)
you see on the picture where the Motor1 and Motor outputs are located. BUT there is an error: Motor1 is Motor2 and vice versa!
So for controling the Motor1 (using the instruction Motor1 in the Arduino program), just connect it to the Motor2 output !
and everything runs perfectly !... anonymous
On this page:
https://www.dfrobot.com/wiki/index.php/ ... :_DRI0001)
you see on the picture where the Motor1 and Motor outputs are located. BUT there is an error: Motor1 is Motor2 and vice versa!
So for controling the Motor1 (using the instruction Motor1 in the Arduino program), just connect it to the Motor2 output !
and everything runs perfectly !... anonymous