Part 1
요약·해설
FIR의 1/N coefficient, arm_fir_q31(), Cortex 최적화와 전체 출력 예제를 보존합니다.
32 samples
10 taps
arm_fir_q31()
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
D1E8C55BA6B5CD09AB5EF4CAC6702B0E861E8D2F88E955E2CFBCCFB3107E6D91
.. zephyr:code-sample:: cmsis-dsp-moving-average
:name: CMSIS-DSP moving average
Use the CMSIS-DSP library to calculate the moving average of a signal.
Overview
********
This sample demonstrates how to use the CMSIS-DSP library to calculate the moving average of a
signal.
It can be run on any board supported in Zephyr, but note that CMSIS-DSP is specifically optimized
for ARM Cortex-A and Cortex-M processors.
A **moving average** filter is a common method used for smoothing noisy data. It can be implemented
as a finite impulse response (FIR) filter where the filter coefficients are all equal to 1/N, where
N is the number of "taps" (i.e. the size of the moving average window).
The sample uses a very simple input signal of 32 samples, and computes the moving average using a
"window" of 10 samples. The resulting output is computed in one single call to the ``arm_fir_q31()``
CMSIS-DSP function, and displayed on the console.
.. note::
In order to allow an easy comparison of the efficiency of the CMSIS-DSP library when used on ARM
processors vs. other architectures, the sample outputs the time and number of cycles it took to
compute the moving average.
Requirements
************
CMSIS-DSP is an optional module and needs to be added explicitly to your Zephyr workspace:
.. code-block:: shell
west config manifest.project-filter -- +cmsis-dsp
west update cmsis-dsp
Building and Running
*********************
The demo can be built as follows:
.. zephyr-app-commands::
:zephyr-app: samples/modules/cmsis-dsp/moving_average
:host-os: unix
:board: qemu_cortex_m0
:goals: run
:compact:
The sample will output the number of cycles it took to compute the moving averages, as well as the
computed average for each 10-sample long window of the input signal.
.. code-block:: console
*** Booting Zephyr OS build v3.6.0-224-gb55824751d6c ***
Time: 244 us (244 cycles)
Input[00]: 0 0 0 0 0 0 0 0 0 0 | Output[00]: 0.00
Input[01]: 0 0 0 0 0 0 0 0 0 1 | Output[01]: 0.10
Input[02]: 0 0 0 0 0 0 0 0 1 2 | Output[02]: 0.30
Input[03]: 0 0 0 0 0 0 0 1 2 3 | Output[03]: 0.60
...
Input[30]: 21 22 23 24 25 26 27 28 29 30 | Output[30]: 25.50
Input[31]: 22 23 24 25 26 27 28 29 30 31 | Output[31]: 26.50
Part 3
한국어 전문 번역
개요
이 sample은 CMSIS-DSP library를 사용해 signal의 moving average를 계산하는 방법을 보여줍니다.
Zephyr가 지원하는 모든 board에서 실행할 수 있지만 CMSIS-DSP는 ARM Cortex-A와 Cortex-M processor에 맞게 특별히 최적화되어 있습니다.
Moving average filter는 noisy data를 부드럽게 만드는 일반적인 방법입니다. Filter coefficient가 모두 1/N인 finite impulse response(FIR) filter로 구현할 수 있으며, 여기서 N은 tap 수, 즉 moving-average window 크기입니다.
Sample은 32개 sample로 구성된 매우 단순한 input signal과 10개 sample 크기의 window를 사용합니다. 결과 output은 CMSIS-DSP의 arm_fir_q31() function을 한 번 호출해 계산하고 console에 표시합니다.
ARM processor와 다른 architecture에서 CMSIS-DSP library의 효율을 쉽게 비교할 수 있도록 moving average 계산에 걸린 시간과 cycle 수도 출력합니다.
요구 사항
CMSIS-DSP는 optional module이므로 Zephyr workspace에 명시적으로 추가해야 합니다.
west config manifest.project-filter -- +cmsis-dsp
west update cmsis-dsp
Build와 실행
다음과 같이 demo를 build하고 실행할 수 있습니다.
west build -b qemu_cortex_m0 samples/modules/cmsis-dsp/moving_average
west build -t run
Sample은 moving average 계산에 사용된 cycle 수와 input signal의 10-sample window마다 계산한 평균을 출력합니다.
*** Booting Zephyr OS build v3.6.0-224-gb55824751d6c ***
Time: 244 us (244 cycles)
Input[00]: 0 0 0 0 0 0 0 0 0 0 | Output[00]: 0.00
Input[01]: 0 0 0 0 0 0 0 0 0 1 | Output[01]: 0.10
Input[02]: 0 0 0 0 0 0 0 0 1 2 | Output[02]: 0.30
Input[03]: 0 0 0 0 0 0 0 1 2 3 | Output[03]: 0.60
...
Input[30]: 21 22 23 24 25 26 27 28 29 30 | Output[30]: 25.50
Input[31]: 22 23 24 25 26 27 28 29 30 31 | Output[31]: 26.50
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.