Part 1
요약·해설
qdec0 alias, pinctrl·filter·counts-per-revolution과 출력 차이를 설명합니다.
Mechanical encoder
TIM3 · PA6/PA7
Position degrees
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
2D338156B5FB17B37353CBA300F2AD34D35C2474F53979BBF0AED7A491303EF1
.. _qdec_sensor:
Quadrature Decoder Sensor
#########################
Overview
********
This sample reads the value of the counter which has been configured in
quadrature decoder mode.
It requires:
* an external mechanical encoder
* pin to be properly configured in the device tree
Building and Running
********************
In order to run this sample you need to:
* enable the quadrature decoder device in your board's DT file or board overlay
* add a new alias property named ``qdec0`` and make it point to the decoder
device you just enabled
For example, here's how the overlay file of an STM32F401 board looks like when
using decoder from TIM3 through pins PA6 and PA7:
.. code-block:: dts
/ {
aliases {
qdec0 = &qdec;
};
};
&timers3 {
status = "okay";
qdec: qdec {
status = "okay";
pinctrl-0 = <&tim3_ch1_pa6 &tim3_ch2_pa7>;
pinctrl-names = "default";
st,input-polarity-inverted;
st,input-filter-level = <FDIV32_N8>;
st,counts-per-revolution = <16>;
};
};
Sample Output
=============
Once the MCU is started it prints the counter value every second on the
console
.. code-block:: console
Quadrature decoder sensor test
Position = 0 degrees
Position = 15 degrees
Position = 30 degrees
...
Of course the read value changes once the user manually rotates the mechanical
encoder.
.. note::
The reported increment/decrement can be larger/smaller than the one shown
in the above example. This depends on the mechanical encoder being used and
``st,counts-per-revolution`` value.
Part 3
한국어 전문 번역
개요
이 sample은 quadrature-decoder mode로 구성한 counter 값을 읽습니다.
외부 mechanical encoder가 필요하며 관련 pin을 Devicetree에 올바르게 구성해야 합니다.
빌드 및 실행
Sample을 실행하려면 board DT file 또는 board overlay에서 quadrature-decoder device를 활성화하고, qdec0이라는 새 alias property가 방금 활성화한 decoder device를 가리키도록 해야 합니다.
다음은 STM32F401 board에서 PA6·PA7 pin을 통해 TIM3 decoder를 사용할 때의 overlay 예입니다.
/ {
aliases {
qdec0 = &qdec;
};
};
&timers3 {
status = "okay";
qdec: qdec {
status = "okay";
pinctrl-0 = <&tim3_ch1_pa6 &tim3_ch2_pa7>;
pinctrl-names = "default";
st,input-polarity-inverted;
st,input-filter-level = <FDIV32_N8>;
st,counts-per-revolution = <16>;
};
};
출력 예
MCU가 시작되면 counter value를 매초 console에 출력합니다.
Quadrature decoder sensor test
Position = 0 degrees
Position = 15 degrees
Position = 30 degrees
...
사용자가 mechanical encoder를 직접 돌리면 읽은 값이 바뀝니다. 보고되는 증가·감소량은 예시보다 크거나 작을 수 있으며, 사용하는 mechanical encoder와 st,counts-per-revolution 값에 따라 달라집니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.