Modifications

Sauter à la navigation Sauter à la recherche
Ligne 120 : Ligne 120 :     
== step() - fonction bloquante ==
 
== step() - fonction bloquante ==
As you can see above, you can step mulitple steps at a time with '''step()'''
+
Comme vous pouvez le voir ci-dessus, vous pouvez faire des avances de plusieurs pas en une fois à l'aide de la fonction '''step()'''
   −
  step(number_de_pas, direction, type)
+
  step(numbre_de_pas, direction, type)
   −
Where ''nombre_de_pas'' is the number of steps to take, ''direction'' is either FORWARD or BACKWARD and ''type'' is SINGLE, DOUBLE, INTERLEAVE or MICROSTEP
+
Où :
 +
* '''nombre_de_pas''' est le nombre de pas à faire
 +
* '''direction''' indique le sens de rotation (FORWARD pour avant et BACKWARD pour l'arrière).
 +
* '''type''' est le type de pas SINGLE (''simple''), DOUBLE (''double''), INTERLEAVE (''entrelacé'') ou MICROSTEP (''micro-stepping'').
   −
{{ambox|text=Note that INTERLEAVE will move half the distance of SINGLE or DOUBLE because there are twice as many steps. And MICROSTEP will move 1/8 the distance because each microstep counts as a step!}}
+
{{ambox|text=Le type de pas entrelacé (''INTERLEAVE'') tournera l'axe de la moitié du type simple ou double pas (''SINGLE'' ou ''DOUBLE'') parce qu'il y a deux fois plus de pas en mode entrelacé. Le type de pas MICROSTEP tournera l'axe du 1/8 de rotation par rapport au pas simple ou double parce que chaque micro-pas compte pour un pas et qu'il y en a 8x plus!}}
   −
This is the easiest way to move your stepper but is '''blocking''' - that means that the Python program is completely busy moving the motor. If you have two motors and you call these two procedures in a row:
+
Cette approche est l'approche la plus simple mais elle est également '''bloquante''' - cela signifie que le programme Python reste occupé pendant toute la phase de déplacement du moteur. Si vous avez deux moteurs et faites les appels suivants:
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
Ligne 135 : Ligne 138 :  
</syntaxhighlight>
 
</syntaxhighlight>
   −
Then the first stepper will move 100 steps, stop, and then the second stepper will start moving.
+
Alors le premier moteur se déplacera de 100 pas puis stopper. Ensuite seulement, le second moteur pas-à-pas entamera sa révolution de 100 pas.
   −
Chances are you'd like to have your motors moving at once!
+
Cette approche est intéressante si votre projet s'accommode qu'un seul moteur puisse fonctionner à fois!
   −
For that, you'll need to take advantage of Python's ability to multitask with threads which you can see in '''DualStepperTest.py'''
+
Si vous désirez faire fonctionner plusieurs moteurs pas-à-pas en même temps, il est possible d'exploiter le support multitâche de Python. L'exemple '''DualStepperTest.py''' exploite le support multitâche et utilise des threads pour faire fonctionner les deux moteurs en même temps.
   −
The key part of the DualStepperTest example code is that we define a function that will act as a 'wrapper' for the {{fname|step()}} procedure:
+
La partie importante de l'exemple '''DualStepperTest'''  est la définition d'une fonction qui agit comme un ''wrapper'' (surcouche) pour la fonction {{fname|step()}}:
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
 
       def stepper_worker(stepper, numsteps, direction, style):
 
       def stepper_worker(stepper, numsteps, direction, style):
#print("Steppin!")
+
#print("Faire des pas!")
 
stepper.step(numsteps, direction, style)
 
stepper.step(numsteps, direction, style)
#print("Done")
+
#print("Fait")
 
</syntaxhighlight>
 
</syntaxhighlight>
   −
We have some commented-out print statements in case you want to do some debugging.
+
Il y a quelques instructions d'affichage (''print'') pour le cas où vous voudriez faire du débogage.
   −
Then, whenever you want to make the first stepper move, you can call:
+
Ensuite, lorsque vous voulez faire tourner le premier moteur pas-à-pas, vous pouvez appeler:
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
Ligne 159 : Ligne 162 :  
</syntaxhighlight>
 
</syntaxhighlight>
   −
Which will spin up a background thread to move Stepper1 and will return immediately. You can then do the same with the second stepper:
+
Ce qui crée une tâche d'arrière plan (un ''thread'') pour faire tourner ''Stepper1'' et rend immédiatement la main au programme principal.  
 +
 
 +
Vous pouvez faire de même avec le second moteur pas-à-pas avec la ligne suivante:
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
Ligne 166 : Ligne 171 :  
</syntaxhighlight>
 
</syntaxhighlight>
   −
You can tell when the stepper is done moving because the stepper thread you created will 'die' - test it with '''st2.isAlive()''' or '''st2.isAlive()''' - if you get '''True''' that means the stepper is still moving.
+
Il est possible de savoir lorsque le moteur pas-à-pas à terminé sa rotation parce que le ''thread'' créé sera 'mort'. Il est possible de tester les thread avec '''st1.isAlive()''' (ou '''st2.isAlive()'''). Si vous obtenez la valeur '''True''' cela signifie que le moteur tourne (puisque le ''thread'' est toujours en cours d'exécution).
    
== oneStep() - fonction non bloquante ==
 
== oneStep() - fonction non bloquante ==
29 917

modifications

Menu de navigation