Modifications

Sauter à la navigation Sauter à la recherche
167 octets ajoutés ,  19 avril 2015 à 11:53
Ligne 78 : Ligne 78 :  
If using a battery to power the pyboard and run servo motors, make sure it is not greater than 6V, since this is the maximum voltage most servo motors can take. (Some motors take only up to 4.8V, so check what type you are using.)
 
If using a battery to power the pyboard and run servo motors, make sure it is not greater than 6V, since this is the maximum voltage most servo motors can take. (Some motors take only up to 4.8V, so check what type you are using.)
   −
== Commander le Servo ==
+
== Commander un servo-moteur ==
 
Plug in a servo to position 1 (the one with pin X1) and create a servo object using:
 
Plug in a servo to position 1 (the one with pin X1) and create a servo object using:
   Ligne 99 : Ligne 99 :  
  <nowiki>>>> servo1.angle(50, 1000)</nowiki>
 
  <nowiki>>>> servo1.angle(50, 1000)</nowiki>
   −
This command will return straight away and the servo will continue to move to the desired angle, and stop when it gets there. You can use this feature as a speed control, or to synchronise 2 or more servo motors. If we have another servo motor (<nowiki>1=servo2 = pyb.Servo(2)}}) then we can do
+
This command will return straight away and the servo will continue to move to the desired angle, and stop when it gets there. You can use this feature as a speed control, or to synchronise 2 or more servo motors. If we have another servo motor ({{fname|1=servo2 = pyb.Servo(2)}}) then we can do
    
  <nowiki>>>> servo1.angle(-45, 2000); servo2.angle(60, 2000)</nowiki>
 
  <nowiki>>>> servo1.angle(-45, 2000); servo2.angle(60, 2000)</nowiki>
Ligne 108 : Ligne 108 :  
1.2. Continuous rotation servos
 
1.2. Continuous rotation servos
    +
== Commander servo à rotation continue ==
 
So far we have been using standard servos that move to a specific angle and stay at that angle. These servo motors are useful to create joints of a robot, or things like pan-tilt mechanisms. Internally, the motor has a variable resistor (potentiometer) which measures the current angle and applies power to the motor proportional to how far it is from the desired angle. The desired angle is set by the width of a high-pulse on the servo signal wire. A pulse width of 1500 microsecond corresponds to the centre position (0 degrees). The pulses are sent at 50 Hz, ie 50 pulses per second.
 
So far we have been using standard servos that move to a specific angle and stay at that angle. These servo motors are useful to create joints of a robot, or things like pan-tilt mechanisms. Internally, the motor has a variable resistor (potentiometer) which measures the current angle and applies power to the motor proportional to how far it is from the desired angle. The desired angle is set by the width of a high-pulse on the servo signal wire. A pulse width of 1500 microsecond corresponds to the centre position (0 degrees). The pulses are sent at 50 Hz, ie 50 pulses per second.
    
You can also get continuous rotation servo motors which turn continuously clockwise or counterclockwise. The direction and speed of rotation is set by the pulse width on the signal wire. A pulse width of 1500 microseconds corresponds to a stopped motor. A pulse width smaller or larger than this means rotate one way or the other, at a given speed.
 
You can also get continuous rotation servo motors which turn continuously clockwise or counterclockwise. The direction and speed of rotation is set by the pulse width on the signal wire. A pulse width of 1500 microseconds corresponds to a stopped motor. A pulse width smaller or larger than this means rotate one way or the other, at a given speed.
   −
On the pyboard, the servo object for a continuous rotation motor is the same as before. In fact, using angle you can set the speed. But to make it easier to understand what is intended, there is another method called speed which sets the speed:
+
On the pyboard, the servo object for a continuous rotation motor is the same as before. In fact, using {{fname|angle}} you can set the speed. But to make it easier to understand what is intended, there is another method called {{fname|speed}} which sets the speed:
    
  <nowiki>>>> servo1.speed(30)</nowiki>
 
  <nowiki>>>> servo1.speed(30)</nowiki>
   −
speed has the same functionality as angle: you can get the speed, set it, and set it with a time to reach the final speed.
+
{{fname|speed}} has the same functionality as {{fname|angle}}: you can get the speed, set it, and set it with a time to reach the final speed.
    
  <nowiki>>>> servo1.speed()
 
  <nowiki>>>> servo1.speed()
Ligne 127 : Ligne 128 :  
A servo speed of 100 (or -100) is considered maximum speed, but actually you can go a bit faster than that, depending on the particular motor.
 
A servo speed of 100 (or -100) is considered maximum speed, but actually you can go a bit faster than that, depending on the particular motor.
   −
The only difference between the angle and speed methods (apart from the name) is the way the input numbers (angle or speed) are converted to a pulse width.
+
The only difference between the {{fname|angle}} and {{fname|speed}} methods (apart from the name) is the way the input numbers (angle or speed) are converted to a pulse width.
1.3. Calibration
      +
== Calibration ==
 
The conversion from angle or speed to pulse width is done by the servo object using its calibration values. To get the current calibration, use
 
The conversion from angle or speed to pulse width is done by the servo object using its calibration values. To get the current calibration, use
   Ligne 139 : Ligne 140 :  
* Maximum pulse width; the largest pulse width that the servo accepts.
 
* Maximum pulse width; the largest pulse width that the servo accepts.
 
* Centre pulse width; the pulse width that puts the servo at 0 degrees or 0 speed.
 
* Centre pulse width; the pulse width that puts the servo at 0 degrees or 0 speed.
* The pulse width corresponding to 90 degrees. This sets the conversion in the method angle of angle to pulse width.
+
* The pulse width corresponding to 90 degrees. This sets the conversion in the method {{fname|angle}} of angle to pulse width.
* The pulse width corresponding to a speed of 100. This sets the conversion in the method speed of speed to pulse width.
+
* The pulse width corresponding to a speed of 100. This sets the conversion in the method {{fname|speed}} of speed to pulse width.
    
You can recalibrate the servo (change its default values) by using:
 
You can recalibrate the servo (change its default values) by using:
Ligne 147 : Ligne 148 :     
Of course, you would change the above values to suit your particular servo motor.
 
Of course, you would change the above values to suit your particular servo motor.
 +
 +
{{MicroPython-Hack-Servo-TRAILER}}
    
== Servo à rotation continue ==
 
== Servo à rotation continue ==
29 836

modifications

Menu de navigation