Modifications

Sauter à la navigation Sauter à la recherche
2 899 octets supprimés ,  4 octobre 2015 à 19:45
aucun résumé de modification
Ligne 177 : Ligne 177 :     
Bien entendu, vous devriez uniquement modifier ces valeurs a un servo moteur particulier.
 
Bien entendu, vous devriez uniquement modifier ces valeurs a un servo moteur particulier.
  −
{{MicroPython-Hack-Servo-TRAILER}}
  −
  −
== 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.
  −
  −
  −
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 {{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:
  −
  −
>>> servo1.speed(30)
  −
  −
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.
  −
  −
>>> servo1.speed()
  −
30
  −
>>> servo1.speed(-20)
  −
>>> servo1.speed(0, 2000)
  −
  −
The final command above will set the motor to stop, but take 2 seconds to do it. This is essentially a control over the acceleration of the continuous servo.
  −
  −
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.
  −
1.3. 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
  −
  −
>>> servo1.calibration()
  −
(640, 2420, 1500, 2470, 2200)
  −
  −
There are 5 numbers here, which have meaning:
  −
  −
    Minimum pulse width; the smallest 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.
  −
    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 a speed of 100. This sets the conversion in the method speed of speed to pulse width.
  −
  −
You can recalibrate the servo (change its default values) by using:
  −
  −
>>> servo1.calibration(700, 2400, 1510, 2500, 2000)
  −
  −
Of course, you would change the above values to suit your particular servo motor.
  −
      
{{MicroPython-Hack-Servo-TRAILER}}
 
{{MicroPython-Hack-Servo-TRAILER}}
29 837

modifications

Menu de navigation