Différences entre versions de « Adafruit Motor Shield V2-Moteur continu »

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche
(Page créée avec « {{Adafruit Motor Shield V2-NAV}} {{Adafruit Motor Shield V2-TRAILER}} »)
 
Ligne 1 : Ligne 1 :
 
{{Adafruit Motor Shield V2-NAV}}
 
{{Adafruit Motor Shield V2-NAV}}
 +
 +
== Intro ==
 +
 +
[[Fichier:Motor Shield V2-Logiciel-01.jpg|640px]]
 +
 +
DC motors are used for all sort of robotic projects.
 +
 +
The motor shield can drive up to 4 DC motors bi-directionally. That means they can be driven forwards and backwards. The speed can also be varied at 0.5% increments using the high-quality built in PWM. This means the speed is very smooth and won't vary!
 +
 +
Note that the H-bridge chip is not meant for driving continuous loads over 1.2A or motors that peak over 3A, so this is for small motors. Check the datasheet for information about the motor to verify its OK!
 +
 +
== Connecter les moteurs ==
 +
To connect a motor, simply solder two wires to the terminals and then connect them to either the M1, M2, M3, or M4. Then follow these steps in your sketch
 +
 +
== Programmation ==
 +
 +
=== Inclure les bibliothèques ===
 +
Make sure you #include the required libraries
 +
 +
<nowiki>#include <Wire.h>
 +
#include <Adafruit_MotorShield.h>
 +
#include "utility/Adafruit_PWMServoDriver.h"</nowiki>
 +
 +
=== Créer un objet Adafruit_MotorShield ===
 +
 +
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
 +
 +
=== Un objet Moteur Continu ===
 +
En anglais, un moteur à courant continu se dit "DC motor", d'où le nom des objects et méthodes.
 +
 +
Request the DC motor from the Adafruit_MotorShield:
 +
 +
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
 +
 +
with '''getMotor(port#)'''.
 +
 +
Port# is which port it is connected to. If you're using M1 its '''1''', M2 use '''2''', M3 use '''3''' and M4 use '''4'''
 +
 +
=== Connecter le moteur au controleur ===
 +
In your setup() function, call 'begin()" on the Adafruit_MotorShield object:
 +
 +
AFMS.begin();
 +
 +
=== Initialiser la vitesse ===
 +
En anglais, la vitesse se dit "''Speed''" d'où le nom de la fonction.
 +
 +
Cette fonction permet d'initialiser la vitesse par défaut du moteur (celle qui sera utilisée lorsque vous lui demanderez de tourner).
 +
 +
Set the speed of the motor using '''setSpeed(speed)''' where the speed ranges from 0 (stopped) to 255 (full speed). You can set the speed whenever you want.
 +
 +
myMotor->setSpeed(100);
 +
 +
=== Faire fonctionner le moteur ===
 +
En anglais "''run''" signifie courir mais convient à toute opération à exécuter (à ''faire avancer''). D'où le
 +
 +
To run the motor, call '''run(direction)''' where direction is '''FORWARD''' (avant), '''BACKWARD''' (arrière) ou '''RELEASE''' (relaché, inactif). Of course, the Arduino doesn't actually know if the motor is 'forward' or 'backward', so if you want to change which way it thinks is forward, simply swap the two wires from the motor to the shield.
 +
 +
myMotor->run(FORWARD);
  
 
{{Adafruit Motor Shield V2-TRAILER}}
 
{{Adafruit Motor Shield V2-TRAILER}}

Version du 3 janvier 2014 à 11:59


MCHobby investit du temps et de l'argent dans la réalisation de traduction et/ou documentation. C'est un travail long et fastidieux réalisé dans l'esprit Open-Source... donc gratuit et librement accessible.
SI vous aimez nos traductions et documentations ALORS aidez nous à en produire plus en achetant vos produits chez MCHobby.

Intro

Motor Shield V2-Logiciel-01.jpg

DC motors are used for all sort of robotic projects.

The motor shield can drive up to 4 DC motors bi-directionally. That means they can be driven forwards and backwards. The speed can also be varied at 0.5% increments using the high-quality built in PWM. This means the speed is very smooth and won't vary!

Note that the H-bridge chip is not meant for driving continuous loads over 1.2A or motors that peak over 3A, so this is for small motors. Check the datasheet for information about the motor to verify its OK!

Connecter les moteurs

To connect a motor, simply solder two wires to the terminals and then connect them to either the M1, M2, M3, or M4. Then follow these steps in your sketch

Programmation

Inclure les bibliothèques

Make sure you #include the required libraries

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"

Créer un objet Adafruit_MotorShield

Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 

Un objet Moteur Continu

En anglais, un moteur à courant continu se dit "DC motor", d'où le nom des objects et méthodes.

Request the DC motor from the Adafruit_MotorShield:

Adafruit_DCMotor *myMotor = AFMS.getMotor(1);

with getMotor(port#).

Port# is which port it is connected to. If you're using M1 its 1, M2 use 2, M3 use 3 and M4 use 4

Connecter le moteur au controleur

In your setup() function, call 'begin()" on the Adafruit_MotorShield object:

AFMS.begin();

Initialiser la vitesse

En anglais, la vitesse se dit "Speed" d'où le nom de la fonction.

Cette fonction permet d'initialiser la vitesse par défaut du moteur (celle qui sera utilisée lorsque vous lui demanderez de tourner).

Set the speed of the motor using setSpeed(speed) where the speed ranges from 0 (stopped) to 255 (full speed). You can set the speed whenever you want.

myMotor->setSpeed(100); 

Faire fonctionner le moteur

En anglais "run" signifie courir mais convient à toute opération à exécuter (à faire avancer). D'où le

To run the motor, call run(direction) where direction is FORWARD (avant), BACKWARD (arrière) ou RELEASE (relaché, inactif). Of course, the Arduino doesn't actually know if the motor is 'forward' or 'backward', so if you want to change which way it thinks is forward, simply swap the two wires from the motor to the shield.

myMotor->run(FORWARD);

Source: Adafruit Motor Shield V2 for Arduino créé par LadyAda pour AdaFruit Industries. Crédit [www.adafruit.com AdaFruit Industries]

Traduit par Meurisse D. pour MCHobby.be

Nos remerciements à Mr Pierre M. pour ses suggestions de correction.

Traduit avec l'autorisation d'AdaFruit Industries - Translated with the permission from Adafruit Industries - www.adafruit.com

Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : «  Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.

L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.