Posts

Showing posts with the label ARM

CMSIS Biquad Cascade IIR Filter + Iowa Hills IIR Filter Design

Image
You are looking at CMSIS IIR Filters ( https://www.keil.com/pack/doc/CMSIS/DSP/html/group__BiquadCascadeDF1.html ), and don't know how to use it? Don't worry, this example will clearly help you. The first thing that you need to know is that Biquad Cascade DF1 use this transfer function to do filtering. y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] - a1 * y[n-1] - a2 * y[n-2] It is hard to understand how this does filtering, especially if you looking at it in the time domain. In short this transfer function use current input(x[n]), and two last input(x[n-1], x[n-2]) and output (y[n-1], y[n-2]). Each new input function calculates new output and stores all the values. That is all that this filter does. The hardest part is to calculate coefficients b0, b1, b2, a1, a2, that is where Iowa Hills IIR  Filter Design jumps in. In this example, I'll do the band-pass filter for 1 Hz. In the image below you can see, what I selected at Iowa Hills IIR  Filter Design. N...

ARM sinus lookup tables 5x faster than math.h - TM4C123GXL Cortex M4F

Image
Lately, I was working with IIR filter so in CMSIS repo I saw look-up table with sinus value. I was wondering how much faster it works then math.h sinus function. The name of the function which uses a lookup table is arm_sin_f32() which is part of  arm_math.h Lets first compare results calculated with the lookup table and math.h sin function. Result2 are from the lookup table (arm_sin_f32() -> arm_math.h) and result1 are from sinus function (sin() -> math.h). From results is seen that after decimal point 4-5 digits are similar so take care with that.  I have done an iteration of 100 000 calculation and I was measuring the time needed for math.h sin and got 9726 [ms], and for arm_math.h 2006 [ms] which is almost 5x time faster.  In the photo below I added sinus wave for both calculations. Blue is result1 and red is result2. You can see they overlap.  You can check the code on the link .