STM32F1 CMSIS DSP Filtering Functions

Started by tha, July 26, 2021, 07:18:31 AM

Previous topic - Next topic

tha

Fixed-Point Behavior

ต้องใช้ความระมัดระวังเมื่อใช้ the Q15 and Q31 versions ของ the Biquad Cascade filter functions. ประเด็นต่อไปนี้ต้องถูกพิจารณา :

     •    Scaling of coefficients
     •    Filter gain
     •    Overflow and saturation

Scaling of coefficients: Filter coefficients ถูกแสดงเป็น fractional values และ coefficients ถูกจำกัดอยู่ในย่าน [-1 +1). The fixed-point functions มี an additional scaling parameter postShift ซึ่งยอมให้ the filter coefficients เกินย่าน [+1 -1). ที่ the output ของ the filter's accumulator เป็น a shift register ซึ่งเลื่อนผลลัพธ์ไป postShift bits.

             

สิ่งนี้จะปรับขนาดอย่างเป็นหลัก the filter coefficients โดย 2^postShift. ตัวอย่างเช่น, การหา the coefficients

{1.5, -0.8, 1.2, 1.6, -0.9}

เซ็ต the pCoeffs array เป็น:

   {0.75, -0.4, 0.6, 0.8, -0.45}

และเซ็ต postShift=1

Filter gain: The frequency response ของ a Biquad filter คือ a function ของ coefficients ของมัน. มันเป็นไปได้สำหรับ the gain ที่ผ่าน the filter เกิน 1.0 หมายความว่า the filter จะเพิ่ม the amplitude ของ certain frequencies. นี้หมายความว่า an input signal ที่มี amplitude < 1.0 อาจให้ผลใน an output > 1.0 และเหล่านี้ถูกทำให้อิ่มตัวหรือโอเวอร์โฟวส์ตามการจัดให้ของ the filter. เพื่อหลีกเลี่ยง behavior นี้ the filter ต้องการถูกปรับขนาดลงเพื่อว่า peak gain ของมัน < 1.0 หรือ the input signal ต้องถูกปรับขนาดลงเพื่อว่าการรวมของ input and filter ไม่โอเวอร์โฟวส์

Overflow and saturation: สำหรับ Q15 and Q31 versions, จะถูกอธิบายแยกต่างหากเป็นส่วนหนึ่งของ the function specific documentation ข้างล่าง

tha


tha



Scaling and Overflow Behavior:

fast version นี้ใช้ a 32-bit accumulator ที่มี 2.30 format. The accumulator รักษา full precision ของ the intermediate multiplication results แต่จัดให้มีเฉพาะ a single guard bit. ดังนั้น, ถ้า the accumulator result โอเวอร์โฟวส์มันจะพันรอบและบิดเบือน the result. เพื่อหลีกเลี่ยง overflows อย่างสมบูรณ์ the input signal ต้องถูกลดขนาดลงสอง bits และอยู่ในย่าน [-0.25 +0.25). The 2.30 accumulator จากนั้นถูกเลื่อนไป postShift bits และ the result ถูกตัดเป็น 1.15 format โดยการทิ้ง the low 16 bits.             

อ้างอิงถึง the function arm_biquad_cascade_df1_q15() สำหรับ a slower implementation ของฟังชั่นนี้ซึ่งใช้ 64-bit accumulation เพื่อหลีกเลี่ยง wrap around distortion. ทั้ง the slow and the fast versions ใช้ the same instance structure. ใช้ the function arm_biquad_cascade_df1_init_q15() เพื่อเริ่มต้น the filter structure.

References __PKHBT, __SIMD32, __SMLAD(), __SMUAD(), __SMUADX(), arm_biquad_casd_df1_inst_q15::numStages, arm_biquad_casd_df1_inst_q15::pCoeffs, arm_biquad_casd_df1_inst_q15::postShift, and arm_biquad_casd_df1_inst_q15::pState.