Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
ddbcc795
Commit
ddbcc795
authored
10 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
docs: Add quickref info about Servo; improve Servo docs.
parent
ce5b5caf
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/library/pyb.Servo.rst
+54
-13
54 additions, 13 deletions
docs/library/pyb.Servo.rst
docs/library/pyb.rst
+1
-0
1 addition, 0 deletions
docs/library/pyb.rst
docs/quickref.rst
+12
-0
12 additions, 0 deletions
docs/quickref.rst
with
67 additions
and
13 deletions
docs/library/pyb.Servo.rst
+
54
−
13
View file @
ddbcc795
.. _pyb.Servo:
class Servo -- 3-wire hobby servo driver
========================================
Servo controls standard hobby servos with 3-wires (ground, power, signal).
Servo objects control standard hobby servo motors with 3-wires (ground, power,
signal). There are 4 positions on the pyboard where these motors can be plugged
in: pins X1 through X4 are the signal pins, and next to them are 4 sets of power
and ground pins.
Example usage::
import pyb
s1 = pyb.Servo(1) # create a servo object on position X1
s2 = pyb.Servo(2) # create a servo object on position X2
s1.angle(45) # move servo 1 to 45 degrees
s2.angle(0) # move servo 2 to 0 degrees
# move servo1 and servo2 synchronously, taking 1500ms
s1.angle(-60, 1500)
s2.angle(30, 1500)
.. note:: The Servo objects use Timer(5) to produce the PWM output. You can
use Timer(5) for Servo control, or your own purposes, but not both at the
same time.
Constructors
------------
.. class:: pyb.Servo(id)
Create a servo object. ``id`` is 1-4.
Create a servo object. ``id`` is 1-4
, and corresponds to pins X1 through X4
.
Methods
...
...
@@ -17,22 +39,41 @@ Methods
.. method:: servo.angle([angle, time=0])
Get or set the angle of the servo.
If no arguments are given, this function returns the current angle.
If arguments are given, this function sets the angle of the servo:
- ``angle`` is the angle to move to in degrees.
- ``time`` is the number of milliseconds to take to get to the specified angle.
- ``time`` is the number of milliseconds to take to get to the specified
angle. If omitted, then the servo moves as quickly as possible to its
new position.
.. method:: servo.calibration([pulse_min, pulse_max, pulse_centre, [pulse_angle_90, pulse_speed_100]])
.. method:: servo.speed([speed, time=0])
If no arguments are given, this function returns the current speed.
Get or set the calibration of the servo timing.
If arguments are given, this function sets the speed of the servo:
- ``speed`` is the speed to change to, between -100 and 100.
- ``time`` is the number of milliseconds to take to get to the specified
speed. If omitted, then the servo accelerates as quickly as possible.
.. method:: servo.pulse_width([value])
Get or set the pulse width in milliseconds.
If no arguments are given, this function returns the current raw pulse-width
value.
.. method:: servo.speed([speed, time=0])
If an argument is given, this function sets the raw pulse-width value.
.. method:: servo.calibration([pulse_min, pulse_max, pulse_centre, [pulse_angle_90, pulse_speed_100]])
If no arguments are given, this function returns the current calibration
data, as a 5-tuple.
If arguments are given, this function sets the timing calibration:
Get or set the speed of a continuous rotation servo.
- ``speed`` is the speed to move to change to, between -100 and 100.
- ``time`` is the number of milliseconds to take to get to the specified speed.
- ``pulse_min`` is the minimum allowed pulse width.
- ``pulse_max`` is the maximum allowed pulse width.
- ``pulse_centre`` is the pulse width corresponding to the centre/zero position.
- ``pulse_angle_90`` is the pulse width corresponding to 90 degrees.
- ``pulse_speed_100`` is the pulse width corresponding to a speed of 100.
This diff is collapsed.
Click to expand it.
docs/library/pyb.rst
+
1
−
0
View file @
ddbcc795
...
...
@@ -98,6 +98,7 @@ Power related functions
If given no arguments, returns a tuple of clock frequencies:
(sysclk, hclk, pclk1, pclk2).
These correspond to:
- sysclk: frequency of the CPU
- hclk: frequency of the AHB bus, core memory and DMA
- pclk1: frequency of the APB1 bus
...
...
This diff is collapsed.
Click to expand it.
docs/quickref.rst
+
12
−
0
View file @
ddbcc795
...
...
@@ -48,6 +48,18 @@ See :ref:`pyb.Pin <pyb.Pin>`. ::
p_in = Pin('X2', Pin.IN, Pin.PULL_UP)
p_in.value() # get value, 0 or 1
Servo control
-------------
See :ref:`pyb.Servo <pyb.Servo>`. ::
from pyb import Servo
s1 = Servo(1) # servo on position 1 (X1, VIN, GND)
s1.angle(45) # move to 45 degrees
s1.angle(-60, 1500) # move to -60 degrees in 1500ms
s1.speed(50) # for continuous rotation servos
External interrupts
-------------------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment