<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>biquad &#8211; ASN Home</title>
	<atom:link href="https://www.advsolned.com/tag/biquad/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.advsolned.com</link>
	<description>ASN home site</description>
	<lastBuildDate>Fri, 12 May 2023 14:39:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Linear phase IIR filters – analysis and design</title>
		<link>https://www.advsolned.com/linear-phase-iir-filters-analysis-design/</link>
		
		<dc:creator><![CDATA[Dr. Sanjeev Sarpal]]></dc:creator>
		<pubDate>Wed, 03 Jun 2020 08:24:39 +0000</pubDate>
				<category><![CDATA[ASN Filter Designer]]></category>
		<category><![CDATA[biomedical]]></category>
		<category><![CDATA[biquad]]></category>
		<category><![CDATA[ECG]]></category>
		<category><![CDATA[IIR]]></category>
		<category><![CDATA[IIR Biquad]]></category>
		<category><![CDATA[IoT]]></category>
		<category><![CDATA[linear phase]]></category>
		<guid isPermaLink="false">https://www.advsolned.com/?p=12722</guid>

					<description><![CDATA[<p>Although the design of FIR filters with linear phase is an easy task. This is certainly not true for IIR filters that usually have a highly non-linear phase response, especially around the filter’s cut-off frequencies. This article discusses the characteristics needed for a digital filter to have linear phase, and how an IIR filter’s passband [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.advsolned.com/linear-phase-iir-filters-analysis-design/">Linear phase IIR filters – analysis and design</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Although the design of FIR filters with linear phase is an easy task. This is <strong>certainly not true for IIR filters that usually have a highly non-linear phase response</strong>, especially around the filter’s cut-off frequencies. This article discusses the characteristics needed for a digital filter to have linear phase, and how an IIR filter’s passband phase can be modified in order to achieve linear phase using all-pass equalisation filters.</p>



<h2 class="wp-block-heading"><strong>Why do we need linear phase filters?</strong></h2>



<p class="wp-block-paragraph">Digital filters with linear phase have the advantage of delaying all frequency components by the same amount, i.e. they preserve the input signal’s phase relationships. This <strong>preservation of phase</strong> means that the filtered signal retains the shape of the original input signal. This characteristic is essential for audio applications as the signal shape is paramount for maintaining high fidelity in the filtered audio. Yet another application area that requires this, is ECG biomedical waveform analysis, as any artefacts introduced by the filter may be misinterpreted as heart anomalies.</p>



<p class="wp-block-paragraph">The following plot shows the filtering performance of a Chebyshev type I lowpass IIR on ECG data – input waveform (shown in blue) shifted by 10 samples (\(\small \Delta=10\)) to approximately compensate for the filter’s group delay. Notice that the filtered signal (shown in red) has attenuated, broadened and added oscillations around the ECG peak, which is undesirable.</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img fetchpriority="high" decoding="async" width="889" height="510" src="https://www.advsolned.com/wp-content/uploads/2020/06/iir_lpf.png" alt="" class="wp-image-12728" srcset="https://www.advsolned.com/wp-content/uploads/2020/06/iir_lpf.png 889w, https://www.advsolned.com/wp-content/uploads/2020/06/iir_lpf-300x172.png 300w, https://www.advsolned.com/wp-content/uploads/2020/06/iir_lpf-768x441.png 768w, https://www.advsolned.com/wp-content/uploads/2020/06/iir_lpf-705x404.png 705w, https://www.advsolned.com/wp-content/uploads/2020/06/iir_lpf-450x258.png 450w" sizes="(max-width: 889px) 100vw, 889px" /><figcaption><center><em>Figure 1: IIR lowpass filtering result with phase distortion</em></center></figcaption></figure></div>



<p class="wp-block-paragraph"><span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>In order for a digital filter to have linear phase, its impulse response must have conjugate-even or conjugate-odd symmetry about its midpoint. This is readily seen for an FIR filter,</p>



<center>\(\displaystyle
H(z)=\sum\limits_{k=0}^{L-1} b_k z^{-k}\tag{1}
\)</center>



<p class="wp-block-paragraph">With the following constraint on its coefficients,</p>



<center>\(\displaystyle
b_k=\pm\, b^{\ast}_{L-1-k}\tag{2}
\)</center>



<p class="wp-block-paragraph"><span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span>which leads to,</p>



<center>\(\displaystyle
z^{L-1}H(z) = \pm\, H^\ast (1/z^\ast)\tag{3}
\)</center>



<p class="wp-block-paragraph"><span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span>Analysing Eqn. 3, we see that roots (zeros) of \(\small H(z)\) must also be the zeros of &nbsp;\(\small H^\ast (1/z^\ast)\). This means that the <strong>roots of \(\small H(z)\) must occur in conjugate reciprocal pairs</strong>, i.e. &nbsp;if \(\small z_k\) is a zero of \(\small H(z)\), then \(\small H^\ast (1/z^\ast)\) must also be a zero.</p>



<h2 class="wp-block-heading"><strong>Why IIR filters do not have linear phase</strong></h2>



<p class="wp-block-paragraph">A digital filter is said to be <strong>bounded input, bounded output stable</strong>, or BIBO stable, if every bounded input gives rise to a bounded output. All IIR filters have either poles or both poles and zeros, and must be BIBO stable, i.e.</p>



<p class="has-text-align-center wp-block-paragraph">\(\displaystyle \sum_{k=0}^{\infty}\left|h(k)\right|&lt;\infty \tag{4}\)</p>



<p class="wp-block-paragraph">Where, \(\small h(k)\) is the filter&#8217;s impulse response. Analyzing Eqn. 4, it should be clear that the BIBO stability criterion will only be satisfied if the <strong>system&#8217;s poles lie inside the unit circle</strong>, since the system&#8217;s ROC (region of convergence) must include the unit circle. Consequently, it is sufficient to say that a bounded input signal will always produce a bounded output signal if all the poles lie inside the unit circle. </p>



<p class="wp-block-paragraph">The zeros on the other hand, are not constrained by this requirement, and as a consequence may lie anywhere on z-plane, since they do not directly affect system stability. Therefore, a system stability analysis may be undertaken by firstly calculating the roots of the transfer function (i.e., roots of the numerator and denominator polynomials) and then plotting the corresponding poles and zeros upon the z-plane.</p>



<p class="wp-block-paragraph">Applying the developed logic to the poles of an IIR filter, we now arrive at a <strong>very important conclusion</strong> on why IIR filters cannot have linear phase.<span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph"><em>A BIBO stable filter must have its poles within the unit circle, and as such in order to get linear phase, an IIR would need conjugate reciprocal poles outside of the unit circle, making it BIBO unstable.</em></p>
</blockquote>



<p class="wp-block-paragraph">Based upon this statement, it would seem that it’s not possible to design an IIR to have linear phase. However, a discussed below, phase equalisation filters can be used to linearise the passband phase response.</p>



<h2 class="wp-block-heading"><strong>Phase linearisation with all-pass filters</strong></h2>



<p><a style="color: #0000ff;" href="https://www.advsolned.com/all-pass-filter/">All-pass phase linearisation filters</a> (equalisers) are a well-established method of altering a filter’s phase response while not affecting its magnitude response. A second order (Biquad) all-pass filter is defined as:<span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span></p>



<center>\( A(z)=\Large\frac{r^2-2rcos \left( \frac{2\pi f_c}{fs}\right) z^{-1}+z^{-2}}{1-2rcos \left( \frac{2\pi f_c}{fs}\right)z^{-1}+r^2 z^{-2}}\tag{5} \)</center>



<p class="wp-block-paragraph">Where, \(\small f_c\) is the centre frequency, \(\small r\) is radius of the poles and \(\small f_s\) is the sampling frequency. Notice how the numerator and denominator coefficients are arranged as a <strong>mirror image pair</strong> of one another.&nbsp; The mirror image property is what gives the all-pass filter its desirable property, namely allowing the designer to alter the phase response while keeping the magnitude response constant or flat over the complete frequency spectrum.</p>



<p class="wp-block-paragraph">Cascading an APF (all-pass filter) equalisation cascade (comprised of multiple APFs) with an IIR filter, the basic idea is that <strong>we only need to linearise the phase response the passband region</strong>. The other regions, such as the transition band and stopband may be ignored, as any non-linearities in these regions are of little interest to the overall filtering result.</p>



<h3 class="wp-block-heading"><strong>The challenge</strong></h3>



<p class="wp-block-paragraph">The APF cascade sounds like an ideal compromise for this challenge, but in truth a significant amount of time and very careful fine-tuning of the APF positions is required in order to achieve an acceptable result. Each APF has two variables: \(\small f_c\) and \(\small r\) that need to be optimised, which complicates the solution. This is further complicated by the fact that the more APF stages that are added to the cascade, the higher the overall filter’s group delay (latency) becomes. This latter issue may become problematic for fast real-time closed loop control systems that rely on an IIR’s low latency property.</p>



<p class="wp-block-paragraph">Nevertheless, despite these challenges, the APF equaliser is a good compromise for linearising an IIRs passband phase characteristics.</p>



<h3 class="wp-block-heading"><strong>The APF equaliser</strong></h3>



<p class="wp-block-paragraph">ASN Filter Designer provides designers with a very simple to use graphical all-phase equaliser interface for linearising the passband phase of IIR filters. As seen below, the interface is very intuitive, and allows designers to quickly place and fine-tune APF filters positions with the mouse. The tool automatically calculates \(\small f_c\) and \(\small r\), based on the marker position.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="884" height="633" src="https://www.advsolned.com/wp-content/uploads/2020/06/AFE_designer.png" alt="APF equaliser ASN Filter Designer" class="wp-image-12723" srcset="https://www.advsolned.com/wp-content/uploads/2020/06/AFE_designer.png 884w, https://www.advsolned.com/wp-content/uploads/2020/06/AFE_designer-300x215.png 300w, https://www.advsolned.com/wp-content/uploads/2020/06/AFE_designer-768x550.png 768w, https://www.advsolned.com/wp-content/uploads/2020/06/AFE_designer-260x185.png 260w, https://www.advsolned.com/wp-content/uploads/2020/06/AFE_designer-705x505.png 705w, https://www.advsolned.com/wp-content/uploads/2020/06/AFE_designer-450x322.png 450w" sizes="(max-width: 884px) 100vw, 884px" /></figure>
</div>


<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<figure class="wp-block-image size-large"><img decoding="async" width="509" height="347" src="https://www.advsolned.com/wp-content/uploads/2020/06/AFE_designer_options.png" alt="" class="wp-image-12724" srcset="https://www.advsolned.com/wp-content/uploads/2020/06/AFE_designer_options.png 509w, https://www.advsolned.com/wp-content/uploads/2020/06/AFE_designer_options-300x205.png 300w, https://www.advsolned.com/wp-content/uploads/2020/06/AFE_designer_options-450x307.png 450w" sizes="(max-width: 509px) 100vw, 509px" /></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<p class="wp-block-paragraph"><span class="" style="display:block;clear:both;height: 0px;padding-top: 5px;border-top-width:0px;border-bottom-width:0px;"></span><strong>Right clicking </strong>on the frequency response chart or on an existing all-pass design marker displays an options menu, as shown on the left.</p>



<p class="wp-block-paragraph">You may add up to 10 biquads (professional version only).</p>
</div>
</div>



<h2 class="wp-block-heading"><strong>An IIR with linear passband phase</strong></h2>



<p class="wp-block-paragraph">Designing an equaliser composed of three APF pairs, and cascading it with the Chebyshev filter of Figure 1, we obtain a filter waveform that has a much a sharper peak with less attenuation and oscillation than the original IIR &#8211; see below. However, this improvement comes at the expense of three extra Biquad filters (the APF cascade) and an increased group delay, which has now risen to 24 samples compared with the original 10 samples.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="889" height="510" src="https://www.advsolned.com/wp-content/uploads/2020/06/iir_linearphase_eq-1.png" alt="IIR lowpass filtering result with three APF phase equalisation filters
(minimal phase distortion)" class="wp-image-12745" srcset="https://www.advsolned.com/wp-content/uploads/2020/06/iir_linearphase_eq-1.png 889w, https://www.advsolned.com/wp-content/uploads/2020/06/iir_linearphase_eq-1-300x172.png 300w, https://www.advsolned.com/wp-content/uploads/2020/06/iir_linearphase_eq-1-768x441.png 768w, https://www.advsolned.com/wp-content/uploads/2020/06/iir_linearphase_eq-1-705x404.png 705w, https://www.advsolned.com/wp-content/uploads/2020/06/iir_linearphase_eq-1-450x258.png 450w" sizes="auto, (max-width: 889px) 100vw, 889px" /><figcaption class="wp-element-caption"><center><em>IIR lowpass filtering result with three APF phase equalisation filters<br>(minimal phase distortion)</em></center></figcaption></figure>
</div>


<p class="wp-block-paragraph">The frequency response of both the original IIR and the equalised IIR are shown below, where the group delay (shown in purple) is the average delay of the filter and is a simpler way of assessing linearity.</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="580" height="656" src="https://www.advsolned.com/wp-content/uploads/2020/06/iir_linearphase_noeq.png" alt="IIR without equalisation cascade" class="wp-image-12726" srcset="https://www.advsolned.com/wp-content/uploads/2020/06/iir_linearphase_noeq.png 580w, https://www.advsolned.com/wp-content/uploads/2020/06/iir_linearphase_noeq-265x300.png 265w, https://www.advsolned.com/wp-content/uploads/2020/06/iir_linearphase_noeq-450x509.png 450w" sizes="auto, (max-width: 580px) 100vw, 580px" /><figcaption class="wp-element-caption"><center><em>IIR <strong>without </strong>equalisation cascade</em></center></figcaption></figure>



<p class="wp-block-paragraph"></p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="580" height="656" src="https://www.advsolned.com/wp-content/uploads/2020/06/iir_linearphase_eq.png" alt="IIR with equalisation cascade" class="wp-image-12727" srcset="https://www.advsolned.com/wp-content/uploads/2020/06/iir_linearphase_eq.png 580w, https://www.advsolned.com/wp-content/uploads/2020/06/iir_linearphase_eq-265x300.png 265w, https://www.advsolned.com/wp-content/uploads/2020/06/iir_linearphase_eq-450x509.png 450w" sizes="auto, (max-width: 580px) 100vw, 580px" /><figcaption class="wp-element-caption"><center><em>IIR <strong>with </strong>equalisation cascade</em></center></figcaption></figure>



<p class="wp-block-paragraph"></p>
</div>
</div>



<p class="wp-block-paragraph">Notice that the group delay of the equalised IIR passband (shown on the right) is almost flat, confirming that the phase is indeed linear.</p>



<h2 class="wp-block-heading"><strong>Automatic code generation to Arm processor cores via CMSIS-DSP</strong></h2>



<p class="wp-block-paragraph">The ASN Filter Designer’s automatic code generation engine facilitates the export of a designed filter to Cortex-M Arm based processors via the CMSIS-DSP software framework. The tool’s built-in analytics and help functions assist the designer in successfully configuring the design for deployment.</p>



<p class="wp-block-paragraph">Before generating the code, the IIR and equalisation filters (i.e. H1 and Heq filters) need to be firstly re-optimised (merged) to an H1 filter (main filter) structure for deployment. The <strong>options</strong> menu can be found under the <strong>P-Z</strong> tab in the main UI.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/reopt_preemp.png"><img loading="lazy" decoding="async" width="359" height="127" src="https://www.advsolned.com/wp-content/uploads/2019/10/reopt_preemp.png" alt="" class="wp-image-12140" srcset="https://www.advsolned.com/wp-content/uploads/2019/10/reopt_preemp.png 359w, https://www.advsolned.com/wp-content/uploads/2019/10/reopt_preemp-300x106.png 300w" sizes="auto, (max-width: 359px) 100vw, 359px" /></a></figure>
</div>


<p class="wp-block-paragraph">All floating point IIR filters designs should be based on <strong>Single Precision</strong> arithmetic and either a <strong>Direct Form I</strong> or <strong>Direct Form II Transposed</strong> filter structure, as this is supported by a hardware multiplier in the M4F, M7F, M33F and M55F cores. Although you may choose <strong>Double Precision, </strong>hardware support is only available in some M7F and M55F Helium devices. The <strong>Direct Form II Transposed</strong> structure is advocated for floating point implementation by virtue of its higher numerically accuracy.<span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span></p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="284" height="247" src="https://www.advsolned.com/wp-content/uploads/2019/10/preempQoptions.png" alt="" class="wp-image-12131"/></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">Quantisation and filter structure settings can be found under the <strong>Q</strong> tab (as shown on the left). Setting <strong>Arithmetic</strong> to <strong>Single Precision</strong> and <strong>Structure</strong> to <strong>Direct Form II Transposed</strong> and clicking on the <strong>Apply</strong> button configures the IIR considered herein for the CMSIS-DSP software framework.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>
</div>
</div>



<p class="wp-block-paragraph"><span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>Select the <strong>Arm CMSIS-DSP</strong> framework from the selection box in the filter summary window:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="170" height="183" src="https://www.advsolned.com/wp-content/uploads/2018/09/codegeneratoroptions.png" alt="" class="wp-image-17875"/></figure>
</div>


<p class="wp-block-paragraph">The automatically generated C code based on the CMSIS-DSP framework for direct implementation on an Arm based Cortex-M processor is shown below:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="686" height="514" src="https://www.advsolned.com/wp-content/uploads/2021/09/v5armcodegen.png" alt="" class="wp-image-17497" srcset="https://www.advsolned.com/wp-content/uploads/2021/09/v5armcodegen.png 686w, https://www.advsolned.com/wp-content/uploads/2021/09/v5armcodegen-300x225.png 300w, https://www.advsolned.com/wp-content/uploads/2021/09/v5armcodegen-450x337.png 450w" sizes="auto, (max-width: 686px) 100vw, 686px" /></figure>
</div>


<p class="wp-block-paragraph">The ASN Filter Designer&#8217;s automatic code generator generates all initialisation code, scaling and data structures needed to implement the linearised filter IIR filter via Arm&#8217;s CMSIS-DSP library.</p>



<h3 class="wp-block-heading"><strong>Arm deployment wizard </strong></h3>



<p class="wp-block-paragraph">Professional licence users may expedite the deployment by using the Arm deployment wizard. The built in AI will automatically determine the best settings for your design based on the quantisation settings chosen. <span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span></p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:45.33%">
<figure class="wp-block-image size-full is-resized is-style-default"><img loading="lazy" decoding="async" src="https://www.advsolned.com/wp-content/uploads/2018/09/Armwizard.png" alt="" class="wp-image-17853" width="343" height="286"/></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66%">
<p class="wp-block-paragraph">The built in AI automatically analyses your complete filter cascade and converts any H2 or Heq filters into an H1 for implementation.</p>
</div>
</div>


<span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>



<h2 class="wp-block-heading"><span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span>What we have learnt</h2>



<p class="wp-block-paragraph">The roots of a linear phase digital filter must occur in conjugate reciprocal pairs. Although this no problem for an FIR filter, it becomes infeasible for an IIR filter, as poles would need to be both inside and outside of the unit circle, making the filter BIBO unstable.</p>



<p class="wp-block-paragraph">The passband phase response of an IIR filter may be linearised by using an APF equalisation cascade. The ASN Filter Designer provides designers with everything they need via a very simple to use, graphical all-pass phase equaliser interface, in order to   design a suitable APF cascade by just using the mouse!</p>



<p class="wp-block-paragraph">The linearised IIR filter may be exported via the automatic code generator using Arm&#8217;s optimised CMSIS-DSP library functions for deployment on any Cortex-M microcontroller.</p>



<span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>
<p><a href="https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox.png"><img loading="lazy" decoding="async" class="alignleft wp-image-3310" style="margin: 10px 80px 10px 20px;" src="https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox.png" alt="" width="183" height="253" srcset="https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox.png 800w, https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox-217x300.png 217w, https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox-768x1062.png 768w, https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox-745x1030.png 745w, https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox-510x705.png 510w, https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox-450x622.png 450w" sizes="auto, (max-width: 183px) 100vw, 183px" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p style="text-align: left;"><a class="button" href="https://www.advsolned.com/request-form-asn-filter-designer-demo/">Download demo now</a></p>
<p> </p>
<p><a class="button" href="https://www.advsolned.com/pricing-and-licencing/#Best_licence_forme">Licencing information</a></p>



<p class="wp-block-paragraph"></p>


<p><span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>
                
                    <!--begin code -->

                    
                    <div class="pp-multiple-authors-boxes-wrapper pp-multiple-authors-wrapper pp-multiple-authors-layout-boxed multiple-authors-target-shortcode box-post-id-19551 box-instance-id-1 ppma_boxes_19551"
                    data-post_id="19551"
                    data-instance_id="1"
                    data-additional_class="pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode"
                    data-original_class="pp-multiple-authors-boxes-wrapper pp-multiple-authors-wrapper box-post-id-19551 box-instance-id-1">
                                                                                    <h2 class="widget-title box-header-title">Author</h2>
                                                                            <span class="ppma-layout-prefix"></span>
                        <div class="ppma-author-category-wrap">
                                                                                                                                    <span class="ppma-category-group ppma-category-group-1 category-index-0">
                                                                                                                        <ul class="pp-multiple-authors-boxes-ul author-ul-0">
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                    <li class="pp-multiple-authors-boxes-li author_index_0 author_ssarpal has-avatar">
                                                                                                                                                                                    <div class="pp-author-boxes-avatar">
                                                                    <div class="avatar-image">
                                                                                                                                                                                                                <img alt='' src='https://www.advsolned.com/wp-content/uploads/2023/05/sanjeevsarpal.jpeg' srcset='https://www.advsolned.com/wp-content/uploads/2023/05/sanjeevsarpal.jpeg' class='multiple_authors_guest_author_avatar avatar' height='80' width='80'/>                                                                                                                                                                                                            </div>
                                                                                                                                    </div>
                                                            
                                                            <div class="pp-author-boxes-avatar-details">
                                                                <div class="pp-author-boxes-name multiple-authors-name"><a href="https://www.advsolned.com/author/ssarpal/" rel="author" title="Dr. Sanjeev Sarpal" class="author url fn">Dr. Sanjeev Sarpal</a></div>                                                                                                                                                                                                    
                                                                                                                                            <div class="pp-author-boxes-description multiple-authors-description author-description-0">
                                                                                                                                                    <p>Sanjeev is a RTEI (Real-Time Edge Intelligence) visionary and expert in signals and systems with a track record of successfully developing over 26 commercial products. He is a Distinguished Arm Ambassador and advises top international blue chip companies on their AIoT/RTEI solutions and strategies for I5.0, telemedicine, smart healthcare, smart grids and smart buildings.</p>
                                                                                                                                                </div>
                                                                                                                                                                                                    
                                                                                                                                    <span class="pp-author-boxes-meta multiple-authors-links">
                                                                        <a href="https://www.advsolned.com/author/ssarpal/" title="View all posts">
                                                                            <span>View all posts</span>
                                                                        </a>
                                                                    </span>
                                                                                                                                <a class="ppma-author-user_email-profile-data ppma-author-field-meta ppma-author-field-type-email" aria-label="Email" href="mailto:sanjeev.sarpal@advsolned.com"  target="_self"><span class="dashicons dashicons-email-alt"></span> </a>
                                                                                                                            </div>
                                                                                                                                                                                                                        </li>
                                                                                                                                                                                                                                                                                        </ul>
                                                                            </span>
                                                                                                                        </div>
                        <span class="ppma-layout-suffix"></span>
                                            </div>
                    <!--end code -->
                    
                
                            
        </p>
		<div class="wpulike wpulike-default " ><div class="wp_ulike_general_class wp_ulike_is_restricted"><button type="button"
					aria-label="Like Button"
					data-ulike-id="12722"
					data-ulike-nonce="5bb3471792"
					data-ulike-type="post"
					data-ulike-template="wpulike-default"
					data-ulike-display-likers=""
					data-ulike-likers-style="popover"
					class="wp_ulike_btn wp_ulike_put_image wp_post_btn_12722"></button><span class="count-box wp_ulike_counter_up" data-ulike-counter-value="+17"></span>			</div></div>
	<p>The post <a rel="nofollow" href="https://www.advsolned.com/linear-phase-iir-filters-analysis-design/">Linear phase IIR filters – analysis and design</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to export designed IIR/FIR filters to Matlab</title>
		<link>https://www.advsolned.com/how-to-export-designed-iir-fir-filters-to-matlab/</link>
					<comments>https://www.advsolned.com/how-to-export-designed-iir-fir-filters-to-matlab/#respond</comments>
		
		<dc:creator><![CDATA[ASN consultancy team]]></dc:creator>
		<pubDate>Tue, 25 Sep 2018 14:54:07 +0000</pubDate>
				<category><![CDATA[ASN Filter Designer]]></category>
		<category><![CDATA[biquad]]></category>
		<category><![CDATA[Chebyshev]]></category>
		<category><![CDATA[FIR]]></category>
		<category><![CDATA[IIR]]></category>
		<category><![CDATA[Matlab]]></category>
		<guid isPermaLink="false">http://www.advsolned.com/?p=7933</guid>

					<description><![CDATA[<p>For many IoT sensor measurement applications, an IIR or FIR filter is just one of the many components needed for an algorithm. This could be a powerline interference canceller for a biomedical application or even a simpler DC loadcell filter. In many cases, it is necessary to integrate a filter into a complete algorithm in [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.advsolned.com/how-to-export-designed-iir-fir-filters-to-matlab/">How to export designed IIR/FIR filters to Matlab</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">For many IoT sensor measurement applications, an IIR or FIR filter is just one of the many components needed for an algorithm. This could be a powerline interference canceller for a biomedical application or even a simpler DC loadcell filter. In many cases, it is necessary to integrate a filter into a complete algorithm in another domain.</p>



<p class="wp-block-paragraph"><a style="color: #0000ff;" href="http://www.mathworks.com">Matlab</a> is a well-established numerical computing language developed by the Mathworks that allows for the design of algorithms, matrix data manipulations and data analysis. The product offers a broad range of algorithms and support functions for signal processing applications, and as such is very popular amongst many scientists and engineers worldwide.</p>



<h2 class="wp-block-heading">ASN Filter Designer automatic code generator for Matlab</h2>



<p class="wp-block-paragraph">The ASN Filter Designer greatly simplifies exporting a designed filter to Matlab via its automatic code generator. The code generator supports all aspects of the ASN Filter Designer, allowing for a complete design comprised of H1, H2 and H3 filters and math operators to be fully integrated with an algorithm in Matlab.</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">The Matlab code generator can be accessed via the filter summary options (as shown on the right). Selecting this option will automatically generate a Matlab <code>.m</code> file based on the current design.<span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span></p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="176" height="187" src="https://www.advsolned.com/wp-content/uploads/2022/12/matlab_codegen_option.png" alt="" class="wp-image-19214"/></figure>
</div>
</div>



<p class="wp-block-paragraph">Version 5 of the tool has a completely revamped filter summary UI, and now includes built in AI to analyse the filter cascade for any potential problems.&nbsp; The project wizard bundles all of the necessary SDK framework files needed to run the designed filter cascade without the need for any other dependencies or 3<sup>rd</sup> party plugins.</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="686" height="558" src="https://www.advsolned.com/wp-content/uploads/2022/12/matlab_codegen-1.png" alt="" class="wp-image-19218" srcset="https://www.advsolned.com/wp-content/uploads/2022/12/matlab_codegen-1.png 686w, https://www.advsolned.com/wp-content/uploads/2022/12/matlab_codegen-1-300x244.png 300w, https://www.advsolned.com/wp-content/uploads/2022/12/matlab_codegen-1-450x366.png 450w" sizes="auto, (max-width: 686px) 100vw, 686px" /></figure></div>



<h3 class="wp-block-heading"><strong>Framework files and examples</strong></h3>



<p class="wp-block-paragraph">In order to use the generated code in Matlab without the need for <a style="color: #0000ff;" href="https://nl.mathworks.com/products/signal.html">Signal Processing Toolbox</a>, the following three framework files are provided in the ASN Filter Designer’s <code>\Matlab</code> directory:</p>



<p class="wp-block-paragraph"><code>ASNFDMatlabFilterData.m</code><br><code>ASNFDMatlabImport.m</code><br><code>ASNFDFilter.m</code></p>



<p class="wp-block-paragraph">These framework files do not have any special Matlab toolbox dependences, and the example script <code>ASNFDMatlabDemo.m</code> demonstrates the simplicity with which the framework can be integrated into your application for your designed filter. Several example filters generated via the automatic code generator are given within <code>ASNFDMatlabDemo.m</code> in order to get you going!</p>



<p class="wp-block-paragraph">An example of the summary of all of generated files (including the framework files) is shown below.</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="686" height="514" src="https://www.advsolned.com/wp-content/uploads/2022/12/matlab_codegen_files.png" alt="" class="wp-image-19217" srcset="https://www.advsolned.com/wp-content/uploads/2022/12/matlab_codegen_files.png 686w, https://www.advsolned.com/wp-content/uploads/2022/12/matlab_codegen_files-300x225.png 300w, https://www.advsolned.com/wp-content/uploads/2022/12/matlab_codegen_files-450x337.png 450w" sizes="auto, (max-width: 686px) 100vw, 686px" /></figure></div>



<p class="wp-block-paragraph">These files can be used directly in your Matlab/Octave project. <span class="" style="display:block;clear:both;height: 0px;padding-top: 15px;border-top-width:0px;border-bottom-width:0px;"></span></p>



<h2 class="wp-block-heading">Comparing the results to Matlab’s Signal Processing Toolbox</h2>



<p class="wp-block-paragraph">It’s sometimes informative to compare the results of the ASN Filter Designer’s DSP library functions to that of Matlab’s Signal Processing Toolbox.</p>



<p class="wp-block-paragraph">Designing an IIR Chebyshev Type I filter with the following specifications:</p>



<figure class="wp-block-table"><table><tbody><tr><td><strong>Fs:</strong></td><td>500Hz</td></tr><tr><td><strong>Passband frequency:</strong></td><td>0-25Hz</td></tr><tr><td><strong>Type:</strong></td><td>Lowpass</td></tr><tr><td><strong>Method:</strong></td><td>Chebyshev Type I</td></tr><tr><td><strong>Stopband attenuation @ 125Hz:</strong></td><td>≥ 80 dB</td></tr><tr><td><strong>Passband ripple:</strong></td><td>≤ 0.1dB</td></tr><tr><td><strong>Order:</strong></td><td>5</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">Graphically entering the specifications into the ASN Filter Designer, and fine tuning the design marker positions, the tool automatically designs the filter as a Biquad cascade. Notice that the tool automatically finds the required filter order, and in essence &#8211; automatically produces the filter’s exact technical specification!</p>



<p class="wp-block-paragraph">The frequency response of a 5th order IIR Chebyshev Type I lowpass filter meeting the specifications is shown below:</p>



<div class="wp-block-image"><figure class="aligncenter"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/matlabfilterFR.png"><img loading="lazy" decoding="async" width="580" height="656" src="http://www.advsolned.com/wp-content/uploads/2018/09/matlabfilterFR.png" alt="" class="wp-image-7939" srcset="https://www.advsolned.com/wp-content/uploads/2018/09/matlabfilterFR.png 580w, https://www.advsolned.com/wp-content/uploads/2018/09/matlabfilterFR-265x300.png 265w, https://www.advsolned.com/wp-content/uploads/2018/09/matlabfilterFR-450x509.png 450w" sizes="auto, (max-width: 580px) 100vw, 580px" /></a></figure></div>



<p class="wp-block-paragraph">The resulting filter coefficients are:</p>



<div class="wp-block-image"><figure class="aligncenter"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/matlabasnfdresult.png"><img loading="lazy" decoding="async" width="454" height="235" src="http://www.advsolned.com/wp-content/uploads/2018/09/matlabasnfdresult.png" alt="" class="wp-image-7937" srcset="https://www.advsolned.com/wp-content/uploads/2018/09/matlabasnfdresult.png 454w, https://www.advsolned.com/wp-content/uploads/2018/09/matlabasnfdresult-300x155.png 300w, https://www.advsolned.com/wp-content/uploads/2018/09/matlabasnfdresult-450x233.png 450w" sizes="auto, (max-width: 454px) 100vw, 454px" /></a></figure></div>



<p class="wp-block-paragraph">Designing the same filter in Matlab using Signal Processing Toolbox:</p>



<pre class="brush: matlabkey; title: ; notranslate">
Fs=500;
Rp=0.1;
Rs=80;
F=2*&#x5B;25,125]/Fs;

&#x5B;N,Wn]=cheb1ord(F(1),F(2),Rp,Rs)
&#x5B;z, p, k] = cheby1(N,Rp,Wn,'low'); % design lowpass

&#x5B;sos,g]=zp2sos(z,p,k,'up')  % generate SOS form
</pre>



<p class="wp-block-paragraph">Running the script, we get the following, where each row of <code>sos</code> is a biquad arranged as: <code> b0 b1 b2 a0 a1 a2 </code></p>



<div class="wp-block-image"><figure class="aligncenter"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/matlabresult.png"><img loading="lazy" decoding="async" width="551" height="200" src="http://www.advsolned.com/wp-content/uploads/2018/09/matlabresult.png" alt="" class="wp-image-7940" srcset="https://www.advsolned.com/wp-content/uploads/2018/09/matlabresult.png 551w, https://www.advsolned.com/wp-content/uploads/2018/09/matlabresult-300x109.png 300w, https://www.advsolned.com/wp-content/uploads/2018/09/matlabresult-450x163.png 450w" sizes="auto, (max-width: 551px) 100vw, 551px" /></a></figure></div>



<p class="wp-block-paragraph">Analysing both sets of numerator and denominator coefficients, we get exactly the same result! But what about the gain? Matlab outputs a net gain, <code>g = 3.0096e-05</code> but the ASN Filter Designer optimally assigns a gain to each biquad. Thus, combining the biquad section gains, i.e. <code> 0.078643, 0.013823 </code> and <code>0.027685</code> results in a net gain of <code>3.0096e-05</code>, which is exactly the same net gain as Matlab!</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p><strong>Conclusion: the ASN Filter Designer’s DSP IIR library functions completely match Matlab’s Signal Processing Toolbox results!!</strong></p></blockquote>



<p class="wp-block-paragraph">The complete automatically generated code is shown below, where it can be seen that the biquad gains have been pre-multiplied with the feedforward coefficients.</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="894" height="455" src="https://www.advsolned.com/wp-content/uploads/2018/09/matlabcomplete-e1670947969663.png" alt="The complete automatically generated code is shown below, where it can be seen that the biquad gains have been pre-multiplied with the feedforward coefficients." class="wp-image-7938" srcset="https://www.advsolned.com/wp-content/uploads/2018/09/matlabcomplete-e1670947969663.png 894w, https://www.advsolned.com/wp-content/uploads/2018/09/matlabcomplete-e1670947969663-300x153.png 300w, https://www.advsolned.com/wp-content/uploads/2018/09/matlabcomplete-e1670947969663-768x391.png 768w, https://www.advsolned.com/wp-content/uploads/2018/09/matlabcomplete-e1670947969663-705x359.png 705w, https://www.advsolned.com/wp-content/uploads/2018/09/matlabcomplete-e1670947969663-450x229.png 450w" sizes="auto, (max-width: 894px) 100vw, 894px" /></figure></div>



<h2 class="wp-block-heading"><span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>Using the generated code with Signal Processing Toolbox</h2>



<p class="wp-block-paragraph">If you have <a style="color: #0000ff;" href="https://nl.mathworks.com/products/signal.html">Signal Processing Toolbox</a> installed, then you may directly use the generated coefficients given in SOS with the <code>sosfilt()</code> command, e.g.</p>



<pre class="brush: matlabkey; title: ; notranslate">
Clear all;

ASNFD_SOS=&#x5B; 0.07864301814, 0.07864301814, 0.00000000000, 1.00000000000,-0.84271396371, 0.00000000000;...
 0.01382289248, 0.02764578495, 0.01382289248, 1.00000000000,-1.70536517618, 0.76065674608;...
 0.02768538360, 0.05537076720, 0.02768538360, 1.00000000000,-1.79181447713, 0.90255601154;...
];

y=sosfilt(ASNFD_SOS, x); %  x is your input data

plot(x,y); % plot results
</pre>



<p class="wp-block-paragraph">As seen, it is as simple as copying and pasting the filter coefficients from the ASN Filter Designer&#8217;s filter summary into a Matlab script.</p>


<span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:50%">
<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.advsolned.com/wp-content/uploads/2019/12/Softwareboxshadow-verkleind-495x400_verleind.jpg" alt="ASN Filter Designer box" class="wp-image-10817" width="495" height="400" srcset="https://www.advsolned.com/wp-content/uploads/2019/12/Softwareboxshadow-verkleind-495x400_verleind.jpg 495w, https://www.advsolned.com/wp-content/uploads/2019/12/Softwareboxshadow-verkleind-495x400_verleind-300x242.jpg 300w, https://www.advsolned.com/wp-content/uploads/2019/12/Softwareboxshadow-verkleind-495x400_verleind-450x364.jpg 450w" sizes="auto, (max-width: 495px) 100vw, 495px" /></figure>



<p class="wp-block-paragraph"></p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:50%">
<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link has-vivid-cyan-blue-background-color has-text-color has-background no-border-radius" href="https://www.advsolned.com/request-form-asn-filter-designer-demo/" style="color:#ffffff">Download Demo</a></div>
</div>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link has-vivid-cyan-blue-background-color has-text-color has-background no-border-radius" href="https://www.advsolned.com/pricing-and-licencing/" style="color:#ffffff">Pricing and Licencing</a></div>
</div>



<p class="wp-block-paragraph"></p>
</div>
</div>
		<div class="wpulike wpulike-default " ><div class="wp_ulike_general_class wp_ulike_is_restricted"><button type="button"
					aria-label="Like Button"
					data-ulike-id="7933"
					data-ulike-nonce="53caf78e0b"
					data-ulike-type="post"
					data-ulike-template="wpulike-default"
					data-ulike-display-likers=""
					data-ulike-likers-style="popover"
					class="wp_ulike_btn wp_ulike_put_image wp_post_btn_7933"></button><span class="count-box wp_ulike_counter_up" data-ulike-counter-value="+2"></span>			</div></div>
	<p>The post <a rel="nofollow" href="https://www.advsolned.com/how-to-export-designed-iir-fir-filters-to-matlab/">How to export designed IIR/FIR filters to Matlab</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.advsolned.com/how-to-export-designed-iir-fir-filters-to-matlab/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Implementing Biquad IIR filters with the ASN Filter Designer and the Arm CMSIS-DSP software framework</title>
		<link>https://www.advsolned.com/implementing-biquad-iir-filters-with-the-asn-filter-designer-and-the-arm-cmsis-dsp-software-framework/</link>
		
		<dc:creator><![CDATA[Dr. Sanjeev Sarpal]]></dc:creator>
		<pubDate>Sat, 22 Sep 2018 20:44:11 +0000</pubDate>
				<category><![CDATA[ASN Filter Designer]]></category>
		<category><![CDATA[Arm]]></category>
		<category><![CDATA[Arm Cortex-M]]></category>
		<category><![CDATA[biquad]]></category>
		<category><![CDATA[CMSIS-DSP]]></category>
		<category><![CDATA[IIR]]></category>
		<guid isPermaLink="false">http://www.advsolned.com/?p=7877</guid>

					<description><![CDATA[<p>Infinite impulse response (IIR) filters are useful for a variety of sensor measurement applications, including measurement noise removal and unwanted component cancellation, such as powerline interference. Although several practical implementations for the IIR exist, the Direct form II Transposed structure offers the best numerical accuracy for floating point implementation. However, when considering fixed point implementation [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.advsolned.com/implementing-biquad-iir-filters-with-the-asn-filter-designer-and-the-arm-cmsis-dsp-software-framework/">Implementing Biquad IIR filters with the ASN Filter Designer and the Arm CMSIS-DSP software framework</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Infinite impulse response (IIR) filters are useful for a variety of sensor measurement applications, including measurement noise removal and unwanted component cancellation, such as powerline interference. Although several practical implementations for the IIR exist, the <strong>Direct form II Transposed</strong> structure offers the best numerical accuracy for floating point implementation. However, when considering fixed point implementation on a microcontroller, the <strong>Direct Form I</strong> structure is considered to be the best choice by virtue of its large accumulator that accommodates any intermediate overflows. This application note specifically addresses IIR biquad filter design and implementation on a Cortex-M based microcontroller with the ASN Filter Designer for both floating point and fixed point applications via the Arm CMSIS-DSP software framework.</p>



<p class="wp-block-paragraph">Details are also given (including a <a href="http://www2.keil.com/mdk5/cmsis/asnfd">reference example project</a>) regarding implementation of the IIR filter in Arm/Keil’s MDK industry standard Cortex-M microcontroller development kit.</p>



<h2 class="wp-block-heading">Introduction</h2>



<p class="wp-block-paragraph">ASN Filter Designer provides engineers with a powerful DSP experimentation platform, allowing for the design, experimentation and deployment of complex IIR and FIR (finite impulse response) digital filter designs for a variety of sensor measurement applications. The tool’s advanced functionality, includes a graphical based real-time filter designer, multiple filter blocks, various mathematical I/O blocks, live symbolic math scripting and real-time signal analysis (via a built-in signal analyser). These advantages coupled with automatic documentation and code generation functionality allow engineers to design and validate a digital filter within minutes rather than hours.</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:75%">
<p class="wp-block-paragraph">The <a href="http://arm-software.github.io/CMSIS_5/DSP/html/index.html">Arm CMSIS-DSP</a> (Cortex Microcontroller Software Interface Standard) software framework is a rich collection of over sixty DSP functions (including various mathematical functions, such as sine and cosine; IIR/FIR filtering functions, complex math functions, and data types) developed by Arm that have been optimised for their range of Cortex-M processor cores.</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow"><div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="170" height="67" src="https://www.advsolned.com/wp-content/uploads/2018/02/cmsis.png" alt="" class="wp-image-3311"/></figure>
</div></div>
</div>



<p>The framework makes extensive use of highly optimised SIMD (single instruction, multiple data) instructions, that perform multiple identical operations in a single cycle instruction. The SIMD instructions (if supported by the core) coupled together with other optimisations allow engineers to produce highly optimised signal processing applications for Cortex-M based micro-controllers quickly and simply.</p>



<p class="wp-block-paragraph">ASN Filter Designer fully supports the CMSIS-DSP software framework, by automatically producing optimised C code based on the framework’s DSP functions via its code generation engine.</p>



<h2 class="wp-block-heading">Designing IIR filters with the ASN Filter Designer</h2>



<p class="wp-block-paragraph">ASN Filter Designer provides engineers with an easy to use, intuitive graphical design development platform for both IIR and FIR digital filter design. The tool’s real-time design paradigm makes use of graphical design markers, allowing designers to simply draw and modify their magnitude frequency response requirements in real-time while allowing the tool automatically fill in the exact specifications for them.</p>



<p class="wp-block-paragraph">Consider the design of the following technical specification:</p>



<figure class="wp-block-table aligncenter"><table><tbody><tr><td><strong>Fs:</strong></td><td>&nbsp; 500Hz</td></tr><tr><td><strong>Passband frequency:</strong></td><td>&nbsp; 0-40Hz</td></tr><tr><td><strong>Type:</strong></td><td>&nbsp; Lowpass</td></tr><tr><td><strong>Method:</strong></td><td>&nbsp; Elliptic</td></tr><tr><td><strong>Stopband attenuation @ 125Hz:</strong>  </td><td>&nbsp; ≥ 80 dB</td></tr><tr><td><strong>Passband ripple:</strong></td><td>&nbsp; &lt; 0.1dB</td></tr><tr><td><strong>Order:</strong></td><td>&nbsp; Small as possible</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">Graphically entering the specifications into the ASN Filter Designer, and fine tuning the design marker positions, the tool automatically designs the filter as a Biquad cascade (this terminology will be discussed in the following sections), automatically choosing the required filter order, and in essence &#8211; automatically producing the filter’s exact technical specification!</p>



<p class="wp-block-paragraph">The frequency response of a 5th order IIR Elliptic Lowpass filter meeting the specifications is shown below:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/asn25_filterFR.png"><img loading="lazy" decoding="async" width="591" height="632" src="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_filterFR.png" alt="" class="wp-image-12179" srcset="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_filterFR.png 591w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_filterFR-281x300.png 281w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_filterFR-450x481.png 450w" sizes="auto, (max-width: 591px) 100vw, 591px" /></a></figure>
</div>


<p class="wp-block-paragraph">This 5th order Lowpass filter will form the basis of the discussion presented herein.</p>



<h2 class="wp-block-heading">Biquad IIR filters</h2>



<p class="wp-block-paragraph">The IIR filter implementation discussed herein is said to be <strong>biquad</strong>, since it has two poles and two zeros as illustrated below in Figure 1. The biquad implementation is particularly useful for fixed point implementations, as the effects of quantization and numerical stability are minimised. However, the overall success of any biquad implementation is dependent upon the available number precision, which must be sufficient enough in order to ensure that the quantised poles are always inside the unit circle.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/asn25_DFI.png"><img loading="lazy" decoding="async" width="867" height="331" src="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_DFI.png" alt="" class="wp-image-12181" srcset="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_DFI.png 867w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_DFI-300x115.png 300w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_DFI-768x293.png 768w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_DFI-705x269.png 705w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_DFI-450x172.png 450w" sizes="auto, (max-width: 867px) 100vw, 867px" /></a></figure>
</div>


<p class="has-text-align-center wp-block-paragraph"><em>Figure 1: Direct Form I (biquad) IIR filter realization and transfer function.</em></p>



<p class="has-text-align-left wp-block-paragraph">Analysing Figure 1, it can be seen that the biquad structure is actually comprised of two feedback paths (scaled by \(a_1\) and \(a_2\)), three feed forward paths (scaled by \(b_0, b_1\) and \(b_2\)) and a section gain, \(K\). Thus, the filtering operation of Figure 1 can be summarised by the following simple recursive equation:</p>



<p class="has-text-align-center wp-block-paragraph">\(\displaystyle y(n)=K\times\Big[b_0 x(n) + b_1 x(n-1) + b_2 x(n-2)\Big] &#8211; a_1 y(n-1)-a_2 y(n-2)\)</p>



<p class="wp-block-paragraph">Analysing the equation, notice that the biquad implementation only requires four additions (requiring only one accumulator) and five multiplications, which can be <strong>easily accommodated on any Cortex-M microcontroller</strong>. The section gain, \(K\) may also be pre-multiplied with the forward path coefficients before implementation.<span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span></p>



<p class="wp-block-paragraph">A collection of Biquad filters is referred to as a <strong>Biquad Cascade</strong>, as illustrated below.</p>


<div class="wp-block-image">
<figure class="aligncenter"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/asn25_biquadcascade.png"><img loading="lazy" decoding="async" width="739" height="111" src="http://www.advsolned.com/wp-content/uploads/2018/09/asn25_biquadcascade.png" alt="" class="wp-image-7890" srcset="https://www.advsolned.com/wp-content/uploads/2018/09/asn25_biquadcascade.png 739w, https://www.advsolned.com/wp-content/uploads/2018/09/asn25_biquadcascade-300x45.png 300w, https://www.advsolned.com/wp-content/uploads/2018/09/asn25_biquadcascade-705x106.png 705w, https://www.advsolned.com/wp-content/uploads/2018/09/asn25_biquadcascade-450x68.png 450w" sizes="auto, (max-width: 739px) 100vw, 739px" /></a></figure>
</div>


<p class="wp-block-paragraph">The ASN Filter Designer can design and implement a cascade of up to 50 biquads (Professional edition only).</p>



<h3 class="wp-block-heading" id="floating_point"><strong>Floating point implementation</strong></h3>



<p class="wp-block-paragraph">When implementing a filter in floating point (i.e. using double or single precision arithmetic) Direct Form II structures are considered to be a better choice than the <strong>Direct Form I</strong> structure. The <strong>Direct Form II Transposed</strong> structure is considered the most numerically accurate for floating point implementation, as the undesirable effects of numerical swamping are minimised as seen by analysing the difference equations.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/asn25_DFIITrans.png"><img loading="lazy" decoding="async" width="902" height="407" src="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_DFIITrans.png" alt="" class="wp-image-12185" srcset="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_DFIITrans.png 902w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_DFIITrans-300x135.png 300w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_DFIITrans-768x347.png 768w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_DFIITrans-705x318.png 705w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_DFIITrans-450x203.png 450w" sizes="auto, (max-width: 902px) 100vw, 902px" /></a></figure>
</div>


<p class="has-text-align-center wp-block-paragraph"><em>Figure 2 &#8211; Direct Form II Transposed strucutre, transfer function and difference equations</em></p>



<p class="wp-block-paragraph">The filter summary (shown in <a style="color: #0000ff;" href="http://www.advsolned.com/implementing-biquad-iir-filters-with-the-asn-filter-designer-and-the-arm-cmsis-dsp-software-framework/#figure3">Figure 3</a>) provides the designer with a detailed overview of the designed filter, including a detailed summary of the technical specifications and the filter coefficients, which presents a quick and simple route to documenting your design.<span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span></p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">The ASN Filter Designer supports the design and implementation of both single section and Biquad (default setting) IIR filters. However, as the CMSIS-DSP framework does not directly support single section IIR filters, this feature will not be covered in this application note.</p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="330" height="169" src="https://www.advsolned.com/wp-content/uploads/2018/09/asn25_biquad-1.png" alt="" class="wp-image-12169" srcset="https://www.advsolned.com/wp-content/uploads/2018/09/asn25_biquad-1.png 330w, https://www.advsolned.com/wp-content/uploads/2018/09/asn25_biquad-1-300x154.png 300w" sizes="auto, (max-width: 330px) 100vw, 330px" /></figure>
</div>
</div>


<span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:10%">
<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.advsolned.com/wp-content/uploads/2018/10/appnote_infosymbol.png" alt="" class="wp-image-12160" width="49" height="53"/></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<p class="wp-block-paragraph">The CMSIS-DSP software framework implementation requires <strong>sign inversion</strong> (i.e. flipping the sign) of the feedback coefficients. In order to accommodate this, the tool’s automatic code generation engine automatically flips the sign of the feedback coefficients as required. In this case, the set of difference equations become,</p>
</div>
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/asn25_filtersummary.png"><img loading="lazy" decoding="async" width="894" height="598" src="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_filtersummary.png" alt="" class="wp-image-12186" srcset="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_filtersummary.png 894w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_filtersummary-300x201.png 300w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_filtersummary-768x514.png 768w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_filtersummary-705x472.png 705w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_filtersummary-450x301.png 450w" sizes="auto, (max-width: 894px) 100vw, 894px" /></a></figure>
</div>


<p class="wp-block-paragraph">\(y(n)=b_0 x(n)+w_1 (n-1)\)<br>\(w_1 (n)= b_1 x(n)+a_1 y(n)+w_2 (n-1)\)<br>\(w_2 (n)= b_2 x(n)+a_2 y(n)\)<br><span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span><br></p>



<p class="has-text-align-center wp-block-paragraph"><em>Figure 3: ASN filter designer: filter summary.</em></p>



<h3 class="wp-block-heading"><strong>Automatic code generation to Arm processor cores via CMSIS-DSP</strong></h3>



<p class="wp-block-paragraph">The ASN Filter Designer’s automatic code generation engine facilitates the export of a designed filter to Cortex-M Arm based processors via the CMSIS-DSP software framework. The tool’s built-in analytics and help functions assist the designer in successfully configuring the design for deployment.</p>



<p class="wp-block-paragraph">All floating point IIR filters designs should be based on <strong>Single Precision</strong> arithmetic and either a <strong>Direct Form I</strong> or <strong>Direct Form II Transposed</strong> filter structure, as this is supported by a hardware multiplier in the M4F, M7F, M33F and M55F cores. Although you may choose <strong>Double Precision, </strong>hardware support is only available in some M7F and M55F Helium devices. As discussed in the <a style="color: #0000ff;" href="http://www.advsolned.com/implementing-biquad-iir-filters-with-the-asn-filter-designer-and-the-arm-cmsis-dsp-software-framework/#floating_point">previous section</a>, the <strong>Direct Form II Transposed</strong> structure is advocated for floating point implementation by virtue of its higher numerically accuracy.</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="284" height="247" src="https://www.advsolned.com/wp-content/uploads/2020/04/preempQoptions-1.png" alt="" class="wp-image-12171"/></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">Quantisation and filter structure settings can be found under the <strong>Q</strong> tab (as shown on the left). Setting <strong>Arithmetic</strong> to <strong>Single Precision</strong> and <strong>Structure</strong> to <strong>Direct Form II Transposed</strong> and clicking on the <strong>Apply</strong> button configures the IIR considered herein for the CMSIS-DSP software framework.</p>
</div>
</div>



<p class="wp-block-paragraph"><span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>Select the <strong>Arm CMSIS-DSP</strong> framework from the selection box in the filter summary window:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" src="https://www.advsolned.com/wp-content/uploads/2018/09/codegeneratoroptions.png" alt="" class="wp-image-17875" width="199" height="214"/></figure>
</div>


<p class="wp-block-paragraph">The automatically generated C code based on the CMSIS-DSP framework for direct implementation on an Arm based Cortex-M processor is shown below:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="686" height="514" src="https://www.advsolned.com/wp-content/uploads/2021/09/v5armcodegen.png" alt="" class="wp-image-17497" srcset="https://www.advsolned.com/wp-content/uploads/2021/09/v5armcodegen.png 686w, https://www.advsolned.com/wp-content/uploads/2021/09/v5armcodegen-300x225.png 300w, https://www.advsolned.com/wp-content/uploads/2021/09/v5armcodegen-450x337.png 450w" sizes="auto, (max-width: 686px) 100vw, 686px" /></figure>
</div>


<p class="wp-block-paragraph">As seen, the automatic code generator generates all initialisation code, scaling and data structures needed to implement the IIR via the CMSIS-DSP library. This code may be directly used in any Cortex-M based development project &#8211; a <a style="color: #0000ff;" href="http://www2.keil.com/mdk5/cmsis/asnfd">complete Keil MDK example</a> is available on Arm/Keil&#8217;s website. Notice that the tool’s code generator produces code for the Cortex-M4 core as default, please refer to the table below for the <code>#define</code> definition required for all supported cores.</p>



<figure class="wp-block-table"><table><tbody><tr><td><code>ARM_MATH_CM0</code></td><td>Cortex-M0 core.</td><td><code>ARM_MATH_CM4</code></td><td>Cortex-M4 core.</td></tr><tr><td><code>ARM_MATH_CM0PLUS</code></td><td>Cortex-M0+ core.</td><td><code>ARM_MATH_CM7</code></td><td>Cortex-M7 core.</td></tr><tr><td><code>ARM_MATH_CM3</code></td><td>Cortex-M3 core.</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>ARM_MATH_ARMV8MBL</code></td><td>ARMv8M Baseline target (Cortex-M23 core).</td></tr><tr><td><code>ARM_MATH_ARMV8MML</code></td><td>ARMv8M Mainline target (Cortex-M33 core).</td></tr></tbody></table></figure>


<span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:10%">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="49" height="53" src="https://www.advsolned.com/wp-content/uploads/2018/10/appnote_infosymbol.png" alt="" class="wp-image-12160"/></figure>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">Automatic code generation of complex coefficient IIR filters is currently not supported (see below for more information).</p>
</div>
</div>


<span class="" style="display:block;clear:both;height: 0px;padding-top: 30px;border-top-width:0px;border-bottom-width:0px;"></span>



<p class="wp-block-paragraph"></p>



<h3 class="wp-block-heading"><strong>Arm deployment wizard </strong></h3>



<p class="wp-block-paragraph">Professional licence users may expedite the deployment by using the Arm deployment wizard. The built in AI will automatically determine the best settings for your design based on the quantisation settings chosen. </p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:45%">
<figure class="wp-block-image size-full is-resized is-style-default"><img loading="lazy" decoding="async" src="https://www.advsolned.com/wp-content/uploads/2018/09/Armwizard.png" alt="" class="wp-image-17853" width="376" height="316" srcset="https://www.advsolned.com/wp-content/uploads/2018/09/Armwizard.png 326w, https://www.advsolned.com/wp-content/uploads/2018/09/Armwizard-300x252.png 300w" sizes="auto, (max-width: 376px) 100vw, 376px" /></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:55%">
<p class="wp-block-paragraph">The built in AI automatically analyses your complete filter cascade and converts any H2 or Heq filters into an H1 for implementation. A complex coefficient filter will be automatically converted to real filter for implementation.</p>
</div>
</div>


<span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>



<h3 class="wp-block-heading"><strong>Implementing the filter in Arm Keil’s MDK</strong></h3>



<p class="wp-block-paragraph">As mentioned in the previous section, the code generated by the Arm CMSIS-DSP code generator may be directly used in any Cortex-M based development project tooling, such as Arm Keil’s industry standard μVision MDK (microcontroller development kit).</p>



<p class="wp-block-paragraph">A complete μVision example IIR biquad filter project can be downloaded from <a style="color: #0000ff;" href="http://www2.keil.com/mdk5/cmsis/asnfd">Keil&#8217;s website</a>, and as seen below is as simple as copying and pasting the code and making minor adjustments to the code.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/asn25_mdk.png"><img loading="lazy" decoding="async" width="828" height="511" src="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_mdk.png" alt="" class="wp-image-12192" srcset="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_mdk.png 828w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_mdk-300x185.png 300w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_mdk-768x474.png 768w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_mdk-705x435.png 705w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_mdk-450x278.png 450w" sizes="auto, (max-width: 828px) 100vw, 828px" /></a></figure>
</div>


<p class="wp-block-paragraph">The example project makes use of μVision’s powerful simulation capabilities, allowing for the evaluation of the IIR filter on M0, M3, M4 and M7 cores respectively. As an added bonus, μVision’s logic analyser may also be used, allowing for comparisons between the ASN Filter Designer’s signal analyser and the reality on a Cortex-M core.</p>



<h2 class="wp-block-heading">Fixed point implementation</h2>



<p class="wp-block-paragraph">As aforementioned, the <strong>Direct Form I</strong> filter structure is the best choice for fixed point implementation. However, before implementing the difference equation on a fixed point processor, several important data scaling considerations must be taken into account. As the CMSIS-DSP framework only supports Q15 and Q31 data types for IIR filters, the following discussion relates to an implementation on a 16-bit word architecture, i.e. Q15.</p>



<h3 class="wp-block-heading"><strong>Quantisation</strong></h3>



<p class="has-text-align-left wp-block-paragraph">In order to correctly represent the coefficients and input/output numbers, the system word length (16-bit for the purposes of this application note) is first split up into its number of integers and fractional components. The general format is given by:</p>



<p class="has-text-align-center wp-block-paragraph"><em>Q Num of Integers.Fraction length</em></p>



<p class="has-text-align-left wp-block-paragraph">If we assume that all of data values lie within a maximum/minimum range of \(\pm 1\), we can use Q0.15 format to represent all of the numbers respectively. Notice that Q0.15 (or simply Q15) format represents a maximum of \(\displaystyle 1-2^{-15}=0.9999=0x7FFF\) and a minimum of \(-1=0x8000\) (two&#8217;s complement format).</p>



<p class="has-text-align-left wp-block-paragraph">The ASN Filter Designer may be configured for <strong>Fixed Point</strong> Q15 arithmetic by setting the <strong>Word length</strong> and <strong>Fractional length</strong> specifications in the <strong>Q</strong> Tab (see the <a style="color: #0000ff;" href="http://www.advsolned.com/implementing-biquad-iir-filters-with-the-asn-filter-designer-and-the-arm-cmsis-dsp-software-framework/#q15config">configuration section</a> for the details). However, one obvious problem that manifests itself for Biquads is the number range of the coefficients. As poles can be placed anywhere inside the unit circle, the resulting polynomial needed for implementation will often be in the range \(\pm 2\), which would require Q14 arithmetic. In order to overcome this issue, all numerator and denominator coefficients are scaled via a biquad Post Scaling Factor as discussed below.</p>



<h3 class="wp-block-heading"><strong>Post Scaling Factor</strong></h3>



<p class="wp-block-paragraph">In order to ensure that coefficients fit within the <strong>Word length</strong> and <strong>Fractional length</strong> specifications, all IIR filters include a <strong>Post Scaling Factor</strong>, which scales the numerator and denominator coefficients accordingly. As a consequence of this scaling, the <strong>Post Scaling Factor</strong> must be included within the filter structure in order to ensure correct operation.</p>



<p class="wp-block-paragraph">The Post scaling concept is illustrated below for a Direct Form I biquad implementation.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/asn25_biquad_postscale.png"><img loading="lazy" decoding="async" width="678" height="316" src="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_biquad_postscale.png" alt="" class="wp-image-12194" srcset="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_biquad_postscale.png 678w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_biquad_postscale-300x140.png 300w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_biquad_postscale-450x210.png 450w" sizes="auto, (max-width: 678px) 100vw, 678px" /></a></figure>
</div>


<p class="has-text-align-center wp-block-paragraph"><em>Figure 4: Direct Form I structure with post scaling.</em></p>



<p class="wp-block-paragraph">Pre-multiplying the numerator coefficients with the section gain, \(K\), each coefficient can now be scaled by \(G\), i.e.&nbsp;\(\displaystyle b_0=\frac{b_0}{G}, b_1=\frac{b_1}{G}, a_1=\frac{a_1}{G}, a_2=\frac{a_2}{G}\) and etc. This now results in the following difference equation:</p>



<p class="has-text-align-center wp-block-paragraph">\(\displaystyle y(n)=G \times\Big [b_0 x(n) + b_1 x(n-1) + b_2 x(n-2) &#8211; a_1 y(n-1)-a_2 y(n-2)\Big]\)<span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span></p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:10%">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="49" height="53" src="https://www.advsolned.com/wp-content/uploads/2018/10/appnote_infosymbol.png" alt="" class="wp-image-12160"/></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">All IIR structures implemented within the tool include the <strong>Post Scaling Factor</strong> concept. This scaling is mandatory for implementation via the Arm CMSIS-DSP framework – see the <a href="http://www.advsolned.com/implementing-biquad-iir-filters-with-the-asn-filter-designer-and-the-arm-cmsis-dsp-software-framework/#q15config">configuration section</a> for more details.</p>
</div>
</div>



<h3 class="wp-block-heading"><strong>Understanding the filter summary</strong></h3>



<p class="wp-block-paragraph">In order to fully understand the information presented in the ASN Filter Designer filter summary, the following example illustrates the filter coefficients obtained with <strong>Double Precision</strong> arithmetic and with <strong>Fixed Point</strong> Q15 quantisation.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/asn25_doubleprec.png"><img loading="lazy" decoding="async" width="722" height="287" src="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_doubleprec.png" alt="" class="wp-image-12196" srcset="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_doubleprec.png 722w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_doubleprec-300x119.png 300w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_doubleprec-705x280.png 705w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_doubleprec-450x179.png 450w" sizes="auto, (max-width: 722px) 100vw, 722px" /></a></figure>
</div>


<p class="wp-block-paragraph">Applying <strong>Fixed Point</strong> Q15 arithmetic (note the effects of quantisation on the coefficient values):</p>


<div class="wp-block-image">
<figure class="aligncenter"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/asn25_fixedpoint.png"><img loading="lazy" decoding="async" width="800" height="350" src="http://www.advsolned.com/wp-content/uploads/2018/09/asn25_fixedpoint.png" alt="" class="wp-image-7883" srcset="https://www.advsolned.com/wp-content/uploads/2018/09/asn25_fixedpoint.png 800w, https://www.advsolned.com/wp-content/uploads/2018/09/asn25_fixedpoint-300x131.png 300w, https://www.advsolned.com/wp-content/uploads/2018/09/asn25_fixedpoint-768x336.png 768w, https://www.advsolned.com/wp-content/uploads/2018/09/asn25_fixedpoint-705x308.png 705w, https://www.advsolned.com/wp-content/uploads/2018/09/asn25_fixedpoint-450x197.png 450w" sizes="auto, (max-width: 800px) 100vw, 800px" /></a></figure>
</div>


<h3 class="wp-block-heading" id="q15config"><strong>Configuring the ASN Filter Designer for Fixed Point arithmetic</strong></h3>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">In order to implement an IIR fixed point filter via the CMSIS-DSP framework, all designs must be based on <strong>Fixed Point</strong> arithmetic (either Q15 or Q31) and the <strong>Direct Form I</strong> filter structure.<span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span></p>
</blockquote>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="370" height="288" src="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_fixedpointquant.png" alt="" class="wp-image-12173" srcset="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_fixedpointquant.png 370w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_fixedpointquant-300x234.png 300w" sizes="auto, (max-width: 370px) 100vw, 370px" /></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">Quantisation and filter structure settings can be found under the <strong>Q</strong> tab (as shown on the left): Setting <strong>Arithmetic</strong> to <strong>Fixed Point</strong> and <strong>Structure</strong> to <strong>Direct Form I</strong> and clicking on the <strong>Apply</strong> button configures the IIR considered herein for the CMSIS-DSP software framework.</p>
</div>
</div>


<span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:10%">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="49" height="53" src="https://www.advsolned.com/wp-content/uploads/2018/10/appnote_infosymbol.png" alt="" class="wp-image-12160"/></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">The <strong>Post Scaling Factor</strong> is actually implemented in the CMSIS-DSP software framework as \( \log_2 G\) (i.e. a shift left scaling operation as depicted in <a href="http://www.advsolned.com/implementing-biquad-iir-filters-with-the-asn-filter-designer-and-the-arm-cmsis-dsp-software-framework/#figure4">Figure 4</a>).</p>
</div>
</div>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:10%">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="49" height="53" src="https://www.advsolned.com/wp-content/uploads/2018/10/appnote_infosymbol.png" alt="" class="wp-image-12160"/></figure>



<p class="wp-block-paragraph"></p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">Built in analytics: the tool will automatically analyse the cascade’s filter coefficients and choose an appropriate scaling factor. As seen above, as the largest minimum value is -1.63143, thus, a <strong>Post Scaling Factor</strong> of 2 is required in order to ‘fit’ all of the coefficients into Q15 arithmetic.</p>
</div>
</div>



<h3 class="wp-block-heading"><strong><span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span>Comparing spectra obtained by different arithmetic rules</strong></h3>



<p class="wp-block-paragraph">In order to improve clarity and overall computation speed, the ASN Filter Designer only displays spectra (i.e. magnitude, phase etc.) based on the current arithmetic rules. This is somewhat different to other tools that display multi-spectra obtained by (for example) <strong>Fixed Point</strong> and <strong>Double Precision</strong> arithmetic. For any users wishing to compare spectra you may simply switch between arithmetic settings by changing the <strong>Arithmetic</strong> method. The designer will then automatically re-compute the filter coefficients using the selected arithmetic rules and the current technical specification. The chart will then be updated using the current zoom settings.</p>



<h3 class="wp-block-heading"><strong>Automatic code generation to the Arm CMSIS-DSP framework</strong></h3>



<p class="wp-block-paragraph">As with floating point arithmetic, select the <strong>Arm CMSIS-DSP</strong> framework from the selection box in the filter summary window:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/arm_code_selection.png"><img loading="lazy" decoding="async" width="166" height="144" src="https://www.advsolned.com/wp-content/uploads/2020/04/arm_code_selection-2.png" alt="" class="wp-image-12197"/></a></figure>
</div>


<p class="wp-block-paragraph">The automatically generated C code based on the CMSIS-DSP framework for direct implementation on an Arm based Cortex-M processor is shown below:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/asn25_armcodeQ15.png"><img loading="lazy" decoding="async" width="724" height="489" src="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_armcodeQ15.png" alt="" class="wp-image-12198" srcset="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_armcodeQ15.png 724w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_armcodeQ15-300x203.png 300w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_armcodeQ15-705x476.png 705w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_armcodeQ15-450x304.png 450w" sizes="auto, (max-width: 724px) 100vw, 724px" /></a></figure>
</div>


<p class="wp-block-paragraph">As with the floating point filter, the automatic code generator generates all initialisation code, scaling and data structures needed to implement the IIR via the CMSIS-DSP library. This code may be directly used in any Cortex-M based development project &#8211; a <a style="color: #0000ff;" href="http://www2.keil.com/mdk5/cmsis/asnfd">complete Keil MDK example</a> is available on Arm/Keil&#8217;s website. Notice that the tool’s code generator produces code for the Cortex-M4 core as default, please refer to the table below for the <code>#define</code> definition required for all supported cores.</p>



<figure class="wp-block-table"><table><tbody><tr><td><code>ARM_MATH_CM0</code></td><td>Cortex-M0 core.</td><td><code>ARM_MATH_CM4</code></td><td>Cortex-M4 core.</td></tr><tr><td><code>ARM_MATH_CM0PLUS</code></td><td>Cortex-M0+ core.</td><td><code>ARM_MATH_CM7</code></td><td>Cortex-M7 core.</td></tr><tr><td><code>ARM_MATH_CM3</code></td><td>Cortex-M3 core.</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>ARM_MATH_ARMV8MBL</code></td><td>ARMv8M Baseline target (Cortex-M23 core).</td></tr><tr><td><code>ARM_MATH_ARMV8MML</code></td><td>ARMv8M Mainline target (Cortex-M33 core).</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">The main test loop code (not shown) centres around the <code>arm_biquad_cascade_df2T_f32()</code> function, which performs the filtering operation on a block of input data.<span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span></p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:10%">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="49" height="53" src="https://www.advsolned.com/wp-content/uploads/2018/10/appnote_infosymbol.png" alt="" class="wp-image-12160"/></figure>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">Complex coefficient IIR filters are currently not supported.</p>
</div>
</div>



<h2 class="wp-block-heading">Validating the design with the signal analyser</h2>



<p class="wp-block-paragraph">A design may be validated with the signal analyser, where both time and frequency domain plots are supported. A comprehensive signal generator is fully integrated into the signal analyser allowing designers to test their filters with a variety of input signals, such as sine waves, white noise or even external test data.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/asn25_signalanalyser.png"><img loading="lazy" decoding="async" width="817" height="643" src="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_signalanalyser.png" alt="" class="wp-image-12199" srcset="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_signalanalyser.png 817w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_signalanalyser-300x236.png 300w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_signalanalyser-768x604.png 768w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_signalanalyser-705x555.png 705w, https://www.advsolned.com/wp-content/uploads/2020/04/asn25_signalanalyser-450x354.png 450w" sizes="auto, (max-width: 817px) 100vw, 817px" /></a></figure>
</div>


<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="242" height="167" src="https://www.advsolned.com/wp-content/uploads/2020/04/asn25_accsettings.png" alt="" class="wp-image-12175"/></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">For Fixed Point implementations, the tool allows designers to specify the <strong>Overflow</strong> arithmetic rules as: <strong>Saturate</strong> or <strong>Wrap</strong>. Also, the <strong>Accumulator Word Length</strong> may be set between 16-40 bits allowing designers to quickly find the optimum settings to suit their application.</p>
</div>
</div>



<h2 class="wp-block-heading">&nbsp;</h2>


<span class="" style="display:block;clear:both;height: 0px;padding-top: 15px;border-top-width:0px;border-bottom-width:0px;"></span>



<h2 class="wp-block-heading"><strong>Extra resources</strong></h2>



<ol class="wp-block-list">
<li>Digital signal processing: principles, algorithms and applications, J.Proakis and D.Manoloakis</li>



<li>Digital signal processing: a practical approach, E.Ifeachor and B.Jervis.</li>



<li>Digital filters and signal processing, L.Jackson.</li>



<li>Step by step <a style="color: #0000ff;" href="https://youtu.be/ltikbqR9nK8">video tutorial</a> of designing an IIR and deploying it to Keil MDK uVision.</li>



<li>Implementing Biquad IIR filters with the ASN Filter Designer and the Arm CMSIS-DSP software framework <a style="color: #0000ff;" href="http://www.advsolned.com/wp-content/uploads/2018/05/Implementing-Biquad-IIR-filters-with-the-ASN-Filter-Designer-and-the-ARM-CMSIS-DSP-software-framework.pdf">(ASN-AN025)</a></li>



<li>Keil MDK uVision <a style="color: #0000ff;" href="http://www2.keil.com/mdk5/cmsis/asnfd">example IIR filter project</a></li>
</ol>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%"></div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%"></div>
</div>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:50%">
<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.advsolned.com/wp-content/uploads/2019/12/Softwareboxshadow-verkleind-495x400_verleind.jpg" alt="ASN Filter Designer box" class="wp-image-10817" width="495" height="400" srcset="https://www.advsolned.com/wp-content/uploads/2019/12/Softwareboxshadow-verkleind-495x400_verleind.jpg 495w, https://www.advsolned.com/wp-content/uploads/2019/12/Softwareboxshadow-verkleind-495x400_verleind-300x242.jpg 300w, https://www.advsolned.com/wp-content/uploads/2019/12/Softwareboxshadow-verkleind-495x400_verleind-450x364.jpg 450w" sizes="auto, (max-width: 495px) 100vw, 495px" /></figure>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:50%">
<div class="wp-block-buttons is-layout-flex wp-container-core-buttons-is-layout-00436373 wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link has-vivid-cyan-blue-background-color has-text-color has-background wp-element-button" href="https://www.advsolned.com/request-form-asn-filter-designer-demo/" style="color:#ffffff">Download Demo</a></div>
</div>


<span class="" style="display:block;clear:both;height: 0px;padding-top: 25px;border-top-width:0px;border-bottom-width:0px;"></span>



<div class="wp-block-buttons is-layout-flex wp-container-core-buttons-is-layout-a68e0a8e wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link has-vivid-cyan-blue-background-color has-text-color has-background wp-element-button" style="color:#ffffff">Pricing and Licencing</a></div>
</div>



<p class="wp-block-paragraph"></p>


<span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>
</div>
</div>


<p><span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>
                
                    <!--begin code -->

                    
                    <div class="pp-multiple-authors-boxes-wrapper pp-multiple-authors-wrapper pp-multiple-authors-layout-boxed multiple-authors-target-shortcode box-post-id-19551 box-instance-id-1 ppma_boxes_19551"
                    data-post_id="19551"
                    data-instance_id="1"
                    data-additional_class="pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode"
                    data-original_class="pp-multiple-authors-boxes-wrapper pp-multiple-authors-wrapper box-post-id-19551 box-instance-id-1">
                                                                                    <h2 class="widget-title box-header-title">Author</h2>
                                                                            <span class="ppma-layout-prefix"></span>
                        <div class="ppma-author-category-wrap">
                                                                                                                                    <span class="ppma-category-group ppma-category-group-1 category-index-0">
                                                                                                                        <ul class="pp-multiple-authors-boxes-ul author-ul-0">
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                    <li class="pp-multiple-authors-boxes-li author_index_0 author_ssarpal has-avatar">
                                                                                                                                                                                    <div class="pp-author-boxes-avatar">
                                                                    <div class="avatar-image">
                                                                                                                                                                                                                <img alt='' src='https://www.advsolned.com/wp-content/uploads/2023/05/sanjeevsarpal.jpeg' srcset='https://www.advsolned.com/wp-content/uploads/2023/05/sanjeevsarpal.jpeg' class='multiple_authors_guest_author_avatar avatar' height='80' width='80'/>                                                                                                                                                                                                            </div>
                                                                                                                                    </div>
                                                            
                                                            <div class="pp-author-boxes-avatar-details">
                                                                <div class="pp-author-boxes-name multiple-authors-name"><a href="https://www.advsolned.com/author/ssarpal/" rel="author" title="Dr. Sanjeev Sarpal" class="author url fn">Dr. Sanjeev Sarpal</a></div>                                                                                                                                                                                                    
                                                                                                                                            <div class="pp-author-boxes-description multiple-authors-description author-description-0">
                                                                                                                                                    <p>Sanjeev is a RTEI (Real-Time Edge Intelligence) visionary and expert in signals and systems with a track record of successfully developing over 26 commercial products. He is a Distinguished Arm Ambassador and advises top international blue chip companies on their AIoT/RTEI solutions and strategies for I5.0, telemedicine, smart healthcare, smart grids and smart buildings.</p>
                                                                                                                                                </div>
                                                                                                                                                                                                    
                                                                                                                                    <span class="pp-author-boxes-meta multiple-authors-links">
                                                                        <a href="https://www.advsolned.com/author/ssarpal/" title="View all posts">
                                                                            <span>View all posts</span>
                                                                        </a>
                                                                    </span>
                                                                                                                                <a class="ppma-author-user_email-profile-data ppma-author-field-meta ppma-author-field-type-email" aria-label="Email" href="mailto:sanjeev.sarpal@advsolned.com"  target="_self"><span class="dashicons dashicons-email-alt"></span> </a>
                                                                                                                            </div>
                                                                                                                                                                                                                        </li>
                                                                                                                                                                                                                                                                                        </ul>
                                                                            </span>
                                                                                                                        </div>
                        <span class="ppma-layout-suffix"></span>
                                            </div>
                    <!--end code -->
                    
                
                            
        </p>



<p class="wp-block-paragraph"></p>
		<div class="wpulike wpulike-default " ><div class="wp_ulike_general_class wp_ulike_is_restricted"><button type="button"
					aria-label="Like Button"
					data-ulike-id="7877"
					data-ulike-nonce="bf60031b8a"
					data-ulike-type="post"
					data-ulike-template="wpulike-default"
					data-ulike-display-likers=""
					data-ulike-likers-style="popover"
					class="wp_ulike_btn wp_ulike_put_image wp_post_btn_7877"></button><span class="count-box wp_ulike_counter_up" data-ulike-counter-value="+3"></span>			</div></div>
	<p>The post <a rel="nofollow" href="https://www.advsolned.com/implementing-biquad-iir-filters-with-the-asn-filter-designer-and-the-arm-cmsis-dsp-software-framework/">Implementing Biquad IIR filters with the ASN Filter Designer and the Arm CMSIS-DSP software framework</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>All-pass filter</title>
		<link>https://www.advsolned.com/all-pass-filter/</link>
		
		<dc:creator><![CDATA[Dr. Sanjeev Sarpal]]></dc:creator>
		<pubDate>Thu, 05 Jul 2018 15:18:25 +0000</pubDate>
				<category><![CDATA[ASN FilterScript]]></category>
		<category><![CDATA[allpass filter]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[biquad]]></category>
		<category><![CDATA[equaliser]]></category>
		<category><![CDATA[IIR]]></category>
		<guid isPermaLink="false">http://www.advsolned.com/?p=6118</guid>

					<description><![CDATA[<p>All-pass filters (phase equalisers) provide a simple way of altering/improving the phase response of an IIR without affecting its magnitude response.</p>
<p>The post <a rel="nofollow" href="https://www.advsolned.com/all-pass-filter/">All-pass filter</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div style='padding-bottom:10px; ' class='av-special-heading av-special-heading-h1     '><h1 class='av-special-heading-tag '  itemprop="headline"  >All-pass filters</h1><div class='special-heading-border'><div class='special-heading-inner-border' ></div></div></div>
<p><section class="av_textblock_section "  itemscope="itemscope" itemtype="https://schema.org/BlogPosting" itemprop="blogPost" ><div class='avia_textblock  '   itemprop="text" ><p>All-pass filters provide a simple way of altering/improving the phase response of an IIR without affecting its magnitude response. As such, they are commonly referred to as phase equalisers and have found particular use in digital audio applications.</p>
<p>In its simplest form, a filter can be constructed from a first order transfer function, i.e.,</p>
<p style="text-align: center;">\( A(z)=\Large{\frac{r+z^{-1}}{1+r z^{-1}}}  \, \,  \normalsize{; r&lt;1} \)</p>
<p>Analysing \(\small A(z)\), notice that the pole and zero lie on the real z-plane axis and that the pole at radius \(\small r\) has a zero at radius \(\small 1/r\), such that the poles and zeros are reciprocals of another. This property is key to the all-pass filter concept, as we will now see by expanding the concept further to a second order all-pass filter:</p>
<p style="text-align: center;">\( A(z)=\Large\frac{r^2-2rcos \left( \frac{2\pi f_c}{fs}\right) z^{-1}+z^{-2}}{1-2rcos \left( \frac{2\pi f_c}{fs}\right)z^{-1}+r^2 z^{-2}} \)</p>
<p>Where, \(\small f_c\) is the centre frequency, \(\small r\) is radius of the poles and<a href="http://www.advsolned.com/wp-content/uploads/2018/07/allpassPZ.png"><img loading="lazy" decoding="async" class="alignright wp-image-6129 size-square" style="margin-top: 15px; margin-bottom: 15px; margin-left: 40px;" src="https://www.advsolned.com/wp-content/uploads/2018/07/allpassPZ-180x180.png" alt="all pass filter, all-pass filter, allpass filter, all pass pole-zero" width="180" height="180" srcset="https://www.advsolned.com/wp-content/uploads/2018/07/allpassPZ-180x180.png 180w, https://www.advsolned.com/wp-content/uploads/2018/07/allpassPZ-80x80.png 80w, https://www.advsolned.com/wp-content/uploads/2018/07/allpassPZ-36x36.png 36w, https://www.advsolned.com/wp-content/uploads/2018/07/allpassPZ-120x120.png 120w" sizes="auto, (max-width: 180px) 100vw, 180px" /></a> \(\small f_s\) is the sampling frequency. Notice how the numerator and denominator coefficients are arranged as a <strong>mirror image pair</strong> of one another.  The mirror image property is what gives the all-pass filter its desirable property, namely allowing the designer to alter the phase response while keeping the magnitude response constant or flat over the complete frequency spectrum.</p>
<p style="text-align: center;"><a href="http://www.advsolned.com/wp-content/uploads/2018/07/allpass.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-6122 size-full" src="https://www.advsolned.com/wp-content/uploads/2018/07/allpass.png" alt="all pass filter, all-pass filter, allpass, phase equaliser, altering/improving the phase response of an IIR without affecting its magnitude response" width="426" height="422" srcset="https://www.advsolned.com/wp-content/uploads/2018/07/allpass.png 426w, https://www.advsolned.com/wp-content/uploads/2018/07/allpass-80x80.png 80w, https://www.advsolned.com/wp-content/uploads/2018/07/allpass-300x297.png 300w, https://www.advsolned.com/wp-content/uploads/2018/07/allpass-36x36.png 36w, https://www.advsolned.com/wp-content/uploads/2018/07/allpass-120x120.png 120w" sizes="auto, (max-width: 426px) 100vw, 426px" /></a><em>Frequency response of all-pass filter:<br />
</em><em>Notice the constant magnitude spectrum (shown in blue). </em></p>
<span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span>
<h2>Implementation</h2>
<p>An All-pass filter may be implemented in <span style="color: #0000ff;"><a style="color: #0000ff;" href="http://www.advsolned.com/asn_filter_designer/#live-math-scripting">ASN FilterScript</a></span> as follows:<br />
[code language=&#8221;java&#8221;]<br />
ClearH1;  // clear primary filter from cascade</p>
<p>interface radius = {0,2,0.01,0.5};   // radius value<br />
interface fc = {0,fs/2,1,fs/10};     // frequency value</p>
<p>Main()<br />
Num = {radius^2,-2*radius*cos(Twopi*fc/fs),1};<br />
Den = reverse(Num); // mirror image of Num<br />
Gain = 1;</p>
<p>[/code]<br />
<span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span>For a detailed discussion on IIR filter phase equalisation, and the ASN Filter designer&#8217;s APF (all-pass filter) design tool, please refer to the following <a style="color: #0000ff;" href="https://www.advsolned.com/linear-phase-iir-filters-analysis-and-design/">article</a>. <span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span></p>
<p><a href="https://www.advsolned.com/asn_filter_designer/"><img loading="lazy" decoding="async" class="alignleft wp-image-3310" style="margin: 10px 80px 10px 20px;" src="http://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox.png" alt="ASN Filter Designer DSP" width="183" height="253" srcset="https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox.png 800w, https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox-217x300.png 217w, https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox-768x1062.png 768w, https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox-745x1030.png 745w, https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox-510x705.png 510w, https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox-450x622.png 450w" sizes="auto, (max-width: 183px) 100vw, 183px" /></a></p>
<p style="text-align: left;"></br><a class="button" href="http://www.advsolned.com/request-form-asn-filter-designer-demo/">Download demo now</a></p>
<p><a class="button" href="http://www.advsolned.com/pricing-and-licencing/#Best_licence_forme">Licencing information</a></p>
</div></section><span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>
                
                    <!--begin code -->

                    
                    <div class="pp-multiple-authors-boxes-wrapper pp-multiple-authors-wrapper pp-multiple-authors-layout-boxed multiple-authors-target-shortcode box-post-id-19551 box-instance-id-1 ppma_boxes_19551"
                    data-post_id="19551"
                    data-instance_id="1"
                    data-additional_class="pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode"
                    data-original_class="pp-multiple-authors-boxes-wrapper pp-multiple-authors-wrapper box-post-id-19551 box-instance-id-1">
                                                                                    <h2 class="widget-title box-header-title">Author</h2>
                                                                            <span class="ppma-layout-prefix"></span>
                        <div class="ppma-author-category-wrap">
                                                                                                                                    <span class="ppma-category-group ppma-category-group-1 category-index-0">
                                                                                                                        <ul class="pp-multiple-authors-boxes-ul author-ul-0">
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                    <li class="pp-multiple-authors-boxes-li author_index_0 author_ssarpal has-avatar">
                                                                                                                                                                                    <div class="pp-author-boxes-avatar">
                                                                    <div class="avatar-image">
                                                                                                                                                                                                                <img alt='' src='https://www.advsolned.com/wp-content/uploads/2023/05/sanjeevsarpal.jpeg' srcset='https://www.advsolned.com/wp-content/uploads/2023/05/sanjeevsarpal.jpeg' class='multiple_authors_guest_author_avatar avatar' height='80' width='80'/>                                                                                                                                                                                                            </div>
                                                                                                                                    </div>
                                                            
                                                            <div class="pp-author-boxes-avatar-details">
                                                                <div class="pp-author-boxes-name multiple-authors-name"><a href="https://www.advsolned.com/author/ssarpal/" rel="author" title="Dr. Sanjeev Sarpal" class="author url fn">Dr. Sanjeev Sarpal</a></div>                                                                                                                                                                                                    
                                                                                                                                            <div class="pp-author-boxes-description multiple-authors-description author-description-0">
                                                                                                                                                    <p>Sanjeev is a RTEI (Real-Time Edge Intelligence) visionary and expert in signals and systems with a track record of successfully developing over 26 commercial products. He is a Distinguished Arm Ambassador and advises top international blue chip companies on their AIoT/RTEI solutions and strategies for I5.0, telemedicine, smart healthcare, smart grids and smart buildings.</p>
                                                                                                                                                </div>
                                                                                                                                                                                                    
                                                                                                                                    <span class="pp-author-boxes-meta multiple-authors-links">
                                                                        <a href="https://www.advsolned.com/author/ssarpal/" title="View all posts">
                                                                            <span>View all posts</span>
                                                                        </a>
                                                                    </span>
                                                                                                                                <a class="ppma-author-user_email-profile-data ppma-author-field-meta ppma-author-field-type-email" aria-label="Email" href="mailto:sanjeev.sarpal@advsolned.com"  target="_self"><span class="dashicons dashicons-email-alt"></span> </a>
                                                                                                                            </div>
                                                                                                                                                                                                                        </li>
                                                                                                                                                                                                                                                                                        </ul>
                                                                            </span>
                                                                                                                        </div>
                        <span class="ppma-layout-suffix"></span>
                                            </div>
                    <!--end code -->
                    
                
                            
        </p>
		<div class="wpulike wpulike-default " ><div class="wp_ulike_general_class wp_ulike_is_restricted"><button type="button"
					aria-label="Like Button"
					data-ulike-id="6118"
					data-ulike-nonce="f2c85c63b8"
					data-ulike-type="post"
					data-ulike-template="wpulike-default"
					data-ulike-display-likers=""
					data-ulike-likers-style="popover"
					class="wp_ulike_btn wp_ulike_put_image wp_post_btn_6118"></button><span class="count-box wp_ulike_counter_up" data-ulike-counter-value="+4"></span>			</div></div>
	<p>The post <a rel="nofollow" href="https://www.advsolned.com/all-pass-filter/">All-pass filter</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
