Part 1
요약·해설
Pulse width, 20 ms period, 정확한 wiring과 bbc_microbit build·flash 절차를 설명합니다.
0° → 180°
700 → 2300 μs
P19 · SCL
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
92164394D53688BA987EB35AD3E6BE73A2837F4E4BC8973121380F0FD98771AC
.. zephyr:code-sample:: servo-motor
:name: Servomotor
:relevant-api: pwm_interface
Drive a servomotor using the PWM API.
Overview
********
This is a sample app which drives a servomotor using the :ref:`PWM API <pwm_api>`.
The sample rotates a servomotor back and forth in the 180 degree range with a
PWM control signal.
This app is targeted for servomotor ROB-09065. The corresponding PWM pulse
widths for a 0 to 180 degree range are 700 to 2300 microseconds, respectively.
Different servomotors may require different PWM pulse widths, and you may need
to modify the source code if you are using a different servomotor.
Requirements
************
The sample requires a servomotor whose signal pin is connected to a pin driven
by PWM. The servo must be defined in Devicetree using the ``pwm-servo``
compatible (part of the sample) and setting its node label to ``servo``. You
will need to do something like this:
.. code-block:: devicetree
/ {
servo: servo {
compatible = "pwm-servo";
pwms = <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
min-pulse = <PWM_USEC(700)>;
max-pulse = <PWM_USEC(2500)>;
};
};
Note that a commonly used period value is 20 ms. See
:zephyr_file:`samples/basic/servo_motor/boards/bbc_microbit.overlay` for an
example.
Wiring
******
BBC micro:bit
=============
You will need to connect the motor's red wire to external 5V, the black wire to
ground and the white wire to the SCL pin, i.e. pin P19 on the edge connector.
Building and Running
********************
The sample has a devicetree overlay for the :ref:`bbc_microbit`.
This sample can be built for multiple boards, in this example we will build it
for the bbc_microbit board:
.. zephyr-app-commands::
:zephyr-app: samples/basic/servo_motor
:board: bbc_microbit
:goals: build flash
:compact:
Part 3
한국어 전문 번역
개요
이 sample application은 PWM API를 사용해 servomotor를 구동합니다.
PWM control signal로 servomotor를 180도 범위 안에서 앞뒤로 회전시킵니다.
이 application은 ROB-09065 servomotor를 대상으로 합니다. 0도와 180도에 대응하는 PWM pulse width는 각각 700 microseconds와 2300 microseconds입니다. 다른 servomotor는 서로 다른 pulse width가 필요할 수 있으므로, 다른 제품을 사용한다면 source code를 수정해야 할 수 있습니다.
요구사항
Signal pin이 PWM으로 구동되는 pin에 연결된 servomotor가 필요합니다. Servo는 sample에 포함된 pwm-servo compatible을 사용하고 node label을 servo로 설정해 Devicetree에 정의해야 합니다. 다음과 같은 정의가 필요합니다.
/ {
servo: servo {
compatible = "pwm-servo";
pwms = <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
min-pulse = <PWM_USEC(700)>;
max-pulse = <PWM_USEC(2500)>;
};
};
흔히 사용하는 period 값은 20 ms입니다. 예제는 samples/basic/servo_motor/boards/bbc_microbit.overlay를 참조하십시오. 공식 문서 본문은 ROB-09065의 180도 pulse width를 2300 microseconds라고 설명하지만, 위 Devicetree 예제의 max-pulse 값은 2500 microseconds로 제시합니다.
배선
BBC micro:bit
Motor의 빨간 wire는 외부 5V에, 검은 wire는 ground에, 흰 wire는 SCL pin, 즉 edge connector의 P19 pin에 연결합니다.
Build와 실행
이 sample에는 bbc_microbit용 Devicetree overlay가 있습니다.
여러 board용으로 build할 수 있으며, 다음 예에서는 bbc_microbit board용으로 build하고 flash합니다.
west build -b bbc_microbit samples/basic/servo_motor
west flash
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.