Modifications

Sauter à la navigation Sauter à la recherche
Ligne 67 : Ligne 67 :     
== Créer un objet moteur pas-à-pas ==
 
== Créer un objet moteur pas-à-pas ==
Nous disposons maintenant d'un objet MotorHat OK now that you have the motor HAT object, note that each HAT can control up to 2 steppers. And you can have multiple HATs!
+
Nous disposons maintenant d'un objet MotorHAT pouvant contrôer deux moteurs pas-à-pas. Il est possible d'avoir plusieurs HAT moteurs branchés sur le Raspberry-Pi!
   −
To create the actual Stepper motor object, you can request it from the MotorHAT object you created above with '''getStepper(steps, portnum)''' where steps is how many steps per rotation for the stepper motor (usually some number between 35 - 200) ith a value between 1 and 2. Port #1 is '''M1''' and '''M2''', port #2 is '''M3''' and '''M4'''
+
L'objet MotorHAT expose une méthode {{fname|getStepper()}} permettant de créer un objet "moteur pas-à-pas" (dit "Stepper" en anglais) permettant de contrôler facilement celui-ci.
 +
 
 +
La méthode '''getStepper(steps, portnum)''' accepte deux paramètres :
 +
* '''steps''' - indique le nombre de pas nécessaires pour faire une révolution complète du moteur pas-à-pas (habituellement entre 35 et 200).
 +
* '''portnum''' - indique le port à utiliser avec la valeur 1 et 2. Port #1 correspond à '''M1''' et '''M2''', port #2 correspond à '''M3''' et '''M4'''
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
myStepper = mh.getStepper(200, 1)       # 200 steps/rev, motor port #1
+
# 200 pas par révolution, moteur sur port 1
 +
myStepper = mh.getStepper(200, 1)
 
</syntaxhighlight>
 
</syntaxhighlight>
   −
Next, if you are planning to use the 'blocking' '''step()''' function to take multiple steps at once you can set the speed in RPM. If you end up using oneStep() then this step isn't necessary. Also, the speed is approximate as the Raspberry Pi can't do precision delays the way an Arduino would. Anyways, we wanted to keep the Arduino and Pi versions of this library similar so we kept '''setSpeed()''' in:
+
Si vous envisagez utilise la fonction 'bloquante' '''step()''' pour avancer de plusieurs pas en une fois alors vous pouvez fixer la vitesse en Rotation Par Minute.  
 +
 
 +
A contrario, si vous voulez utiliser utiliser la fonction '''oneStep()''' alors l'étape suivante n'est pas nécessaire.  
 +
 
 +
A noter que la vitesse est approximative car le Raspberry-Pi n'est pas capable de gérer les délais avec la même précision qu'un Arduino. Comme Adafruit voulait des bibliothèques Arduino et Pi similaires, ils ont maintenu la fonction '''setSpeed()''' dans la bibliothèque Pi:
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
myStepper.setSpeed(30)                 # 30 RPM
+
myStepper.setSpeed(30) # fixer la vitesse à 30 RPM
 
</syntaxhighlight>
 
</syntaxhighlight>
  
29 922

modifications

Menu de navigation