<?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>ASN FilterScript &#8211; ASN Home</title>
	<atom:link href="https://www.advsolned.com/category/asn-filterscript/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.advsolned.com</link>
	<description>ASN home site</description>
	<lastBuildDate>Fri, 05 Sep 2025 08:22:37 +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>FIR notch filter from a lowpass filter</title>
		<link>https://www.advsolned.com/fir-notch-filter-from-a-lowpass-filter/</link>
					<comments>https://www.advsolned.com/fir-notch-filter-from-a-lowpass-filter/#respond</comments>
		
		<dc:creator><![CDATA[ASN consultancy team]]></dc:creator>
		<pubDate>Sat, 04 Sep 2021 12:11:01 +0000</pubDate>
				<category><![CDATA[ASN FilterScript]]></category>
		<category><![CDATA[Biomedical]]></category>
		<category><![CDATA[biomedical]]></category>
		<category><![CDATA[DSP]]></category>
		<category><![CDATA[lowpass]]></category>
		<category><![CDATA[notchfilter]]></category>
		<guid isPermaLink="false">https://www.advsolned.com/?p=17540</guid>

					<description><![CDATA[<p>Designs an FIR notch filter from a lowpass filter by computing the difference between the prototype lowpass filter and its amplitude complementary</p>
<p>The post <a rel="nofollow" href="https://www.advsolned.com/fir-notch-filter-from-a-lowpass-filter/">FIR notch filter from a lowpass filter</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="flex_column av_one_full  flex_column_div av-zero-column-padding first  " style='border-radius:0px; '><div style='padding-bottom:10px; ' class='av-special-heading av-special-heading-h1     '><h1 class='av-special-heading-tag '  itemprop="headline"  >FIR notch filter from a lowpass filter</h1><div class='special-heading-border'><div class='special-heading-inner-border' ></div></div></div></div>
<div class="flex_column av_one_fifth  flex_column_div av-zero-column-padding first  " style='border-radius:0px; '></div>
<div class="flex_column av_one_half  flex_column_div av-zero-column-padding   " style='border-radius:0px; '><div class='avia-image-container  av-styling-     avia-align-center '  itemprop="ImageObject" itemscope="itemscope" itemtype="https://schema.org/ImageObject"  ><div class='avia-image-container-inner'><div class='avia-image-overlay-wrap'><img class='avia_image' src='https://www.advsolned.com/wp-content/uploads/2021/09/linearnotch.png' alt='linear notch' title='linear notch' height="665" width="582"  itemprop="thumbnailUrl"  /></div></div></div></div>
<div class="flex_column av_two_fifth  flex_column_div av-zero-column-padding first  " style='border-radius:0px; '></div>
<div class="flex_column av_one_full  flex_column_div av-zero-column-padding first  " style='border-radius:0px; '><p><section class="av_textblock_section "  itemscope="itemscope" itemtype="https://schema.org/BlogPosting" itemprop="blogPost" ><div class='avia_textblock  '   itemprop="text" ><p><strong>Syntax</strong><br /><code>Hd = firlp2notch(Hd,DFormat)</code></p>
<p><strong>Description</strong><br />Designs an FIR notch filter from a lowpass filter by computing the difference between the prototype lowpass filter and its amplitude complementary, i.e. \( \displaystyle{H_{BSF}(z)=2H_{LPF}(z)-1.}\)</p>
<p>The resulting bandstop filter (BSF) or notch filter has linear phase (odd length), but a 180-degree phase shift at the notch frequency. This means that all frequencies &gt; notch frequency will be shifted by 180 degrees. For biomedical applications, this excess phase shift is undesirable and may be overcome by cascading two identical filters, such that the phase shift is 360 degrees. The <span style="font-family: courier;">augument()</span> function should be used for achieving this, as shown below in the example.</p>
<p><span style="font-family: courier;">Hd</span>: the <span style="font-family: courier;">firlp2notch</span> method designs an FIR notch (bandstop) filter based on the entered specifications and places the transfer function (i.e. numerator and gain) into a digital filter object, <span style="font-family: courier;">Hd</span>. For even length filters, the method will automatically add an extra coefficient at the centre of the impulse response in order to make it odd in length. The digital filter object can then be combined with other methods if so required. For a digital filter object, <span style="font-family: courier;">Hd</span>, calling <span style="font-family: courier;">getnum(Hd)</span> ) and <span style="font-family: courier;">getgain(Hd)</span> will extract the numerator and gain coefficients respectively – see below.</p>
<p><span style="font-family: courier;">DFormat</span>: allows you to specify the display format of resulting digital filter object.</p>
<table width="833">
<tbody>
<tr>
<td><code>symbolic</code></td>
<td>Display a symbolic representation of the filter object. If the order &gt; 10, the <code>symbolic</code> display option will be overridden and set to <code>numeric</code>.</td>
</tr>
<tr>
<td><code>numeric</code></td>
<td>Display a matrix representation of the filter object</td>
</tr>
<tr>
<td><code>void</code></td>
<td>Create a filter object, but do not display output</td>
</tr>
</tbody>
</table>
<p><strong>Examples</strong></p>
<pre class="brush: java">interface F = {10,400,2,44}; // frequency spec (2 bands for bandstop)
interface TW ={1,40,2,12}; // Band transition width
interface N = {20,300,1,36};

Main() // main loop

Freq={F,F+TW};   // frequency specification

Hd=firwin(N,Freq,"hanning","lowpass","numeric");

Hd=firlp2notch(Hd,"void");
Hd=augment(Hd,Hd,"void"); // compensate for 180 phase shift by cascading a second filter

Num=getnum(Hd);
Den=getden(Hd);
Gain=getgain(Hd);

</pre>
</div></section><br />
<div style='padding-bottom:10px; ' class='av-special-heading av-special-heading-h2     '><h2 class='av-special-heading-tag '  itemprop="headline"  >Biomedical filtering application</h2><div class='special-heading-border'><div class='special-heading-inner-border' ></div></div></div><br />
<section class="av_textblock_section "  itemscope="itemscope" itemtype="https://schema.org/BlogPosting" itemprop="blogPost" ><div class='avia_textblock  '   itemprop="text" ><p>The <code>firlp2notch</code> function can used in conjunction with <code>dcremover</code> function in order to build an ECG biomedical filtering cascade with linear phase around the notch cut-off frequency. Notice that the two filters are split up into the H1 and H2 filters respectively, and may therefore be optimised independently to each other.</p>
</div></section><br />
<div style='height:20px' class='hr hr-invisible   '><span class='hr-inner ' ><span class='hr-inner-style'></span></span></div><br />
<section class="av_textblock_section "  itemscope="itemscope" itemtype="https://schema.org/BlogPosting" itemprop="blogPost" ><div class='avia_textblock  '   itemprop="text" ><pre class="brush: java">// Biomedical HPF + FIR notch filter.
// This notch filter removes 50/60Hz power line interference while
// maintaining linear phase around the notch cut-off frequency. The DC offset
// and low frequencies are removed via the H1 IIR HPF.
//
// Copyright Advanced Solutions Nederland 2021
// Revision: 1.00

interface F = {10,400,2,44}; // frequency spec (2 bands for bandstop)
interface TW ={1,40,2,12}; // Band transition width
interface R ={10,80,5,40}; // Band transition width
interface N = {20,300,1,36};

Main() // main loop 

Freq={F,F+TW};   // frequency specification

//Hd=firkaiser(Freq*fsunits,R,"lowpass","numeric");
Hd=firwin(N,Freq,"hanning","lowpass","numeric");

Hd=firlp2notch(Hd,"void");
Hd=augment(Hd,Hd,"void"); // compensate for 180 phase shift by cascading a second filter

Hd1=dcremover(2,"void");

Num=getnum(Hd);
Den=getden(Hd);
Gain=getgain(Hd);

H1Num=getnum(Hd1);
H1Den=getden(Hd1);
H1Gain=getgain(Hd1);
</pre>
<p><span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span><br />Designers are also referred to the following <a href="https://www.advsolned.com/wp-content/uploads/2021/10/ASN-AN029.pdf"><span style="color: #0000ff;">application note</span></a> that discusses the design and implementation of the Pan-Tompkins filter cascade for QRS complex detection in ECG signals.</p>
<p><strong>See also:</strong></p>
<p><a href="https://www.advsolned.com/fir-moving-average-filter/"><span style="color: #0000ff;">movaver</span></a> / <a href="https://www.advsolned.com/fir-filter-window-method/"><span style="color: #0000ff;">firwin</span></a> / <a href="https://www.advsolned.com/fir-arbitrary-magnitude-response-filter/"><span style="color: #0000ff;">firarb</span></a> / <a href="https://www.advsolned.com/kaiser-window-fir-filter/"><span style="color: #0000ff;">firkaiser</span></a> / <a href="https://www.advsolned.com/fir-gaussian-lowpass-filter/"><span style="color: #0000ff;">firgauss</span></a> / <a href="https://www.advsolned.com/fir-notch-filter-from-a-lowpass-filter/"><span style="color: #0000ff;">firlp2notch</span></a> / <a href="https://www.advsolned.com/savitzky-golay-filter/"><span style="color: #0000ff;">savgolay</span></a></p>
</div></section></p></div>
		<div class="wpulike wpulike-default " ><div class="wp_ulike_general_class wp_ulike_is_not_liked"><button type="button"
					aria-label="Like Button"
					data-ulike-id="17540"
					data-ulike-nonce="f134676489"
					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_17540"></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/fir-notch-filter-from-a-lowpass-filter/">FIR notch filter from a lowpass filter</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.advsolned.com/fir-notch-filter-from-a-lowpass-filter/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Chebyshev Filters</title>
		<link>https://www.advsolned.com/chebyshev-filters/</link>
					<comments>https://www.advsolned.com/chebyshev-filters/#respond</comments>
		
		<dc:creator><![CDATA[ASN consultancy team]]></dc:creator>
		<pubDate>Wed, 26 Aug 2020 08:17:06 +0000</pubDate>
				<category><![CDATA[ASN FilterScript]]></category>
		<category><![CDATA[ASN Filter Designer]]></category>
		<category><![CDATA[Chebyshev]]></category>
		<category><![CDATA[DSP]]></category>
		<guid isPermaLink="false">https://www.advsolned.com/?p=13954</guid>

					<description><![CDATA[<p>Chebyshev I and Chebyshev II filters: what are the advantages and disadvantages? And what is the syntax of Chebyshev, explained with ASN Filterscript</p>
<p>The post <a rel="nofollow" href="https://www.advsolned.com/chebyshev-filters/">Chebyshev Filters</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  blockquote modern-quote modern-centered   '><h1 class='av-special-heading-tag '  itemprop="headline"  >Chebyshev Filters: applications and code examples</h1><div class='special-heading-border'><div class='special-heading-inner-border' ></div></div></div>
<section class="av_textblock_section "  itemscope="itemscope" itemtype="https://schema.org/BlogPosting" itemprop="blogPost" ><div class='avia_textblock  '   itemprop="text" ><p>This article discusses the advantages and disadvantages of the Chebyshev filter, including code examples in <span style="color: #0000ff;"><a style="color: #0000ff;" href="https://www.advsolned.com/asn-filterscript-reference/">ASN Filterscript</a></span>.</p>
<p>Chebyshev Type II filters have flat passbands (no ripple), making them a good choice for DC and low frequency measurement applications, such as bridge sensors (e.g. loadcells). However, this desirable property comes at the expense of wider transition bands, resulting in low passband to stopband transition (slow roll-off). The Chebyshev Type I roll-off faster but have passband ripple and very non-linear passband phase characteristics.</p>
<h2 class="wp-block-heading" id="Chebyshev">Chebyshev Type I</h2>
<p>Chebyshev Type I filters are equiripple in the passband and monotonic in the stopband. As such, Type I filters roll off faster than Chebyshev Type II and Butterworth filters, but at the expense of greater passband ripple.</p>
<div class="wp-block-image">
<figure class="aligncenter"><a href="http://www.advsolned.com/wp-content/uploads/2018/07/Chebyshev-type-I-5th-order.png"><img decoding="async" width="577" height="656" class="wp-image-6437" src="http://www.advsolned.com/wp-content/uploads/2018/07/Chebyshev-type-I-5th-order.png" alt="Chebyshev I; Chebyshev type 1 filter" srcset="https://www.advsolned.com/wp-content/uploads/2018/07/Chebyshev-type-I-5th-order.png 577w, https://www.advsolned.com/wp-content/uploads/2018/07/Chebyshev-type-I-5th-order-264x300.png 264w, https://www.advsolned.com/wp-content/uploads/2018/07/Chebyshev-type-I-5th-order-450x512.png 450w" sizes="(max-width: 577px) 100vw, 577px" /></a></figure>
</div>
<h3 class="wp-block-heading"><strong>Filter characteristics</strong></h3>
<ul class="wp-block-list">
<li>Passband ripple</li>
<li>Maximally flat stopband</li>
<li>Faster roll-off than Butterworth and Chebyshev Type II</li>
<li>Good compromise between Elliptic and Butterworth</li>
</ul>
<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>Chebyshev Type II</h2>
<p>Chebyshev Type II filters are monotonic in the passband and equiripple in the stopband making them a good choice for bridge sensor applications. Although filters designed using the Type II method are slower to roll-off than those designed with the Chebyshev Type I method, the roll-off is faster than those designed with the Butterworth method.</p>
<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="577" height="656" class="wp-image-6436" src="https://www.advsolned.com/wp-content/uploads/2018/07/Chebyshev-type-II-5th-order.png" alt="Chebyshev type II 5th order" srcset="https://www.advsolned.com/wp-content/uploads/2018/07/Chebyshev-type-II-5th-order.png 577w, https://www.advsolned.com/wp-content/uploads/2018/07/Chebyshev-type-II-5th-order-264x300.png 264w, https://www.advsolned.com/wp-content/uploads/2018/07/Chebyshev-type-II-5th-order-450x512.png 450w" sizes="(max-width: 577px) 100vw, 577px" /></figure>
</div>
<h3 class="wp-block-heading"><strong>Filter characteristics</strong></h3>
<ul class="wp-block-list">
<li>Maximally flat passband</li>
<li>Faster roll-off than Butterworth</li>
<li>Slower roll-off than Chebyshev Type I</li>
<li>Good choice for DC measurement applications</li>
</ul>
<p>Read more about other IIR filters in <span style="color: #0000ff;"><a style="color: #0000ff;" href="https://www.advsolned.com/iir-filters-a-practical-guide/">IIR filter design: a practical guide</a></span></p>
</div></section>
<div style='padding-bottom:10px; ' class='av-special-heading av-special-heading-h2     '><h2 class='av-special-heading-tag '  itemprop="headline"  >Syntax Chebyshev Filters</h2><div class='special-heading-border'><div class='special-heading-inner-border' ></div></div></div>
<section class="av_textblock_section "  itemscope="itemscope" itemtype="https://schema.org/BlogPosting" itemprop="blogPost" ><div class='avia_textblock  '   itemprop="text" ><p>An example in <span style="color: #0000ff;"><a style="color: #0000ff;" href="https://www.advsolned.com/asn-filterscript-reference/">ASN Filterscript</a> </span>now follows.</p>
</div></section>
<div style='padding-bottom:10px; ' class='av-special-heading av-special-heading-h3     '><h3 class='av-special-heading-tag '  itemprop="headline"  >Syntax Chebyshev I</h3><div class='special-heading-border'><div class='special-heading-inner-border' ></div></div></div>
<section class="av_textblock_section "  itemscope="itemscope" itemtype="https://schema.org/BlogPosting" itemprop="blogPost" ><div class='avia_textblock  '   itemprop="text" ><p><strong>Syntax</strong><br />
<code>Hd = cheby1 (Order, Frequencies, Rp, Rs, Type, DFormat)</code></p>
<p><strong>Description</strong></p>
<p>Classic IIR Chebyshev Type I filter design</p>
<ul>
<li>Maximally flat stopband</li>
<li>Faster roll off (passband to stopband transition) than Butterworth</li>
</ul>
<p><a href="http://www.advsolned.com/wp-content/uploads/2018/08/Cheby1-495.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-7346 size-full" src="https://www.advsolned.com/wp-content/uploads/2018/08/Cheby1-495.png" alt="Chebyshev I, syntax Cheby" width="495" height="472" srcset="https://www.advsolned.com/wp-content/uploads/2018/08/Cheby1-495.png 495w, https://www.advsolned.com/wp-content/uploads/2018/08/Cheby1-495-300x286.png 300w, https://www.advsolned.com/wp-content/uploads/2018/08/Cheby1-495-450x429.png 450w" sizes="auto, (max-width: 495px) 100vw, 495px" /></a></p>
<p><span style="font-family: courier;">Hd = cheby1 (Order, Frequencies, Rp, Rs, Type, DFormat)</span></p>
<p><span style="font-family: courier;">Order</span>: may be specified up to <span style="font-family: courier;">20</span> (professional) and up to <span style="font-family: courier;">10</span> (educational) edition. Setting the <span style="font-family: courier;">Order</span> to <span style="font-family: courier;">0</span>, enables the automatic order determination algorithm.</p>
<p><span style="font-family: courier;">Frequencies</span>: lowpass and highpass filters have one transition band, and in as such require two frequencies (i.e. lower and upper cut-off frequencies of the transition band). For bandpass and bandstop filters, four frequencies are required (i.e. two transition bands). All frequencies must be ascending in order and < Nyquist (see the example below).

<span style="font-family: courier;">Rp</span>: Passband ripple in dB. This is somewhat of a misnomer, as the Butterworth filter has a maximally flat passband. A good default value is 0.001dB, but increasing this value will affect the position of the filter’s lower cut-off frequency.</p>
<p><span style="font-family: courier;">Rs</span>: Stopband attenuation in dB. This is somewhat of a misnomer, as the Butterworth filter has a maximally flat stopband, which means that the stopband attenuation (assuming the correct filter order is specified) will be ≥ stopband specification.</p>
<p><span style="font-family: courier;">Type</span>: The Butterworth method facilitates the design of <span style="font-family: courier;">lowpass</span>, <span style="font-family: courier;">highpass</span>, <span style="font-family: courier;">bandpass</span> and <span style="font-family: courier;">bandstop</span> filters respectively.</p>
<p><span style="font-family: courier;">Hd</span>: the Butterworth method designs an IIR Butterworth filter based on the entered specifications and places the transfer function (i.e. numerator, denominator, gain) into a digital filter object, <span style="font-family: courier;">Hd</span>. The digital filter object can then be combined with other methods if so required. For a digital filter object, <span style="font-family: courier;">Hd</span>, calling <span style="font-family: courier;">getnum(Hd)</span>, <span style="font-family: courier;">getden(Hd)</span> and <span style="font-family: courier;">getgain(Hd)</span> will extract the numerator, denominator and gain coefficients respectively – see below.</p>
<p><span style="font-family: courier;">DFormat</span>: allows you to specify the display format of resulting digital filter object.</p>
<table width="833">
<tbody>
<tr>
<td><code>symbolic</code></td>
<td>Display a symbolic representation of the filter object. If the order > 10, the symbolic display option will be overridden and set to numeric.</td>
</tr>
<tr>
<td><code>numeric</code></td>
<td>Display a matrix representation of the filter object</td>
</tr>
<tr>
<td><code>void</code></td>
<td>Create a filter object, but do not display output</td>
</tr>
</tbody>
</table>
<p><strong>Example</strong><br />
[code lang=&#8221;java&#8221;]<br />
ClearH1;  // clear primary filter from cascade<br />
ShowH2DesignMarkers;   // show DM on chart&lt;/code&gt;</p>
<p>Main()</p>
<p>Rp=1.4;<br />
Rs=80;<br />
F={50,120};<br />
Hd=cheby1(0,F,Rp,Rs,&quot;lowpass&quot;,&quot;symbolic&quot;);</p>
<p>F={50,80,100,120};<br />
Hd=cheby1(0,F,Rp,Rs,&quot;bandpass&quot;,&quot;symbolic&quot;);</p>
<p>Num = getnum(Hd); // define numerator coefficients<br />
Den = getden(Hd); // define denominator coefficients<br />
Gain = getgain(Hd); // define gain<br />
[/code]</p>
</div></section>
<div style='padding-bottom:10px; ' class='av-special-heading av-special-heading-h3     '><h3 class='av-special-heading-tag '  itemprop="headline"  >Syntax Chebyshev II</h3><div class='special-heading-border'><div class='special-heading-inner-border' ></div></div></div>
<section class="av_textblock_section "  itemscope="itemscope" itemtype="https://schema.org/BlogPosting" itemprop="blogPost" ><div class='avia_textblock  '   itemprop="text" ><p><strong>Syntax</strong><br />
<code>Hd = cheby2 (Order, Frequencies, Rp, Rs, Type, DFormat)</code></p>
<p><strong>Description</strong></p>
<p>Classic IIR Chebyshev Type II filter design</p>
<ul>
<li>Maximally flat passband</li>
<li>Slower roll off (passband to stopband transition) than Chebyshev Type I</li>
</ul>
<p><a href="http://www.advsolned.com/wp-content/uploads/2018/08/Cheby2-495.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-7347 size-full" src="https://www.advsolned.com/wp-content/uploads/2018/08/Cheby2-495.png" alt="Chebyshev II, syntax Cheby II" width="495" height="474" srcset="https://www.advsolned.com/wp-content/uploads/2018/08/Cheby2-495.png 495w, https://www.advsolned.com/wp-content/uploads/2018/08/Cheby2-495-300x287.png 300w, https://www.advsolned.com/wp-content/uploads/2018/08/Cheby2-495-450x431.png 450w" sizes="auto, (max-width: 495px) 100vw, 495px" /></a></p>
<p><span style="font-family: courier;">Hd = cheby2 (Order, Frequencies, Rp, Rs, Type, DFormat)</span></p>
<p><span style="font-family: courier;">Order</span>: may be specified up to <span style="font-family: courier;">20</span> (professional) and up to <span style="font-family: courier;">10</span> (educational) edition. Setting the <span style="font-family: courier;">Order</span> to <span style="font-family: courier;">0</span>, enables the automatic order determination algorithm.</p>
<p><span style="font-family: courier;">Frequencies</span>: lowpass and highpass filters have one transition band, and in as such require two frequencies (i.e. lower and upper cut-off frequencies of the transition band). For bandpass and bandstop filters, four frequencies are required (i.e. two transition bands). All frequencies must be ascending in order and < Nyquist (see the example below).

<span style="font-family: courier;">Rp</span>: Passband ripple in dB. This is somewhat of a misnomer, as the Chebyshev Type II filter has a maximally flat passband. A good default value is 0.001dB, but increasing this value will affect the position of the filter’s lower cut-off frequency.</p>
<p><span style="font-family: courier;">Rs</span>: Stopband attenuation in dB.</p>
<p><span style="font-family: courier;">Type</span>: The Chebyshev Type II method facilitates the design of <span style="font-family: courier;">lowpass</span>, <span style="font-family: courier;">highpass</span>, <span style="font-family: courier;">bandpass</span> and <span style="font-family: courier;">bandstop</span> filters respectively.</p>
<p><span style="font-family: courier;">Hd</span>: the <span style="font-family: courier;">cheby2</span> method designs an IIR Chebyshev Type II filter based on the entered specifications and places the transfer function (i.e. numerator, denominator, gain) into a digital filter object, <span style="font-family: courier;">Hd</span>. The digital filter object can then be combined with other methods if so required. For a digital filter object, <span style="font-family: courier;">Hd</span>, calling <span style="font-family: courier;">getnum(Hd)</span>, <span style="font-family: courier;">getden(Hd)</span> and <span style="font-family: courier;">getgain(Hd)</span> will extract the numerator, denominator and gain coefficients respectively – see below.</p>
<p><span style="font-family: courier;">DFormat</span>: allows you to specify the display format of resulting digital filter object.</p>
<table width="833">
<tbody>
<tr>
<td><code>symbolic</code></td>
<td>Display a symbolic representation of the filter object. If the order > 10, the symbolic display option will be overridden and set to numeric</td>
</tr>
<tr>
<td><code>numeric</code></td>
<td>Display a matrix representation of the filter object</td>
</tr>
<tr>
<td><code>void</code></td>
<td>Create a filter object, but do not display output</td>
</tr>
</tbody>
</table>
<p><strong>Examples</strong><br />
[code lang=&#8221;java&#8221;]<br />
ClearH1;  // clear primary filter from cascade<br />
ShowH2DesignMarkers;   // show DM on chart</p>
<p>Main()</p>
<p>Rp=1;<br />
Rs=80;<br />
F={50,120};<br />
Hd=cheby2(0,F,Rp,Rs,&quot;lowpass&quot;,&quot;symbolic&quot;);</p>
<p>F={50,80,100,120};<br />
Hd=cheby2(0,F,Rp,Rs,&quot;bandpass&quot;,&quot;symbolic&quot;);</p>
<p>Num = getnum(Hd); // define numerator coefficients<br />
Den = getden(Hd); // define denominator coefficients<br />
Gain = getgain(Hd); // define gain<br />
[/code]</p>
</div></section>
<section class="av_textblock_section "  itemscope="itemscope" itemtype="https://schema.org/BlogPosting" itemprop="blogPost" ><div class='avia_textblock  '   itemprop="text" ><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/asn_filter_designer/"><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 style="text-align: left;"><a class="button" href="https://www.advsolned.com/request-form-asn-filter-designer-demo/">Download demo now</a></p>
<p><a class="button" href="https://www.advsolned.com/pricing-and-licencing/#Best_licence_forme">Licencing information</a></p>
</div></section>
		<div class="wpulike wpulike-default " ><div class="wp_ulike_general_class wp_ulike_is_not_liked"><button type="button"
					aria-label="Like Button"
					data-ulike-id="13954"
					data-ulike-nonce="8895a16ffc"
					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_13954"></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/chebyshev-filters/">Chebyshev Filters</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.advsolned.com/chebyshev-filters/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Butterworth Filter</title>
		<link>https://www.advsolned.com/butterworth-filter/</link>
					<comments>https://www.advsolned.com/butterworth-filter/#respond</comments>
		
		<dc:creator><![CDATA[ASN consultancy team]]></dc:creator>
		<pubDate>Thu, 20 Aug 2020 13:36:30 +0000</pubDate>
				<category><![CDATA[ASN FilterScript]]></category>
		<category><![CDATA[ASN Filter Designer]]></category>
		<category><![CDATA[Butterworth]]></category>
		<category><![CDATA[Butterworthfilter]]></category>
		<guid isPermaLink="false">https://www.advsolned.com/?p=13718</guid>

					<description><![CDATA[<p>Butterworth filters have a magnitude response that is maximally flat  in the passband and monotonic overall. Good choice for eg DC and loadcells</p>
<p>The post <a rel="nofollow" href="https://www.advsolned.com/butterworth-filter/">Butterworth 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  blockquote modern-quote modern-centered   '><h1 class='av-special-heading-tag '  itemprop="headline"  >The Butterworth Filter</h1><div class='special-heading-border'><div class='special-heading-inner-border' ></div></div></div>
<section class="av_textblock_section "  itemscope="itemscope" itemtype="https://schema.org/BlogPosting" itemprop="blogPost" ><div class='avia_textblock  '   itemprop="text" ><p>Butterworth filters have a magnitude response that is maximally flat  in the passband and monotonic overall. This makes them a good choice for DC and low frequency measurement applications, such as loadcells. However, this highly desirable ‘smoothness’ comes at the price of decreased roll-off steepness. As a consequence, compared to Chebyshev and Elliptic, the <strong>Butterworth method has the slowest roll-off characteristics of all the methods.</strong></p>
<p><a href="http://www.advsolned.com/wp-content/uploads/2018/07/Butterworth-5th-order.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-6438 size-full" src="https://www.advsolned.com/wp-content/uploads/2018/07/Butterworth-5th-order.png" alt="Butterworth Filter" width="577" height="656" srcset="https://www.advsolned.com/wp-content/uploads/2018/07/Butterworth-5th-order.png 577w, https://www.advsolned.com/wp-content/uploads/2018/07/Butterworth-5th-order-264x300.png 264w, https://www.advsolned.com/wp-content/uploads/2018/07/Butterworth-5th-order-450x512.png 450w" sizes="auto, (max-width: 577px) 100vw, 577px" /></a><br />
<strong>Butterworth Filter characteristics</strong></p>
<ul>
<li>Smooth monotonic response (no ripple)</li>
<li>Slowest roll-off for equivalent order</li>
<li>Highest order of all supported prototypes</li>
<li>More linear passband phase response than all other methods</li>
<li>Good choice for DC measurement and audio applications</li>
</ul>
<span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>
<p><strong>Read More about choosing the IIR filter in our <span style="color: #0000ff;"><a style="color: #0000ff;" href="https://www.advsolned.com/iir-filters-a-practical-guide/">IIR filters guide</a></span></strong></p>
</div></section>
<div style='padding-bottom:10px; ' class='av-special-heading av-special-heading-h2     '><h2 class='av-special-heading-tag '  itemprop="headline"  >The Butterworth filter in ASN Filterscript</h2><div class='special-heading-border'><div class='special-heading-inner-border' ></div></div></div>
<section class="av_textblock_section "  itemscope="itemscope" itemtype="https://schema.org/BlogPosting" itemprop="blogPost" ><div class='avia_textblock  '   itemprop="text" ><p><strong>Syntax</strong><br />
<code>Hd = butter (Order, Frequencies, Rp, Rs, Type, DFormat)</code></p>
<p><strong>Description</strong></p>
<p>Classic IIR Butterworth filter design</p>
<ul>
<li>Smooth monotonic response (no ripple)</li>
<li>Slowest roll-off for equivalent order</li>
<li>Highest order of all supported prototypes</li>
</ul>
<p><a href="http://www.advsolned.com/wp-content/uploads/2018/08/Butterworth-495-1.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-7345 size-full" src="http://www.advsolned.com/wp-content/uploads/2018/08/Butterworth-495-1.png" alt="" width="495" height="502" srcset="https://www.advsolned.com/wp-content/uploads/2018/08/Butterworth-495-1.png 495w, https://www.advsolned.com/wp-content/uploads/2018/08/Butterworth-495-1-80x80.png 80w, https://www.advsolned.com/wp-content/uploads/2018/08/Butterworth-495-1-296x300.png 296w, https://www.advsolned.com/wp-content/uploads/2018/08/Butterworth-495-1-36x36.png 36w, https://www.advsolned.com/wp-content/uploads/2018/08/Butterworth-495-1-450x456.png 450w" sizes="auto, (max-width: 495px) 100vw, 495px" /></a></p>
<p><span style="font-family: courier;">Order</span>: may be specified up to <span style="font-family: courier;">20</span> (professional) and up to <span style="font-family: courier;">10</span> (educational) edition. Setting the <span style="font-family: courier;">Order</span> to <span style="font-family: courier;">0</span>, enables the automatic order determination algorithm.</p>
<p><span style="font-family: courier;">Frequencies</span>: lowpass and highpass filters have one transition band, and in as such require two frequencies (i.e. lower and upper cut-off frequencies of the transition band). For bandpass and bandstop filters, four frequencies are required (i.e. two transition bands). All frequencies must be ascending in order and < Nyquist (see the example below).

<span style="font-family: courier;">Rp</span>: Passband ripple in dB. This is somewhat of a misnomer, as the Butterworth filter has a maximally flat passband. A good default value is 0.001dB, but increasing this value will affect the position of the filter’s lower cut-off frequency.</p>
<p><span style="font-family: courier;">Rs</span>: Stopband attenuation in dB. This is somewhat of a misnomer, as the Butterworth filter has a maximally flat stopband, which means that the stopband attenuation (assuming the correct filter order is specified) will be ≥ stopband specification.</p>
<p><span style="font-family: courier;">Type</span>: The Butterworth method facilitates the design of <span style="font-family: courier;">lowpass</span>, <span style="font-family: courier;">highpass</span>, <span style="font-family: courier;">bandpass</span> and <span style="font-family: courier;">bandstop</span> filters respectively.</p>
<p><span style="font-family: courier;">Hd</span>: the Butterworth method designs an IIR Butterworth filter based on the entered specifications and places the transfer function (i.e. numerator, denominator, gain) into a digital filter object, Hd. The digital filter object can then be combined with other methods if so required. For a digital filter object, <span style="font-family: courier;">Hd</span>, calling <span style="font-family: courier;">getnum(Hd)</span>, <span style="font-family: courier;">getden(Hd)</span> and <span style="font-family: courier;">getgain(Hd)</span> will extract the numerator, denominator and gain coefficients respectively – see below.</p>
<p><span style="font-family: courier;">DFormat</span>: allows you to specify the display format of resulting digital filter object.</p>
<table width="833">
<tbody>
<tr>
<td><code>symbolic</code></td>
<td>Display a symbolic representation of the filter object. If the order > 10, the symbolic display option will be overridden and set to numeric</td>
</tr>
<tr>
<td><code>numeric</code></td>
<td>Display a matrix representation of the filter object</td>
</tr>
<tr>
<td><code>void</code></td>
<td>Create a filter object, but do not display output</td>
</tr>
</tbody>
</table>
<p><strong>Example</strong><br />
[code lang=&#8221;java&#8221;]<br />
ClearH1; // clear primary filter from cascade<br />
ShowH2DesignMarkers; // show DM on chart</p>
<p>Main()</p>
<p>Rp=0.001;<br />
Rs=80;<br />
F={50,120};<br />
Hd=butter(0,F,Rp,Rs,&amp;amp;amp;amp;amp;amp;amp;amp;quot;lowpass&amp;amp;amp;amp;amp;amp;amp;amp;quot;,&amp;amp;amp;amp;amp;amp;amp;amp;quot;symbolic&amp;amp;amp;amp;amp;amp;amp;amp;quot;);</p>
<p>F={50,80,100,120};<br />
Hd=butter(0,F,Rp,Rs,&amp;amp;amp;amp;amp;amp;amp;amp;quot;bandpass&amp;amp;amp;amp;amp;amp;amp;amp;quot;,&amp;amp;amp;amp;amp;amp;amp;amp;quot;symbolic&amp;amp;amp;amp;amp;amp;amp;amp;quot;);</p>
<p>Num = getnum(Hd); // define numerator coefficients<br />
Den = getden(Hd); // define denominator coefficients<br />
Gain = getgain(Hd); // define gain[/code]</p>
</div></section>
</div></div></div><!-- close content main div --></div></div><div id='av-layout-grid-1' class='av-layout-grid-container entry-content-wrapper main_color av-flex-cells    container_wrap sidebar_right' style=' '  >
<div class="flex_cell no_margin av_one_full   " style='vertical-align:top; padding:30px; '><div class='flex_cell_inner' ><p><div class="flex_column av_one_half  flex_column_div av-zero-column-padding first  " style='border-radius:0px; '><div class='avia-image-container  av-styling-    avia-align-right '  itemprop="ImageObject" itemscope="itemscope" itemtype="https://schema.org/ImageObject"  ><div class='avia-image-container-inner'><div class='avia-image-overlay-wrap'><img class='avia_image' src='https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox-217x300.png' alt='' title='ASN Filter Designer DSP' height="300" width="217"  itemprop="thumbnailUrl"  /></div></div></div></div><div class="flex_column av_one_half  flex_column_div av-zero-column-padding   " style='border-radius:0px; '><p><div style='height:40px' class='hr hr-invisible  '><span class='hr-inner ' ><span class='hr-inner-style'></span></span></div><br />
<div class='avia-button-wrap avia-button-left '><a href='https://www.advsolned.com/pricing-and-licencing/'  class='avia-button   avia-icon_select-yes-left-icon avia-color-red avia-size-large avia-position-left '  target="_blank"   ><span class='avia_button_icon avia_button_icon_left ' aria-hidden='true' data-av_icon='' data-av_iconfont='entypo-fontello'></span><span class='avia_iconbox_title' >Pricing and licencing</span></a></div><br />
<div style='height:10px' class='hr hr-invisible  '><span class='hr-inner ' ><span class='hr-inner-style'></span></span></div><br />
<div class='avia-button-wrap avia-button-left '><a href='http://www.advsolned.com/request-form-asn-filter-designer-demo/'  class='avia-button   avia-icon_select-yes-left-icon avia-color-red avia-size-large avia-position-left '  target="_blank"   ><span class='avia_button_icon avia_button_icon_left ' aria-hidden='true' data-av_icon='' data-av_iconfont='entypo-fontello'></span><span class='avia_iconbox_title' >Request Download</span></a></div><br />
<div style='height:20px' class='hr hr-invisible  '><span class='hr-inner ' ><span class='hr-inner-style'></span></span></div><br />
<div class='avia-image-container  av-styling-    avia-align-left '  itemprop="ImageObject" itemscope="itemscope" itemtype="https://schema.org/ImageObject"  ><div class='avia-image-container-inner'><div class='avia-image-overlay-wrap'><img class='avia_image' src='https://www.advsolned.com/wp-content/uploads/2018/06/edn_top100-1.png' alt='' title='edn_top100' height="63" width="274"  itemprop="thumbnailUrl"  /></div></div></div></p></div></p>
</div></div>
</div>
		<div class="wpulike wpulike-default " ><div class="wp_ulike_general_class wp_ulike_is_not_liked"><button type="button"
					aria-label="Like Button"
					data-ulike-id="13718"
					data-ulike-nonce="433e9b0311"
					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_13718"></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/butterworth-filter/">Butterworth Filter</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.advsolned.com/butterworth-filter/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>A computationally efficient moving average filter: Definition and implementation</title>
		<link>https://www.advsolned.com/computationally-efficient-moving-average-filter-definition-and-implementation/</link>
		
		<dc:creator><![CDATA[ASN consultancy team]]></dc:creator>
		<pubDate>Sun, 24 May 2020 13:18:12 +0000</pubDate>
				<category><![CDATA[ASN FilterScript]]></category>
		<category><![CDATA[Arm Cortex-M]]></category>
		<category><![CDATA[digital filter]]></category>
		<category><![CDATA[filters]]></category>
		<category><![CDATA[FIR]]></category>
		<category><![CDATA[IIR]]></category>
		<category><![CDATA[MA filter]]></category>
		<category><![CDATA[moving average]]></category>
		<guid isPermaLink="false">https://www.advsolned.com/?p=12573</guid>

					<description><![CDATA[<p>As discussed in a previous article, the moving average (MA) filter is perhaps one of the most widely used digital filters due to its conceptual simplicity and ease of implementation. The realisation diagram shown below, illustrates that an MA filter can be implemented as a simple FIR filter, just requiring additions and a delay line. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.advsolned.com/computationally-efficient-moving-average-filter-definition-and-implementation/">A computationally efficient moving average filter: Definition and implementation</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>As discussed in a <a style="color: #0000ff;" href="https://www.advsolned.com/the-moving-average-filter/">previous article</a>, the moving average (MA) filter is perhaps one of the most widely used digital filters due to its conceptual simplicity and ease of implementation. The realisation diagram shown below, illustrates that an MA filter can be implemented as a simple FIR filter, just requiring additions and a delay line.</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="670" height="217" src="https://www.advsolned.com/wp-content/uploads/2018/07/firdirectformPNG.png" alt="moving average filter, an MA filter can be implemented as a simple FIR filter, just requiring additions and a delay line. moving average FIR filter" class="wp-image-5927" srcset="https://www.advsolned.com/wp-content/uploads/2018/07/firdirectformPNG.png 670w, https://www.advsolned.com/wp-content/uploads/2018/07/firdirectformPNG-300x97.png 300w, https://www.advsolned.com/wp-content/uploads/2018/07/firdirectformPNG-450x146.png 450w" sizes="auto, (max-width: 670px) 100vw, 670px" /></figure></div>



<p>Modelling the above, we see that a moving average filter of length \(\small\textstyle L\) for an input signal \(\small\textstyle x(n)\) may be defined as follows:</p>



<p class="has-text-align-center">\( y(n)=\large{\frac{1}{L}}\normalsize{\sum\limits_{k=0}^{L-1}x(n-k)}\quad \text{for} \quad\normalsize{n=0,1,2,3&#8230;.}\label{FIRdef}\tag{1}\)</p>



<p>This computation requires \(\small\textstyle L-1\) additions, which may become computationally demanding for very low power processors when \(\small\textstyle L\) is large. Therefore, applying some lateral thinking to the computational challenge, we see that a much more computationally efficient filter can be used in order to achieve the same result, namely:</p>



<p class="has-text-align-center"><span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span>\(H(z)=\displaystyle\frac{1}{L}\frac{1-z^{-L}}{1-z^{-1}}\tag{2}\label{TF}\)</p>



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



<p class="has-text-align-center">\(y(n) =y(n-1)+\displaystyle\frac{x(n)-x(n-L)}{L}\tag{3}\)</p>



<p><span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span>Notice that this implementation only requires <strong>one addition and one subtraction</strong> for any value of \(\small\textstyle L\). A further simplification (valid for both implementations) can be achieved in a pre-processing step prior to implementing the difference equation, i.e. scaling all input values by \(\small\textstyle L\). If \(\small\textstyle L\) is a power of two (e.g. 4,8,16,32..), this can be achieved by a simple binary shift right operation.</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-1 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<h3 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><strong>Is it an IIR or actually an FIR?</strong></h3>



<p>Upon initial inspection of the transfer function of Eqn. \(\small\textstyle\eqref{TF}\), it appears that the efficient Moving average filter is an IIR filter. However, analysing the pole-zero plot of the filter (shown on the right for \(\small\textstyle L=8\)), we see that the <strong>pole at DC has been cancelled by a zero</strong>, and that the resulting filter is actually an FIR filter, with the same result as Eqn. \(\small\textstyle\eqref{FIRdef}\).</p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<div class="wp-block-image"><figure class="alignright size-large"><img loading="lazy" decoding="async" width="357" height="357" src="https://www.advsolned.com/wp-content/uploads/2020/05/iir_ma_zp.png" alt="Moving average filter (MA filter). It appears that the efficient MA filter is an IIR filter. However, analysing the pole-zero plot of the filter, , we see that the pole at DC has been cancelled by a zero, and that the resulting filter is actually an FIR filter, with the same result as Eqn. " class="wp-image-12589" srcset="https://www.advsolned.com/wp-content/uploads/2020/05/iir_ma_zp.png 357w, https://www.advsolned.com/wp-content/uploads/2020/05/iir_ma_zp-300x300.png 300w, https://www.advsolned.com/wp-content/uploads/2020/05/iir_ma_zp-80x80.png 80w, https://www.advsolned.com/wp-content/uploads/2020/05/iir_ma_zp-36x36.png 36w, https://www.advsolned.com/wp-content/uploads/2020/05/iir_ma_zp-180x180.png 180w, https://www.advsolned.com/wp-content/uploads/2020/05/iir_ma_zp-120x120.png 120w" sizes="auto, (max-width: 357px) 100vw, 357px" /></figure></div>
</div>
</div>



<p>Notice also that the frequency spacing of the zeros (corresponding to the nulls in the frequency response) are at spaced at \(\small\textstyle\pm\frac{Fs}{L}\). This can be readily seen for this example, where an MA of length 8, sampled at \(\small\textstyle 500Hz\), results in a \(\small\textstyle\pm62.5Hz\) resolution.</p>



<p>As a final point, notice that the our efficient filter requires a delay line of length \(\small\textstyle L+1\), compared with the FIR delay line of length, \(\small\textstyle L\). However, this is a small price to pay for the computation advantage of a filter just requiring one addition and one subtraction. As such, the MA filter of Eqn. \(\small\textstyle\eqref{TF}\) presented herein is very attractive for very low power processors, such as the Arm Cortex-M0 that have been traditionally overlooked for DSP operations.</p>



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



<p>The MA filter of Eqn. \(\small\textstyle\eqref{TF}\) may be implemented in <a style="color: #0000ff;" href="http://www.advsolned.com/asn_filter_designer/#live-math-scripting">ASN FilterScript</a> as follows:</p>



<p><pre class="brush: java; title: ; notranslate"> 
ClearH1;  // clear primary filter from cascade 
interface L = {2,32,2,4}; // interface variable definition 

Main() 
Num = {1,zeros(L-1),-1}; // define numerator coefficients 
Den = {1,-1}; // define denominator coefficients 
Gain = 1/L; // define gain 
</pre></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/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="" 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>
<br><br>
<p style="text-align: left;"><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 class="wpulike wpulike-default " ><div class="wp_ulike_general_class wp_ulike_is_not_liked"><button type="button"
					aria-label="Like Button"
					data-ulike-id="12573"
					data-ulike-nonce="3f8c30b6c2"
					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_12573"></button><span class="count-box wp_ulike_counter_up" data-ulike-counter-value="+7"></span>			</div></div>
	<p>The post <a rel="nofollow" href="https://www.advsolned.com/computationally-efficient-moving-average-filter-definition-and-implementation/">A computationally efficient moving average filter: Definition and implementation</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>A-weighting equalisation: Designing and deploying to Arm Cortex-M microcontrollers</title>
		<link>https://www.advsolned.com/a-weighting-equalisation-designing-and-deploying-to-arm-cortex-m-devices/</link>
					<comments>https://www.advsolned.com/a-weighting-equalisation-designing-and-deploying-to-arm-cortex-m-devices/#respond</comments>
		
		<dc:creator><![CDATA[Dr. Sanjeev Sarpal]]></dc:creator>
		<pubDate>Thu, 03 Oct 2019 19:22:48 +0000</pubDate>
				<category><![CDATA[ASN Filter Designer]]></category>
		<category><![CDATA[ASN FilterScript]]></category>
		<category><![CDATA[IoT]]></category>
		<category><![CDATA[A-weighting]]></category>
		<category><![CDATA[Arm]]></category>
		<category><![CDATA[CMSIS-DSP]]></category>
		<category><![CDATA[DSP]]></category>
		<category><![CDATA[ITU-R 486–4 weighting]]></category>
		<category><![CDATA[sound meter]]></category>
		<guid isPermaLink="false">http://www.advsolned.com/?p=8673</guid>

					<description><![CDATA[<p>A-weighting equalisation: Designing and deploying to Arm Cortex-M devices;  A-weighting curves, frequency response, modelling perceived sound, LaPlace</p>
<p>The post <a rel="nofollow" href="https://www.advsolned.com/a-weighting-equalisation-designing-and-deploying-to-arm-cortex-m-devices/">A-weighting equalisation: Designing and deploying to Arm Cortex-M microcontrollers</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-2 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>Modern embedded processors, software frameworks and design tooling now allow engineers to apply advanced measurement concepts to smart factories as part of the I4.0 revolution.</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="280" height="149" src="https://www.advsolned.com/wp-content/uploads/2020/04/Industry-4.png" alt="" class="wp-image-12105"/></figure>



<p></p>
</div>
</div>



<p>In recent years, PM (predictive maintenance) of machines has received great attention, as factories look to maximise their production efficiency while at the same time retaining the invaluable skills of experienced foremen and production workers.</p>



<p>Traditionally, a foreman would walk around the shop floor and listen to the sounds a machine would make to get an idea of impending failure. With the advent of I4.0 AIoT technology, microphones, edge DSP algorithms and ML may now be employed in order to ‘listen’ to the sounds a machine makes and then make a classification and prediction.</p>



<p>One of the major challenges is <strong>how to make a computer hear like a human</strong>. In this article we will discuss how sound weighting curves can make a computer hear like a human, and how they can be deployed to an Arm Cortex-M microcontroller for use in an AIoT application.</p>



<h2 class="wp-block-heading">Physics of the human ear</h2>



<p>An illustration of the human ear shown below. As seen, the basic task of the ear is to translate sound (air vibration) into electrical nerve impulses for the brain to interpret.</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-3 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>The ear achieves this via three bones (Stapes, Incus and Malleus) that act as a mechanical amplifier for vibrations received at the eardrum. These amplified sounds are then passed onto the Cochlea via the Oval window (not shown). </p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.7%">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="638" height="430" src="https://www.advsolned.com/wp-content/uploads/2020/04/humanear-638x430-1.png" alt="" class="wp-image-12069" srcset="https://www.advsolned.com/wp-content/uploads/2020/04/humanear-638x430-1.png 638w, https://www.advsolned.com/wp-content/uploads/2020/04/humanear-638x430-1-300x202.png 300w, https://www.advsolned.com/wp-content/uploads/2020/04/humanear-638x430-1-450x303.png 450w" sizes="auto, (max-width: 638px) 100vw, 638px" /></figure>
</div>
</div>



<p><span class="" style="display:block;clear:both;height: 0px;margin-top: -20px;border-top-width:0px;border-bottom-width:0px;"></span>The Cochlea (shown in purple) is filled with a fluid that moves in response to the vibrations from the oval window. As the fluid moves, thousands of nerve endings are set into motion. These nerve endings transform sound vibrations into electrical impulses that travel along the auditory nerve fibres to the brain for analysis.</p>



<h2 class="wp-block-heading"><strong>Modelling perceived sound</strong></h2>



<p>Due to complexity of the fluidic mechanical construction of the human auditory system, low and high frequencies are typically not discernible. Researchers over the years have found that humans are most perceptive to sounds in the 1-6kHz range, although this range varies according to the subject’s physical health.</p>



<p>This research led to the definition of a set of weighting curves: the so-called <strong>A, B, C and D weighting curves</strong>, which equalises a microphone’s frequency response. These weighting curves aim to bring the digital and physical worlds closer together by allowing a computerised microphone-based system to hear like a human.</p>



<p>The A-weighing curve is the most widely used as it is mandated by IEC-61672 to be fitted to all sound level meters. The B and D curves are hardly ever used, but C-weighting may be used for testing the impact of noise in telecoms systems.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="http://www.advsolned.com/wp-content/uploads/2019/10/aweightingcurve.png"><img loading="lazy" decoding="async" width="560" height="420" src="https://www.advsolned.com/wp-content/uploads/2019/10/aweightingcurve-1.png" alt="a-weighting curve" class="wp-image-12130" srcset="https://www.advsolned.com/wp-content/uploads/2019/10/aweightingcurve-1.png 560w, https://www.advsolned.com/wp-content/uploads/2019/10/aweightingcurve-1-300x225.png 300w, https://www.advsolned.com/wp-content/uploads/2019/10/aweightingcurve-1-450x338.png 450w" sizes="auto, (max-width: 560px) 100vw, 560px" /></a></figure></div>


<p>The frequency response of the A-weighting curve is shown above, where it can be seen that sounds entering our ears are <strong>de-emphasised below 500Hz and are most perceptible between 0.5-6kHz</strong>. Notice that the curve is unspecified above 20kHz, as this exceeds the human hearing range.</p>



<h2 class="wp-block-heading">ASN FilterScript</h2>



<p>ASN’s <a style="color: #0000ff;" href="http://www.advsolned.com/asn-filterscript-gsg/">FilterScript </a> symbolic math scripting language offers designers the ability to take an analog filter transfer function and transform it to its digital equivalent with just a few lines of code.</p>



<p>The analog transfer functions of the A and C-weighting curves are given below:<span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span></p>



<p>\(H_A(s) \approx \displaystyle{7.39705×10^9 \cdot s^4 \over (s + 129.4)^2\quad(s + 676.7)\quad (s + 4636)\quad (s + 76655)^2}\)<span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span></p>



<p>\(H_C(s) \approx \displaystyle{5.91797×10^9 \cdot s^2\over(s + 129.4)^2\quad (s + 76655)^2}\)<span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span></p>



<p>These analog transfer functions may be transformed into their digital equivalents via the <code>bilinear()</code> function. However, notice that \(H_A(s) \) requires a significant amount of algebracic manipulation in order to extract the denominator cofficients in powers of \(s\).</p>



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



<p>A simple trick to perform polynomial multiplication is to use linear convolution, which is the same algebraic operation as multiplying two polynomials together. This may be easily performed via FilterScript’s <code>conv()</code> function, as follows:</p>



<pre class="brush: java; light: true; title: ; notranslate">
y=conv(a,b);
</pre>



<p>As a simple example, the multiplication of \((s^2+2s+10)\) with \((s+5)\), would be defined as the following three lines of FilterScript code:</p>



<pre class="brush: cpp; title: ; notranslate">
a={1,2,10};
b={1,5};
y=conv(a,b);
</pre>



<p>which yields,<code> 1 7 20 50 </code> or \((s^3+7s^2+20s+50)\)</p>



<p>For the A-weighting curve Laplace transfer function, the complete FilterScript code is given below:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
ClearH1;  // clear primary filter from cascade

Main() // main loop

a={1, 129.4};
b={1, 676.7};
c={1, 4636};
d={1, 76655};

aa=conv(a,a); // polynomial multiplication
dd=conv(d,d);

aab=conv(aa,b);
aabc=conv(aab,c);

Na=conv(aabc,dd);
Nb = {0 ,0 , 1 ,0 ,0 , 0, 0}; // define numerator coefficients
G = 7.397e+09; // define gain

Ha = analogtf(Nb, Na, G, "symbolic");
Hd = bilinear(Ha,0, "symbolic");

Num = getnum(Hd);
Den = getden(Hd);
Gain = getgain(Hd)/computegain(Hd,1e3);    // set gain to 0dB@1kHz
</pre></div>

<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="http://www.advsolned.com/wp-content/uploads/2019/10/aweightingcomp.png"><img loading="lazy" decoding="async" width="560" height="420" src="https://www.advsolned.com/wp-content/uploads/2019/10/aweightingcomp-1.png" alt="a-weighting" class="wp-image-12129" srcset="https://www.advsolned.com/wp-content/uploads/2019/10/aweightingcomp-1.png 560w, https://www.advsolned.com/wp-content/uploads/2019/10/aweightingcomp-1-300x225.png 300w, https://www.advsolned.com/wp-content/uploads/2019/10/aweightingcomp-1-450x338.png 450w" sizes="auto, (max-width: 560px) 100vw, 560px" /></a></figure></div>


<p>Frequency response of analog vs digital A-weighting filter for \(f_s=48kHz\). As seen, the digital equivalent&nbsp;magnitude response matches the ideal analog magnitude response very closely until \(6kHz\).</p>


<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>The ITU-R 486–4 weighting curve</strong></h3>



<p>Another weighting curve of interest is the ITU-R 486–4 weighting curve, developed by the BBC. Unlike the A-weighting filter, the ITU-R 468–4 curve describes subjective loudness for broadband stimuli. The main disadvantage of the A-weighting curve is that it underestimates the loudness judgement of real-world stimuli particularly in the frequency band from about 1–9 kHz.</p>



<p>Due to the precise definition of the 486–4 weighting curve, there is no analog transfer function available. Instead the standard provides a table of amplitudes and frequencies – <a style="color: #0000ff;" href="https://en.wikipedia.org/wiki/ITU-R_468_noise_weighting">see here</a>. This specification may be directly entered into FilterScript’s <code>firarb()</code> function for designing a suitable FIR filter, as shown below:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
ClearH1;  // clear primary filter from cascade
ShowH2DM;

interface L = {10,400,10,250}; // filter order

Main()

// ITU-R 468 Weighting
A={-29.9,-23.9,-19.8,-13.8,-7.8,-1.9,0,5.6,9,10.5,11.7,12.2,12,11.4,10.1,8.1,0,-5.3,-11.7,-22.2};
F={63,100,200,400,800,1e3,2e3,3.15e3,4e3,5e3,6.3e3,7.1e3,8e3,9e3,1e4,1.25e4,1.4e4,1.6e4,2e4};

A={-30,A};  //  specify arb response
F={0,F,fs/2};   

Hd=firarb(L,A,F,"blackman","numeric");

Num=getnum(Hd);
Den={1};
Gain=getgain(Hd);
</pre></div>

<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><a href="http://www.advsolned.com/wp-content/uploads/2019/10/it468firfr.png"><img loading="lazy" decoding="async" width="473" height="654" src="https://www.advsolned.com/wp-content/uploads/2019/10/it468firfr-1.png" alt="ITU-R 468–4 curve" class="wp-image-12128" style="width:473px;height:654px" srcset="https://www.advsolned.com/wp-content/uploads/2019/10/it468firfr-1.png 473w, https://www.advsolned.com/wp-content/uploads/2019/10/it468firfr-1-217x300.png 217w, https://www.advsolned.com/wp-content/uploads/2019/10/it468firfr-1-450x622.png 450w" sizes="auto, (max-width: 473px) 100vw, 473px" /></a><figcaption class="wp-element-caption">Frequency response of an ITU-R 468-4 FIR filter designed with FilterScript’s <code>firarb()</code> function&nbsp; for \(f_s=48kHz\)</figcaption></figure></div>


<p><span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>As seen, FilterScript provides the designer with a very powerful symbolic scripting language for designing weighting curve filters. The following discussion now focuses on deployment of the A-weighting filter to an Arm based processor via the tool&#8217;s automatic code generator. The concepts and steps demonstrated below are equally valid for FIR filters.</p>



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



<p>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. </p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-4 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>The tool’s built-in analytics and help functions assist the designer in successfully configuring the design for deployment. Professional licence users may expedite the deployment by using the <strong>Arm deployment wizard</strong> that automates the steps described below.</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="326" height="274" src="https://www.advsolned.com/wp-content/uploads/2018/09/Armwizard.png" alt="" class="wp-image-17853" 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: 326px) 100vw, 326px" /></figure>
</div>
</div>



<h3 class="wp-block-heading"><span class="" style="display:block;clear:both;height: 0px;padding-top: 25px;border-top-width:0px;border-bottom-width:0px;"></span><strong>Steps required for Educational licence</strong> <strong>users</strong> <strong>only</strong></h3>



<p>Before generating the code, the <strong>H2 filter</strong> (i.e. the filter designed in FilterScript) needs to be firstly re-optimised (transformed) 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="P-Z editor" 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>All floating point IIR filters designs must 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. 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-5 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>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>



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



<p></p>
</div>
</div>



<p>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"><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>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-full"><img loading="lazy" decoding="async" width="627" height="808" src="https://www.advsolned.com/wp-content/uploads/2023/07/armcmsiscode.png" alt="" class="wp-image-20125" srcset="https://www.advsolned.com/wp-content/uploads/2023/07/armcmsiscode.png 627w, https://www.advsolned.com/wp-content/uploads/2023/07/armcmsiscode-233x300.png 233w, https://www.advsolned.com/wp-content/uploads/2023/07/armcmsiscode-547x705.png 547w, https://www.advsolned.com/wp-content/uploads/2023/07/armcmsiscode-450x580.png 450w" sizes="auto, (max-width: 627px) 100vw, 627px" /></figure></div>


<p>As seen, the ASN Filter Designer&#8217;s automatic code generator generates all initialisation code, scaling and data structures needed to implement the A-weighting filter IIR filter via Arm&#8217;s CMSIS-DSP library. A detailed <a style="color: #0000ff;" href="https://www.advsolned.com/getting-started-with-eclipse-ides-and-arm-mdk-for-the-arm-cmsis-dsp-library/">help tutorial</a> is available by clicking on the <strong>Show me </strong>button<strong>.</strong>&nbsp;<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-6 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"><img loading="lazy" decoding="async" width="495" height="400" src="https://www.advsolned.com/wp-content/uploads/2019/12/Softwareboxshadow-verkleind-495x400_verleind.jpg" alt="ASN Filter Designer box" class="wp-image-10817" 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:66.66%">
<div class="wp-block-buttons is-vertical is-layout-flex wp-container-core-buttons-is-layout-1 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 Evaluation</a></div>



<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/pricing-and-licencing/" style="color:#ffffff">Pricing Information</a></div>
</div>
</div>
</div>


<p><span class="" style="display:block;clear:both;height: 0px;padding-top: 25px;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>                                                                                                                                                                                                        <p class="pp-author-boxes-description multiple-authors-description author-description-0">
                                                                                                                                                    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>
                                                                                                                                
                                                                                                                                    <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 -->
                    
                
                                <style>
                .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-avatar img { 
        width: 80px !important; 
        height: 80px !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-avatar img {
        border-radius: 50% !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-meta a {
        background-color: #655997 !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-meta a {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-meta a:hover {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data {
        background-color: #655997 !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data {
        border-radius: 100% !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data:hover {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data {
        background-color: #655997 !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data {
        border-radius: 100% !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data:hover {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-recent-posts-title {
        border-bottom-style: dotted !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-multiple-authors-boxes-li {
        border-style: solid !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-multiple-authors-boxes-li {
        color: #3c434a !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-multiple-authors-boxes-li {
        border-radius: px !important; 
    }

            </style>
        
        </p>
		<div class="wpulike wpulike-default " ><div class="wp_ulike_general_class wp_ulike_is_not_liked"><button type="button"
					aria-label="Like Button"
					data-ulike-id="8673"
					data-ulike-nonce="f7c1a4fab2"
					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_8673"></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/a-weighting-equalisation-designing-and-deploying-to-arm-cortex-m-devices/">A-weighting equalisation: Designing and deploying to Arm Cortex-M microcontrollers</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.advsolned.com/a-weighting-equalisation-designing-and-deploying-to-arm-cortex-m-devices/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Practical noise reduction tips for biomedical ECG filters</title>
		<link>https://www.advsolned.com/noise-reduction-tips-biomedical-ecg-data/</link>
		
		<dc:creator><![CDATA[Dr. Sanjeev Sarpal]]></dc:creator>
		<pubDate>Wed, 22 May 2019 14:34:20 +0000</pubDate>
				<category><![CDATA[ASN FilterScript]]></category>
		<category><![CDATA[Biomedical]]></category>
		<category><![CDATA[IoT]]></category>
		<category><![CDATA[50Hz mains interference]]></category>
		<category><![CDATA[50Hz powerline]]></category>
		<category><![CDATA[Arm Cortex-M]]></category>
		<category><![CDATA[biomedical]]></category>
		<category><![CDATA[ECG]]></category>
		<category><![CDATA[EMG]]></category>
		<category><![CDATA[FIR]]></category>
		<category><![CDATA[notch]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Savitzky-Golay]]></category>
		<guid isPermaLink="false">http://www.advsolned.com/?p=8573</guid>

					<description><![CDATA[<p>ECG signal processing tips: Noise reduction, Removal of 50/60Hz powerline interference, adjusting for the effects of EMG (body movement and breathing).</p>
<p>The post <a rel="nofollow" href="https://www.advsolned.com/noise-reduction-tips-biomedical-ecg-data/">Practical noise reduction tips for biomedical ECG filters</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In ECG signal processing, the Removal of 50/60Hz powerline interference from delicate information rich ECG biomedical waveforms is a challenging task! The challenge is further complicated by adjusting for the effects of EMG, such as a patient limb/torso movement or even breathing. A traditional approach adopted by many is to use a 2nd order IIR notch filter:</p>



<p class="has-text-align-center">\(\displaystyle H(z)=\frac{1-2cosw_oz^{-1}+z^{-2}}{1-2rcosw_oz^{-1}+r^2z^{-2}}\)</p>



<p>where, \(w_o=\frac{2\pi f_o}{fs}\) controls the centre frequency, \(f_o\) of the notch, and \(r=1-\frac{\pi BW}{fs}\) controls the bandwidth (-3dB point) of the notch.</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-7 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%">
<h3 class="wp-block-heading"><span class="" style="display:block;clear:both;height: 0px;padding-top: 30px;border-top-width:0px;border-bottom-width:0px;"></span><strong>What&#8217;s the challenge?</strong></h3>



<p>As seen above, \(H(z) \) is simple to implement, but the difficulty lies in finding an optimal value of \(r\), as a desirable sharp notch means that the poles are close to unit circle (see right).</p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<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-image"><figure class="alignright size-large is-resized"><img loading="lazy" decoding="async" src="https://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_iir_pz.png" alt="" width="290" height="267"></figure></div>



<p></p>
</div>
</div>



<p><span class="" style="display:block;clear:both;height: 0px;margin-top: -20px;border-top-width:0px;border-bottom-width:0px;"></span>In the presence of stationary interference, e.g. the patient is absolutely still and effects of breathing on the sensor data are minimal this may not be a problem.</p>



<p>However, when considering the effects of EMG on the captured waveform (a much more realistic situation), the IIR filter’s feedback (poles) causes ringing on the filtered waveform, as illustrated below:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="723" height="426" src="https://www.advsolned.com/wp-content/uploads/2020/04/biomedical_ex_iir_td.png" alt="Contaminated ECG with non-stationary 50Hz powerline interference (FIR filtering), ECG sigal processing, ECG DSP, ECG measurement" class="wp-image-12201" srcset="https://www.advsolned.com/wp-content/uploads/2020/04/biomedical_ex_iir_td.png 723w, https://www.advsolned.com/wp-content/uploads/2020/04/biomedical_ex_iir_td-300x177.png 300w, https://www.advsolned.com/wp-content/uploads/2020/04/biomedical_ex_iir_td-705x415.png 705w, https://www.advsolned.com/wp-content/uploads/2020/04/biomedical_ex_iir_td-450x265.png 450w" sizes="auto, (max-width: 723px) 100vw, 723px" /></figure></div>


<p class="has-text-align-center"><em>Contaminated ECG with non-stationary 50Hz powerline interference (IIR filtering)<br></em></p>



<p>As seen above, although a majority of the 50Hz powerline interference has been removed, there is still significant ringing around the main peaks (filtered output shown in red). This ringing is <strong>undesirable for many biomedical applications</strong>, as vital cardiac information such as the ST segment cannot be clearly analysed.</p>



<p>The frequency reponse of the IIR used to filter the above ECG data is shown below.</p>


<div class="wp-block-image">
<figure class="aligncenter"><a href="http://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_iir_fr.png"><img loading="lazy" decoding="async" width="434" height="535" src="http://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_iir_fr.png" alt="IIR notch filter frequency response, ECG signal processing, ECG DSP, ECG  measurement" class="wp-image-8585" srcset="https://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_iir_fr.png 434w, https://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_iir_fr-243x300.png 243w" sizes="auto, (max-width: 434px) 100vw, 434px" /></a></figure></div>


<p class="has-text-align-center"><em>IIR notch filter frequency response</em></p>



<p>Analysing the plot it can be seen that the filter’s group delay (or average delay) is non-linear but almost zero in the passbands, which means no distortion. The group delay at 50Hz rises to 15 samples, which is the source of the ringing &#8211; where the closer to poles are to unit circle the greater the group delay.</p>



<p><span style="color: #0000ff;"><a style="color: #0000ff;" href="httpS://www.advsolned.com/asn-filterscript-gsg/">ASN FilterScript</a></span> offers designers the <span style="font-family: courier;">notch()</span> function, which is a direct implemention of H(z), as shown below:</p>



<pre class="brush: java; title: ; notranslate">
ClearH1;  // clear primary filter from cascade
ShowH2DM;   // show DM on chart

interface BW={0.1,10,.1,1};

Main()

F=50;
Hd=notch(F,BW,&quot;symbolic&quot;);
Num = getnum(Hd); // define numerator coefficients
Den = getden(Hd); // define denominator coefficients
Gain = getgain(Hd); // define gain
</pre>


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



<h2 class="wp-block-heading"><strong>Savitzky-Golay FIR filters</strong></h2>



<p>A solution to the aforementioned mentioned ringing as well as noise reduction can be achieved by virtue of a Savitzky-Golay lowpass smoothing filter. These filters are FIR filters, and thus have no feedback coefficients and no ringing!</p>



<p>Savitzky-Golay (polynomial) smoothing filters or least-squares smoothing filters are generalizations of the FIR average filter that can better preserve the high-frequency content of the desired signal, at the expense of not removing as much noise as an FIR average. The particular formulation of Savitzky-Golay filters preserves various moment orders better than other smoothing methods, which tend to preserve peak widths and heights better than Savitzky-Golay. As such, Savitzky-Golay filters are very suitable for biomedical data, such as ECG datasets.</p>



<h3 class="wp-block-heading"><strong>Eliminating the 50Hz powerline component</strong></h3>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8 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>Designing an 18th order Savitzky-Golay filter with a 4th order polynomial fit (see the example code below), we obtain an FIR filter with a zero distribution as shown on the right. However, as we wish to eliminate the 50Hz component completely, the tool’s P-Z editor can be used to nudge a zero pair (shown in green) to exactly 50Hz.</p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%"><div class="wp-block-image">
<figure class="alignright size-large is-resized"><img loading="lazy" decoding="async" src="https://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_fir_pz.png" alt="" width="326" height="309"/></figure></div></div>
</div>



<p>The resulting frequency response is shown below, where it can be seen that there is notch at exactly 50Hz, and the group delay of 9 samples (shown in purple) is constant across the frequency band.</p>


<div class="wp-block-image">
<figure class="aligncenter"><a href="http://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_fir_fr.png"><img loading="lazy" decoding="async" width="446" height="524" src="http://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_fir_fr.png" alt="FIR  Savitzky-Golay filter frequency response, ECG signal processing, ECG DSP, ECG measurement" class="wp-image-8588" srcset="https://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_fir_fr.png 446w, https://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_fir_fr-255x300.png 255w" sizes="auto, (max-width: 446px) 100vw, 446px" /></a></figure></div>


<p class="has-text-align-center"><em>FIR&nbsp; Savitzky-Golay filter frequency response</em></p>



<p>Passing the tainted ECG dataset through our tweaked Savitzky-Golay filter, and adjusting for the group delay we obtain:</p>


<div class="wp-block-image">
<figure class="aligncenter"><a href="http://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_fir_td.png"><img loading="lazy" decoding="async" width="746" height="407" src="http://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_fir_td.png" alt="Contaminated ECG with non-stationary 50Hz powerline interference (FIR filtering), ECG signal processing, ECG digital filter, ECG filter designa" class="wp-image-8584" srcset="https://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_fir_td.png 746w, https://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_fir_td-300x164.png 300w, https://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_fir_td-705x385.png 705w, https://www.advsolned.com/wp-content/uploads/2019/05/biomedical_ex_fir_td-450x246.png 450w" sizes="auto, (max-width: 746px) 100vw, 746px" /></a></figure></div>


<p class="has-text-align-center"><em>Contaminated ECG with non-stationary 50Hz powerline interference (FIR filtering)</em></p>



<p>As seen, there are <strong>no signs of ringing and the ST segments are now clearly visible for analysis</strong>. Notice also how the filter (shown in red) has reduced the measurement noise, emphasising the practicality of Savitzky-Golay filter’s for biomedical signal processing.</p>



<p>A Savitzky-Golay may be designed and optimised in <span style="color: #0000ff;"><a style="color: #0000ff;" href="httpS://www.advsolned.com/asn-filterscript-gsg/">ASN FilterScript</a></span> via the <span style="font-family: courier;">savgolay()</span> function, as follows:</p>



<pre class="brush: java; title: ; notranslate">
ClearH1;  // clear primary filter from cascade

interface L = {2, 50,2,24};
interface P = {2, 10,1,4};

Main()

Hd=savgolay(L,P,&quot;numeric&quot;);  // Design Savitzky-Golay lowpass
Num=getnum(Hd);
Den={1};
Gain=getgain(Hd);
</pre>


<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">Deployment</h2>



<p>This filter may now be deployed to variety of domains via the tool’s automatic code generator, enabling rapid deployment in Matlab, Python and embedded Arm Cortex-M devices.</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9 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"><a href="https://www.advsolned.com/asn_filter_designer/"><img loading="lazy" decoding="async" width="495" height="400" src="https://www.advsolned.com/wp-content/uploads/2019/12/Softwareboxshadow-verkleind-495x400_verleind.jpg" alt="ASN Filter Designer box" class="wp-image-10817" 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" /></a></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-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-3 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/pricing-and-licencing/" style="color:#ffffff">Pricing and Licencing</a></div>


</div>
</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>                                                                                                                                                                                                        <p class="pp-author-boxes-description multiple-authors-description author-description-0">
                                                                                                                                                    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>
                                                                                                                                
                                                                                                                                    <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 -->
                    
                
                                <style>
                .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-avatar img { 
        width: 80px !important; 
        height: 80px !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-avatar img {
        border-radius: 50% !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-meta a {
        background-color: #655997 !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-meta a {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-meta a:hover {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data {
        background-color: #655997 !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data {
        border-radius: 100% !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data:hover {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data {
        background-color: #655997 !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data {
        border-radius: 100% !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data:hover {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-recent-posts-title {
        border-bottom-style: dotted !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-multiple-authors-boxes-li {
        border-style: solid !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-multiple-authors-boxes-li {
        color: #3c434a !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-multiple-authors-boxes-li {
        border-radius: px !important; 
    }

            </style>
        
        </p>



<p></p>
		<div class="wpulike wpulike-default " ><div class="wp_ulike_general_class wp_ulike_is_not_liked"><button type="button"
					aria-label="Like Button"
					data-ulike-id="8573"
					data-ulike-nonce="fcba00f728"
					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_8573"></button><span class="count-box wp_ulike_counter_up" data-ulike-counter-value="+8"></span>			</div></div>
	<p>The post <a rel="nofollow" href="https://www.advsolned.com/noise-reduction-tips-biomedical-ecg-data/">Practical noise reduction tips for biomedical ECG filters</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Deploying legacy analog filters to Arm Cortex-M processor cores</title>
		<link>https://www.advsolned.com/deploying-legacy-analog-filters-to-arm-cortex-m-processors/</link>
					<comments>https://www.advsolned.com/deploying-legacy-analog-filters-to-arm-cortex-m-processors/#respond</comments>
		
		<dc:creator><![CDATA[Dr. Sanjeev Sarpal]]></dc:creator>
		<pubDate>Fri, 14 Sep 2018 12:51:34 +0000</pubDate>
				<category><![CDATA[ASN FilterScript]]></category>
		<category><![CDATA[analog filter]]></category>
		<category><![CDATA[BZT]]></category>
		<category><![CDATA[CMSIS-DSP]]></category>
		<category><![CDATA[Cortex-M]]></category>
		<category><![CDATA[IoT]]></category>
		<category><![CDATA[legacy]]></category>
		<category><![CDATA[modeling]]></category>
		<guid isPermaLink="false">http://www.advsolned.com/?p=7792</guid>

					<description><![CDATA[<p>The ASN Filter Designer’s Arm automatic code generator automatically generates Arm CMSIS-DSP compliant C code suitable for direct implementation Cortex-M</p>
<p>The post <a rel="nofollow" href="https://www.advsolned.com/deploying-legacy-analog-filters-to-arm-cortex-m-processors/">Deploying legacy analog filters to Arm Cortex-M processor cores</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In recent years, major microcontroller IC vendors such as: ST, NXP, TI, ADI, Atmel/Microchip, Cypress, Maxim to name but a few have based their modern 32-bit microcontrollers on Arm’s Cortex-M processor cores. This exciting trend means that algorithms traditionally undertaken in expensive DSPs (digital signal processors) can now be integrated into a powerful low-cost and power efficient microcontroller packed full of a rich assortment of connectivity and peripheral options, which is ideal for many IoT applications.</p>



<p>For many IC vendors, the coupling of DSP functionality with the flexibility of a low power microcontroller, has allowed them to offer their customers a generation of so called <strong>32-bit enhanced microcontrollers</strong> suitable for a variety of practical applications. More importantly, this marriage of technologies has also allowed designers working on price critical IoT applications to implement complex algorithmic concepts, while at the same time keeping the overall product cost low and still achieving excellent low power performance.</p>



<h2 class="wp-block-heading">Upgrading legacy analog filters with the ASN Filter Designer</h2>



<p>Analog filters have been around since the beginning of electronics, ranging from simple inductor-capacitor networks to more advanced active filters with op-amps. As such, there is a rich collection of tried and tested legacy filter designs for a broad range of sensor measurement applications.</p>



<p>ASN’s FilterScript symbolic math scripting language offers designers the ability to take an existing analog filter transfer function and transform it to digital with just a few lines of code. The ASN Filter Designer’s Arm automatic code generator analyses the designed digital filter and then<strong> automatically generates Arm CMSIS-DSP compliant C code</strong> suitable for direct implementation on a Cortex-M based microcontroller.</p>



<h3 class="wp-block-heading"><strong>Arm CMSIS-DSP software framework</strong></h3>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-10 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.7%">
<p>The <a style="color: #0000ff;" href="https://arm-software.github.io/CMSIS_5/DSP/html/index.html">Arm CMSIS-DSP</a> (Cortex Microcontroller Software Interface Standard)&nbsp; 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" style="flex-basis:30%"><div class="wp-block-image is-resized">
<figure class="alignright size-large"><img decoding="async" src="https://www.advsolned.com/wp-content/uploads/2018/02/cmsis.png" alt=""/></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>



<h2 class="wp-block-heading">Mathematically modelling an analog circuit</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="http://www.advsolned.com/wp-content/uploads/2018/09/preempcircuit.png"><img loading="lazy" decoding="async" width="796" height="397" src="https://www.advsolned.com/wp-content/uploads/2020/04/preempcircuit.png" alt="" class="wp-image-12246" srcset="https://www.advsolned.com/wp-content/uploads/2020/04/preempcircuit.png 796w, https://www.advsolned.com/wp-content/uploads/2020/04/preempcircuit-300x150.png 300w, https://www.advsolned.com/wp-content/uploads/2020/04/preempcircuit-768x383.png 768w, https://www.advsolned.com/wp-content/uploads/2020/04/preempcircuit-705x352.png 705w, https://www.advsolned.com/wp-content/uploads/2020/04/preempcircuit-450x224.png 450w" sizes="auto, (max-width: 796px) 100vw, 796px" /></a></figure></div>


<p>Consider the active pre-emphasis filter shown below. The pre-emphasis filter has found particular use in audio work, since it is necessary to amplify the higher frequencies of the speech spectrum, whilst leaving the lower frequencies unaffected. The R and C values shown are only indented for the example, more practical values will depend on the application. A powerful method of reproducing the magnitude and phases characteristics of the analog filter in a digital implementation, is to mathematically model the circuit. This circuit may be analysed using Kirchhoff’s law, since the sum of currents into the op-amp’s inverting input <strong>must be equal to zero for negative feedback to work correctly</strong> – this results in a transfer function with a negative gain.</p>



<p>Therefore, using Ohm&#8217;s law, i.e. \(I=\frac{V}{R}\),</p>


\(<br />
\displaystyle\frac{X(s)}{R_3}=-\frac{U(s)}{C_1||R_2 + R_1}<br />
\)



<p>After some algebraic manipulation, it can be seen that an expression for the circuit&#8217;s closed loop gain may be expressed as,</p>


\(<br />
\displaystyle\frac{X(s)}{U(s)}=-\frac{R_3}{R_1}\frac{\left(s+\frac{1}{R_2C_1}\right)}{\left(s+\frac{R_1+R_2}{R_1R_2C_1}\right)}<br />
\)



<p>substituting the values shown in the circuit diagram into the developed transfer function, yields</p>


\(<br />
\displaystyle H(s)=-10\left(\frac{s+1000}{s+11000}\right)<br />
\)



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><strong>What sampling rate do we need?<span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span></strong><br></h3>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-11 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:20%">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="220" height="233" src="https://www.advsolned.com/wp-content/uploads/2020/04/SRpremp.png" alt="" class="wp-image-12249"/></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p>Analysing the cut-off frequencies in \(H(s)\), we see that the upper frequency is at \(11000 rad/sec\) or \(1.75kHz\). Therefore, setting the sampling rate to \(16kHz\) should be adequate for modelling the filter in the digital domain.</p>



<p>The sampling rate options are avaliabe in the main filter design UI&nbsp; (shown on the left).</p>



<p></p>
</div>
</div>



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



<p>\(H(s)\) can be easily specified in FilterScript with the <code>analogtf</code> function, as follows:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: java; gutter: false; title: ; notranslate">
Nb={1,1000};
Na={1,11000};

Ha=analogtf(Nb,Na,-10,"symbolic");
</pre></div>


<p>Notice how the negative gain may also be entered directly into function’s argument. The <code>symbolic</code> keyword generates a symbolic transfer function representation in the command window.</p>


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


<p>Applying the Bilinear z-transformation via the <code>bilinear</code> command with no pre-warping, i.e.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: java; gutter: false; title: ; notranslate">
Hd=bilinear(Ha,0,"symbolic");
</pre></div>

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


<p><br>Notice how the <code>bilinear</code> command automatically scales numerator coefficients by -1, in order to account for the effect of the negative gain. The command also automatically assigns the analog filter to the reference spectrum object, which can be shown via the <code>ShowH2DM</code> keyword. The complete code is shown below:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: java; title: ; notranslate">
ClearH1;    // remove other filters from the cascade
ShowH2DM;   // show the analog reference spectrum 

Main()

Nb={1,1000};
Na={1,11000};

Ha=analogtf(Nb,Na,-10,"symbolic");
Hd=bilinear(Ha,0,"symbolic");

Num=getnum(Hd);
Den=getden(Hd);
Gain=getgain(Hd);
</pre></div>


<p>A comparison of the analog (shown in red) and discrete (shown in blue) magnitude spectra is shown below. Analysing the spectra, it can be seen that for a sampling rate of 16kHz the analog and digital filters are almost identical! This demonstrates the relative ease with which a designer can port their existing legacy analog designs into digital.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="656" height="663" src="https://www.advsolned.com/wp-content/uploads/2018/09/analog_vs_digital_laplace.png" alt="" class="wp-image-20889" srcset="https://www.advsolned.com/wp-content/uploads/2018/09/analog_vs_digital_laplace.png 656w, https://www.advsolned.com/wp-content/uploads/2018/09/analog_vs_digital_laplace-297x300.png 297w, https://www.advsolned.com/wp-content/uploads/2018/09/analog_vs_digital_laplace-80x80.png 80w, https://www.advsolned.com/wp-content/uploads/2018/09/analog_vs_digital_laplace-36x36.png 36w, https://www.advsolned.com/wp-content/uploads/2018/09/analog_vs_digital_laplace-120x120.png 120w, https://www.advsolned.com/wp-content/uploads/2018/09/analog_vs_digital_laplace-450x455.png 450w" sizes="auto, (max-width: 656px) 100vw, 656px" /></figure></div>


<h2 class="wp-block-heading">Automatic code generation to Arm Cortex-M processors</h2>



<p>As mentioned at the beginning of this article, the ASN filter designer’s automatic code generation engine facilitates the export of a designed filter to Cortex-M Arm based processor cores via the CMSIS-DSP software framework. </p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-12 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>The tool’s built-in analytics and help functions assist the designer in successfully configuring the design for deployment. Professional licence users may expedite the deployment by using the <strong>Arm deployment wizard</strong> that automates the steps described below.</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="326" height="274" src="https://www.advsolned.com/wp-content/uploads/2018/09/Armwizard.png" alt="" class="wp-image-17853" 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: 326px) 100vw, 326px" /></figure>
</div>
</div>



<h3 class="wp-block-heading"><span class="" style="display:block;clear:both;height: 0px;padding-top: 25px;border-top-width:0px;border-bottom-width:0px;"></span><strong>Steps required for Educational licence</strong> <strong>users</strong></h3>



<p>Before generating the code, the H2 filter (i.e. the filter designed in FilterScript) needs to be firstly re-optimised (transformed) 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/2020/04/reopt_preemp-1.png" alt="" class="wp-image-12257" srcset="https://www.advsolned.com/wp-content/uploads/2020/04/reopt_preemp-1.png 359w, https://www.advsolned.com/wp-content/uploads/2020/04/reopt_preemp-1-300x106.png 300w" sizes="auto, (max-width: 359px) 100vw, 359px" /></a></figure></div>


<p><span class="" style="display:block;clear:both;height: 0px;padding-top: 5px;border-top-width:0px;border-bottom-width:0px;"></span>All floating point IIR filters designs must 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. 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-13 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.3%">
<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-2.png" alt="" class="wp-image-12258"/></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p>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>



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


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



<p><strong>Arm CMSIS-DSP application C code</strong></p>



<p>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"><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>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-full"><img loading="lazy" decoding="async" width="686" height="638" src="https://www.advsolned.com/wp-content/uploads/2018/09/analog_vs_digital_laplace_code.png" alt="" class="wp-image-20891" srcset="https://www.advsolned.com/wp-content/uploads/2018/09/analog_vs_digital_laplace_code.png 686w, https://www.advsolned.com/wp-content/uploads/2018/09/analog_vs_digital_laplace_code-300x279.png 300w, https://www.advsolned.com/wp-content/uploads/2018/09/analog_vs_digital_laplace_code-450x419.png 450w" sizes="auto, (max-width: 686px) 100vw, 686px" /></figure></div>


<p>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="https://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>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.</p>



<h2 class="wp-block-heading">What have we learned?</h2>



<p>The <strong>ASN Filter Designer provides engineers with everything they need</strong> in order to port legacy analog filter designs to a variety of Cortex-M processor cores.</p>



<p>The FilterScript symbolic math scripting language offers designers the ability to take an existing analog filter transfer function and transform it to digital (via the Bilinear z-transform or matched z-transform) with just a few lines of code.</p>



<p>The Arm automatic code generator analyses the designed digital filter and then <strong>automatically generates Arm CMSIS-DSP compliant C code</strong> suitable for direct implementation on a Cortex-M based microcontroller.</p>


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



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



<ol class="wp-block-list">
<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="https://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>


<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-14 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 decoding="async" src="https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox.png" alt=""/></figure>
</div>



<div class="wp-block-column is-vertically-aligned-center has-medium-font-size is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<div class="wp-block-buttons is-vertical is-layout-flex wp-container-core-buttons-is-layout-4 wp-block-buttons-is-layout-flex">
<div class="wp-block-button has-custom-width wp-block-button__width-75 is-style-outline is-style-outline--1"><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>



<div class="wp-block-buttons is-vertical is-layout-flex wp-container-core-buttons-is-layout-5 wp-block-buttons-is-layout-flex">
<div class="wp-block-button has-custom-width wp-block-button__width-75 is-style-outline is-style-outline--2"><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/pricing-and-licencing/" style="color:#ffffff">Pricing and Licencing</a></div>
</div>
</div>
</div>


<p><span class="" style="display:block;clear:both;height: 0px;padding-top: 25px;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>                                                                                                                                                                                                        <p class="pp-author-boxes-description multiple-authors-description author-description-0">
                                                                                                                                                    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>
                                                                                                                                
                                                                                                                                    <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 -->
                    
                
                                <style>
                .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-avatar img { 
        width: 80px !important; 
        height: 80px !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-avatar img {
        border-radius: 50% !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-meta a {
        background-color: #655997 !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-meta a {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-meta a:hover {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data {
        background-color: #655997 !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data {
        border-radius: 100% !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data:hover {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data {
        background-color: #655997 !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data {
        border-radius: 100% !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data:hover {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-recent-posts-title {
        border-bottom-style: dotted !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-multiple-authors-boxes-li {
        border-style: solid !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-multiple-authors-boxes-li {
        color: #3c434a !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-multiple-authors-boxes-li {
        border-radius: px !important; 
    }

            </style>
        
        </p>
		<div class="wpulike wpulike-default " ><div class="wp_ulike_general_class wp_ulike_is_not_liked"><button type="button"
					aria-label="Like Button"
					data-ulike-id="7792"
					data-ulike-nonce="2d22f6845b"
					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_7792"></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/deploying-legacy-analog-filters-to-arm-cortex-m-processors/">Deploying legacy analog filters to Arm Cortex-M processor cores</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.advsolned.com/deploying-legacy-analog-filters-to-arm-cortex-m-processors/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Converting analog into digital filters</title>
		<link>https://www.advsolned.com/converting-analog-digital-filters/</link>
					<comments>https://www.advsolned.com/converting-analog-digital-filters/#respond</comments>
		
		<dc:creator><![CDATA[Dr. Sanjeev Sarpal]]></dc:creator>
		<pubDate>Thu, 02 Aug 2018 15:44:21 +0000</pubDate>
				<category><![CDATA[ASN FilterScript]]></category>
		<category><![CDATA[analog filters]]></category>
		<category><![CDATA[analog prototype]]></category>
		<category><![CDATA[analog-digital transform]]></category>
		<category><![CDATA[analog-to-digital]]></category>
		<category><![CDATA[BZT]]></category>
		<category><![CDATA[IIT]]></category>
		<category><![CDATA[lowpass]]></category>
		<category><![CDATA[transforms]]></category>
		<guid isPermaLink="false">http://www.advsolned.com/?p=6364</guid>

					<description><![CDATA[<p>The post <a rel="nofollow" href="https://www.advsolned.com/converting-analog-digital-filters/">Converting analog into digital filters</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></description>
										<content:encoded><![CDATA[<section class="av_textblock_section "  itemscope="itemscope" itemtype="https://schema.org/BlogPosting" itemprop="blogPost" ><div class='avia_textblock  '   itemprop="text" ><h2><strong>Upgrading legacy designs based on analog filters</strong></h2>
<p>Analog filters have been around since the beginning of electronics, ranging from simple inductor-capacitor networks to more advanced active filters with op-amps. As such, there is a rich collection of tried and tested legacy filter designs for a broad range of sensor measurement applications. However, with the performance requirements of modern IoT (Internet of Things) sensor measurement applications and lower product costs, digital filters integrated into the microcontroller&#8217;s application code are becoming the norm, but <strong>how can we get the best of both worlds</strong>?</p>
<p>Rather than re-inventing the wheel, product designers can take an existing analog filter transfer function, transform it to digital (via a transform) and implement it as digital filter in a microcontroller or DSP (digital signal processor). Although  <strong>analog-to-digital transforms</strong> have been around for decades, the availability of DSP design tooling for tweaking the &#8216;transformed digital filter&#8217; has been somewhat limited, hindering the design and validation process.</p>
<p>A 2nd order analog lowpass filter is shown below, and in its simplest form, only 5 components are required to build the filter, which sounds easy. Right?<a href="http://www.advsolned.com/wp-content/uploads/2018/07/analog_loadcellfilt.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-6330 size-full" style="border: 1px solid #000000; margin-top: 10px; margin-bottom: 10px;" src="http://www.advsolned.com/wp-content/uploads/2018/07/analog_loadcellfilt.png" alt="2nd order analog lowpass filter" width="1224" height="290" srcset="https://www.advsolned.com/wp-content/uploads/2018/07/analog_loadcellfilt.png 1224w, https://www.advsolned.com/wp-content/uploads/2018/07/analog_loadcellfilt-300x71.png 300w, https://www.advsolned.com/wp-content/uploads/2018/07/analog_loadcellfilt-768x182.png 768w, https://www.advsolned.com/wp-content/uploads/2018/07/analog_loadcellfilt-1030x244.png 1030w, https://www.advsolned.com/wp-content/uploads/2018/07/analog_loadcellfilt-705x167.png 705w, https://www.advsolned.com/wp-content/uploads/2018/07/analog_loadcellfilt-450x107.png 450w, https://www.advsolned.com/wp-content/uploads/2018/07/analog_loadcellfilt-1200x284.png 1200w" sizes="auto, (max-width: 1224px) 100vw, 1224px" /></a></p>
<p><strong>The pros</strong></p>
<p>The most obvious advantage is that analog filters have an excellent resolution, as there are no ‘number of bits’ to consider. Analog filters have good EMC (electromagnetic compatibility) properties as there is no clock generating noise. There are no effects of aliasing, which is certainly true for the simpler op-amps, which don’t have any fancy chopping or auto-calibration circuitry built into them, and analog designs can be cheap which is great for cost sensitive applications.</p>
<h3><strong>Sound great, but what’s the bad news?</strong></h3>
<p>Analog filters have several significant disadvantages that affect filter performance, such as component aging, temperature drift and component tolerance. Also, good performance requires good analog design skills and good PCB (printed circuit board) layout, which is hard to find in the contemporary skills market.</p>
<p>These disadvantages make digital filters much more attractive for modern applications, that require high repeatability of characteristics.  Looking at an example, let’s say that you want to manufacture 1000 measurement modules after optimising your filter design. With <strong>a digital solution you can be sure that the performance of your filter will be identical in all modules</strong>. This is certainly not the case with analog, as component tolerance, component aging and temperature drift mean that each module’s filter will have its own characteristics. Also, an analog filter&#8217;s frequency response remains fixed, i.e. a Butterworth filter will always be a Butterworth filter – any changes the frequency response would require physically changing components on the PCB – not ideal!</p>
<p>Digital filters are adaptive and flexible, we can design and implement a filter with any frequency response that we want, deploy it and then update the filter coefficients without changing anything on the PCB! It’s also easy to design digital filters with <strong>linear phase and at very low sampling frequencies</strong> – two things that are tricky with analog.</p>
<h2>Laplace to discrete/digital transforms</h2>
<p>The three methods discussed herein essentially involve transforming a Laplace (analog) transfer function, \(H(s)\) into a discrete transfer function, \(H(z)\) such that a tried and tested analog filter that is already used in a design may be implemented on a microcontroller or DSP.</p>
<p>A selection of some useful Laplace to z-transforms are given in table below:<span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span></p>
<p style="text-align: center;">\(<br />
\begin{array}{ccc}\hline<br />
H(s) &#038;\longleftrightarrow &#038; H(z) \\ \hline<br />
1 &#038;\longleftrightarrow &#038; 1 \\<br />
\frac{\displaystyle1}{\displaystyle s}<br />
&#038;\longleftrightarrow&#038; \frac{\displaystyle 1}{\displaystyle 1-z^{\scriptstyle -1}}\\<br />
\frac{\displaystyle 1}{\displaystyle s^{\scriptstyle 2}} &#038;\longleftrightarrow&#038; \frac{\displaystyle<br />
Tz^{\scriptstyle-1}}{\displaystyle (1-z^{\scriptstyle -1})^2}\\<br />
\frac{\displaystyle 1}{\displaystyle s+a}<br />
&#038;\longleftrightarrow&#038;<br />
\frac{\displaystyle 1}{\displaystyle 1-e^{-aT}z^{-1}}\\<br />
\frac{\displaystyle 1}{\displaystyle (s+a)^2}<br />
&#038;\longleftrightarrow&#038; \frac{\displaystyle z^{-1}(1-e^{-aT})}{\displaystyle a(1-z^{-1})(1-e^{-aT}z^{-1})}\\\hline<br />
\end{array}<br />
\)<span class="" style="display:block;clear:both;height: 0px;padding-top: 5px;border-top-width:0px;border-bottom-width:0px;"></span><br />
<em>A table of useful Laplace and z-transforms</em></p>
<span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>
<h3><strong>The Bilinear z-transform (BZT)</strong></h3>
<p>The Bilinear z-transform (BZT), simply converts an analog transfer function, \(H(s)\) into a discrete transfer function, \(H(z)\) by replacing all \(s\) terms with the following:</p>
<p style="text-align: center;">\(\displaystyle<br />
s=\frac{2}{T}\frac{1-z^{-1}}{1+z^{-1}} \label{bzt}\)</p>
<p>where, \(T\) is the discrete system&#8217;s sampling period. However, substituting \(s=j\Omega\) and \(z=e^{jwT}\) into the BZT equation and simplifying, notice that there is actually a non-linear relationship between the analog, \(\Omega\) and discrete, \(w\) frequencies. This relationship is shown below, and is due to the nonlinearity of the arctangent function.</p>
<p style="text-align: center;">\(\displaystyle\omega=2\tan^{-1}\left(\frac{\Omega T}{2}\right)\label{bzt_warp_def1}\)</p>
<p>Analysing the equation, it can be seen that the equally spaced  analog frequencies in the range \( -\infty\lt\Omega\lt\infty\) are nonlinearly compressed in the frequency range \( -\pi\lt w\lt\pi\) in the discrete domain. This relationship is referred to as frequency warping, and may be compensated for by pre-warping the analog frequencies by:</p>
<p style="text-align: center;">\(\displaystyle<br />
\Omega_c=\frac{2}{T}\tan\left(\frac{\Omega_d T}{2}\right)<br />
\label{bzt_warp_def2}<br />
\)</p>
<p style="text-align: left;">where, \(\displaystyle\Omega_c\) is the compensated or pre-warped analog frequency, and \(\displaystyle\Omega_d\) is the desired analog frequency.</p>
<p style="text-align: left;">The ASN FilterScript command \(\texttt{bilinear}\) may be used convert a Laplace transfer function into its discrete equivalent using the BZT transform. An example is given <span style="color: #0000ff;"><a style="color: #0000ff;" href="#example">below</a></span>.</p>
<h3><strong>The Impulse Invariant Transform</strong></h3>
<p>The second transform, is referred to as the impulse invariant transform (IIT), since the poles of the Laplace transfer function are converted into their discrete equivalents, such that the discrete impulse response, \(h(n)\) is identical to a regularly sampled representation of the analog impulse response (i.e., \(h(n)=h(nT)\), where \(T\) is the sampling rate, and \(t=nT\)). The IIT is a much more tedious transformation technique than the BZT, since the Laplace transfer function must be firstly expanded using partial fractions before applying the transform.</p>
<p style="text-align: left;">The transformation technique is defined below:</p>
<p style="text-align: center;">\(\displaystyle<br />
\frac{K}{s+a} \quad\longrightarrow\quad<br />
\frac{K}{1-e^{-aT}z^{-1}} \label{iit_def}<br />
\)</p>
<p>This method <strong>suffers from several constraints</strong>, since it does not allow for the transformation of zeros or individual constant terms (once expanded), and must have a high sampling rate in order to overcome the effects of spectral aliasing. Indeed, the effects of aliasing hinder this method considerably, such that the method should only be used when the requirement is to match the analog transfer function&#8217;s impulse response, since the resulting discrete model may have a different magnitude and phase spectrum (frequency response) to that of the original analog system. Consequently, the impulse invariant method is unsuitable for modelling highpass filters, and is therefore limited to the modelling of lowpass or bandpass type filters.</p>
<p>Due to the aforementioned limitations of the IIT method, it is currently not supported in ASN Filterscript.</p>
<h3><strong>The Matched-z transformation</strong></h3>
<p>Another analog to discrete modelling technique is the matched-z transformation. As the name suggests, the transform<strong> converts the poles and zeros from the analog transfer function directly into poles and zeros in the z-plane</strong>. The transformation is described below, where \(T\) is the sampling rate.</p>
<p style="text-align: center;">\(\displaystyle<br />
\frac{\prod\limits_{k=1}^q(s+b_k)}{\prod\limits_{k=1}^p(s+a_k)}<br />
\quad\longrightarrow\quad<br />
\frac{\prod\limits_{k=1}^q(1-e^{-b_kT}z^{-1})}{\prod\limits_{k=1}^p(1-e^{-a_kT}z^{-1})}<br />
\label{matchedz_def}<br />
\)</p>
<p>Analysing the transform equation, it can be seen that the transformed z-plane poles will be identical to the poles obtained with the impulse invariant method. However, notice that the positions of the zeros will be different, since the impulse invariant method cannot transform them.</p>
<p>The ASN Filterscript command \(\texttt{mztrans}\) is available for this method.</p>
<h2 id="example">A detailed example</h2>
<p>In order to demonstrate the ease of transforming analog filters into their discrete/digital equivalents using the analog to discrete transforms, an example of modelling with the BZT will now follow for a 2nd order lowpass analog filter.</p>
<p>A generalised 2nd order lowpass analog filter is given by:</p>
<p style="text-align: center;">\(\displaystyle<br />
H(s)=\frac{w_c^2}{s^2+2\zeta w_c s + w_c^2}<br />
\)</p>
<p>where, \(w_c=2\pi f_c\) is the cut-off frequency and \(\zeta\) sets the damping of the filter,  where a  \(\zeta=1/\sqrt{2}\) is said to be critically damped or equal to -3dB at \(w_c\). Many analog engineers choose to specify a quality factor, \(Q =  \displaystyle\frac{1}{2\zeta}\) or peaking factor for their designs. Substituting \(Q\) into \(H(s)\), we obtain:</p>
<p style="text-align: center;">\(\displaystyle<br />
H(s)=\frac{w_c^2}{s^2+ \displaystyle{\frac{w_c}{Q}s} + w_c^2}<br />
\)</p>
<p style="text-align: left;">Analysing, \(H(s)\) notice that \(Q=1/\sqrt{2} = 0.707\) also results in a critically damped response. Various values of \(Q\) are shown below, and as seen when \(Q>1/\sqrt{2}\) peaking occurs.</p>
<p><a href="http://www.advsolned.com/wp-content/uploads/2018/08/analogQ.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-6680" src="http://www.advsolned.com/wp-content/uploads/2018/08/analogQ.png" alt="Values of Q" width="635" height="330" srcset="https://www.advsolned.com/wp-content/uploads/2018/08/analogQ.png 942w, https://www.advsolned.com/wp-content/uploads/2018/08/analogQ-300x156.png 300w, https://www.advsolned.com/wp-content/uploads/2018/08/analogQ-768x399.png 768w, https://www.advsolned.com/wp-content/uploads/2018/08/analogQ-705x366.png 705w, https://www.advsolned.com/wp-content/uploads/2018/08/analogQ-450x234.png 450w" sizes="auto, (max-width: 635px) 100vw, 635px" /></a></p>
<p style="text-align: center;"><em>2nd order lowpass filter prototype magnitude spectrum for various value of Q:<br />
notice that when \(Q>1/\sqrt{2}\) peaking occurs.</em></p>
<p>Before applying the BZT in ASN FilterScript, the analog transfer function must be specified in an analog filter object. The following code sets up an analog filter object for the 2nd order lowpass prototype considered herein:<br />
[code language=&#8221;java&#8221;]<br />
Main()</p>
<p>wc=2*pi*fc;<br />
Nb={0,0,wc^2};<br />
Na={1,wc/Q,wc^2};</p>
<p>Ha=analogtf(Nb,Na,1,&quot;symbolic&quot;); // make analog filter object<br />
[/code]<br />
The \(\texttt{symbolic}\) keyword generates a symbolic transfer function representation in the command window. For a sampling rate of \(f_s=500Hz\) and \(f_c=30Hz\) and \(Q=0.707\), we obtain:</p>
<p><a href="http://www.advsolned.com/wp-content/uploads/2018/08/analogTF.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-6683 size-full" src="http://www.advsolned.com/wp-content/uploads/2018/08/analogTF.png" alt="ASN FilterScript analog command" width="398" height="104" srcset="https://www.advsolned.com/wp-content/uploads/2018/08/analogTF.png 398w, https://www.advsolned.com/wp-content/uploads/2018/08/analogTF-300x78.png 300w" sizes="auto, (max-width: 398px) 100vw, 398px" /></a></p>
<p>Applying the BZT via the \(\texttt{bilinear}\) command without prewarping,<br />
[code language=&#8221;java&#8221; light=&#8221;true&#8221;] Hd=bilinear(Ha,0,&quot;symbolic&quot;); [/code]<br />
<a href="https://www.advsolned.com/wp-content/uploads/2018/08/bilinearTF.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-12435 size-full" src="https://www.advsolned.com/wp-content/uploads/2018/08/bilinearTF.png" alt="bilinear transformation" width="510" height="116" srcset="https://www.advsolned.com/wp-content/uploads/2018/08/bilinearTF.png 510w, https://www.advsolned.com/wp-content/uploads/2018/08/bilinearTF-300x68.png 300w, https://www.advsolned.com/wp-content/uploads/2018/08/bilinearTF-450x102.png 450w" sizes="auto, (max-width: 510px) 100vw, 510px" /></a></p>
<p>The complete frequency response of the transformed digital filter is shown below, where it can be seen that the at \(30Hz\) the magnitude is \(-3dB\) and the phase is \( -90^{\circ}\), which is as expected. Notice also how the filter&#8217;s magnitude roll-off  is affected by the double zero pair at Nyquist (see the z-plane chart below), leading to differences from its analog cousin. <span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span><a href="http://www.advsolned.com/wp-content/uploads/2018/08/analogQzp.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-6693" src="http://www.advsolned.com/wp-content/uploads/2018/08/analogQzp.png" alt="Pole-zero chart 2nd order LPF" width="353" height="353" srcset="https://www.advsolned.com/wp-content/uploads/2018/08/analogQzp.png 357w, https://www.advsolned.com/wp-content/uploads/2018/08/analogQzp-80x80.png 80w, https://www.advsolned.com/wp-content/uploads/2018/08/analogQzp-300x300.png 300w, https://www.advsolned.com/wp-content/uploads/2018/08/analogQzp-36x36.png 36w, https://www.advsolned.com/wp-content/uploads/2018/08/analogQzp-180x180.png 180w, https://www.advsolned.com/wp-content/uploads/2018/08/analogQzp-120x120.png 120w" sizes="auto, (max-width: 353px) 100vw, 353px" /></a></p>
<p><a href="http://www.advsolned.com/wp-content/uploads/2018/08/analogQfr.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-6686" src="http://www.advsolned.com/wp-content/uploads/2018/08/analogQfr.png" alt="2nd order LPF" width="513" height="581" srcset="https://www.advsolned.com/wp-content/uploads/2018/08/analogQfr.png 580w, https://www.advsolned.com/wp-content/uploads/2018/08/analogQfr-265x300.png 265w, https://www.advsolned.com/wp-content/uploads/2018/08/analogQfr-450x509.png 450w" sizes="auto, (max-width: 513px) 100vw, 513px" /></a></p>
<p>The pole-zero positions may be tweaked within ASN Filterscript or via the ASN Filter Designer&#8217;s interactive pole-zero z-plane plot editor by just using the mouse!</p>
<h2>Implementation</h2>
<p>The complete code for transforming a generalised 2nd order analog  lowpass filter prototype into its digital equivalent using the BZT via <span style="color: #0000ff;"><a style="color: #0000ff;" href="http://www.advsolned.com/asn_filter_designer/#live-math-scripting">ASN FilterScript</a></span> is given below:<span class="" style="display:block;clear:both;height: 0px;padding-top: 10px;border-top-width:0px;border-bottom-width:0px;"></span><br />
[code language=&#8221;java&#8221;]</p>
<p>ClearH1;  // clear primary filter from cascade<br />
interface Q = {0.1,10,0.02,0.707};<br />
interface fc = {10,200,10,40};</p>
<p>Main()</p>
<p>wc=2*pi*fc;<br />
Nb={0,0,wc^2};<br />
Na={1,wc/Q,wc^2};</p>
<p>Ha=analogtf(Nb,Na,1,&quot;symbolic&quot;); // make analog filter object<br />
Hd=bilinear(Ha,0,&quot;symbolic&quot;); // transform Ha via BZT into digital object, Hd</p>
<p>Num=getnum(Hd);<br />
Den=getden(Hd);<br />
Gain=getgain(Hd);</p>
<p>[/code]<br />
<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 Box" 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;"><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><br />
<span class="" style="display:block;clear:both;height: 0px;padding-top: 30px;border-top-width:0px;border-bottom-width:0px;"></span></p>
</div></section><br />
<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>                                                                                                                                                                                                        <p class="pp-author-boxes-description multiple-authors-description author-description-0">
                                                                                                                                                    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>
                                                                                                                                
                                                                                                                                    <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 -->
                    
                
                                <style>
                .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-avatar img { 
        width: 80px !important; 
        height: 80px !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-avatar img {
        border-radius: 50% !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-meta a {
        background-color: #655997 !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-meta a {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-meta a:hover {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data {
        background-color: #655997 !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data {
        border-radius: 100% !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data:hover {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data {
        background-color: #655997 !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data {
        border-radius: 100% !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data:hover {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-recent-posts-title {
        border-bottom-style: dotted !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-multiple-authors-boxes-li {
        border-style: solid !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-multiple-authors-boxes-li {
        color: #3c434a !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-multiple-authors-boxes-li {
        border-radius: px !important; 
    }

            </style>
        
        </p>
		<div class="wpulike wpulike-default " ><div class="wp_ulike_general_class wp_ulike_is_not_liked"><button type="button"
					aria-label="Like Button"
					data-ulike-id="6364"
					data-ulike-nonce="96d893200b"
					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_6364"></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/converting-analog-digital-filters/">Converting analog into digital filters</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.advsolned.com/converting-analog-digital-filters/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</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>                                                                                                                                                                                                        <p class="pp-author-boxes-description multiple-authors-description author-description-0">
                                                                                                                                                    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>
                                                                                                                                
                                                                                                                                    <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 -->
                    
                
                                <style>
                .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-avatar img { 
        width: 80px !important; 
        height: 80px !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-avatar img {
        border-radius: 50% !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-meta a {
        background-color: #655997 !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-meta a {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-meta a:hover {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data {
        background-color: #655997 !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data {
        border-radius: 100% !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_url-profile-data:hover {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data {
        background-color: #655997 !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data {
        border-radius: 100% !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .ppma-author-user_email-profile-data:hover {
        color: #ffffff !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-author-boxes-recent-posts-title {
        border-bottom-style: dotted !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-multiple-authors-boxes-li {
        border-style: solid !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-multiple-authors-boxes-li {
        color: #3c434a !important; 
    }

    .pp-multiple-authors-boxes-wrapper.pp-multiple-authors-layout-boxed.multiple-authors-target-shortcode .pp-multiple-authors-boxes-li {
        border-radius: px !important; 
    }

            </style>
        
        </p>
		<div class="wpulike wpulike-default " ><div class="wp_ulike_general_class wp_ulike_is_not_liked"><button type="button"
					aria-label="Like Button"
					data-ulike-id="6118"
					data-ulike-nonce="e6ff61a68c"
					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>
		<item>
		<title>All-pass Peaking/Bell filter</title>
		<link>https://www.advsolned.com/allpass-peaking-bell-filter/</link>
		
		<dc:creator><![CDATA[ASN consultancy team]]></dc:creator>
		<pubDate>Wed, 04 Jul 2018 16:51:51 +0000</pubDate>
				<category><![CDATA[ASN FilterScript]]></category>
		<category><![CDATA[allpass filter]]></category>
		<category><![CDATA[audio filter]]></category>
		<category><![CDATA[bell filter]]></category>
		<category><![CDATA[FIR]]></category>
		<category><![CDATA[magnitude equalisation]]></category>
		<category><![CDATA[peaking filter]]></category>
		<guid isPermaLink="false">http://www.advsolned.com/?p=6010</guid>

					<description><![CDATA[<p>A&#160; Peaking or Bell filter is a type of audio equalisation filter that boosts or attenuates the magnitude of a specified set of frequencies around a centre frequency in order to perform magnitude equalisation. As seen in the plot in the below, the filter gets its name from the shape of the its magnitude spectrum [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.advsolned.com/allpass-peaking-bell-filter/">All-pass Peaking/Bell filter</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>A&nbsp; Peaking or Bell filter is a type of audio equalisation filter that boosts or attenuates the magnitude of a specified set of frequencies around a centre frequency in order to perform magnitude equalisation. As seen in the plot in the below, the filter gets its name from the shape of the its magnitude spectrum (blue line) which resembles a Bell curve.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="http://www.advsolned.com/wp-content/uploads/2018/07/peakbell.png"><img decoding="async" src="https://www.advsolned.com/wp-content/uploads/2018/07/peakbell.png" alt="Peaking filter or Bell filter, a type of audio equalisation filter that boosts or attenuates the magnitude of a specified set of frequencies around a centre frequency in order to perform magnitude equalisation. As seen in the plot in the below, the filter gets its name from the shape of the its magnitude spectrum (blue line) which resembles a Bell curve."/></a></figure></div>


<p><em>Frequency response (magnitude shown in blue, phase shown in purple) of a 2nd order Bell filter peaking at 125Hz.</em></p>



<h2 class="wp-block-heading">All-pass filters</h2>



<p>Central to the Bell filter is the so called <a href="http://www.advsolned.com/all-pass-filter/">All-pass filter</a>. 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>A second order all-pass filter is defined as:</p>



<p class="has-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>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>A Bell filter can be constructed from the \(A(z)\) filter by the following transfer function:</p>



<p class="has-text-align-center">\(H(z)=\Large\frac{(1+K)+A(z)(1-K)}{2}\)</p>



<p>After some algebraic simplication, we obtain the transfer function for the Peaking or Bell filter as:</p>



<p class="has-text-align-center">\(H(z)=\Large{\frac{1}{2}}\left[\normalsize{(1+K)} + \underbrace{\Large\frac{k_2 + k_1(1+k_2)z^{-1}+z^{-2}}{1+k_1(1+k_2)z^{-1}+k_2 z^{-2}}}_{all-pass filter}\normalsize{(1-K)} \right] \)</p>


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



<ul class="wp-block-list">
<li>\(K\) is used to set the gain and sign of the peak</li>



<li>\(k_1\) sets the peak centre frequency</li>



<li>\(k_2\) sets the bandwidth of the peak</li>
</ul>


<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">Implementation</h2>



<p>A Bell filter may easily be implemented in <span style="color: #0000ff;"><a href="https://www.advsolned.com/asn-filterscript-gsg/">ASN FilterScript</a></span> as follows:</p>



<pre class="brush: java; title: ; notranslate">
ClearH1;  // clear primary filter from cascade
interface BW = {0,2,0.1,0.5}; // filter bandwidth
interface fc = {0, fs/2,fs/100,fs/4}; // peak/notch centre frequency
interface K = {0,3,0.1,0.5}; // gain/sign

Main()

k1=-cos(2*pi*fc/fs);
k2=(1-tan(BW/2))/(1+tan(BW/2));

Pz = {1,k1*(1+k2),k2}; // define denominator coefficients
Qz = {k2,k1*(1+k2),1}; // define numerator coefficients
Num = (Pz*(1+K) + Qz*(1-K))/2;
Den = Pz;
Gain = 1;
</pre>



<p>This code may now be used to design a suitable Bell filter, where the exact values of \(K, f_c\) and \(BW\) may be easily found by tweaking the interface variables and seeing the results in real-time, as described below.</p>



<h2 class="wp-block-heading">Designing the filter on the fly</h2>



<p>Central to the interactivity of the FilterScript IDE (integrated development environment) are the so called interface variables. An interface variable is simply stated: <em>a scalar input variable that can be used modify a symbolic expression without having to re-compile the code</em> &#8211; allowing designers to <strong>design on the fly</strong> and quickly reach an optimal solution.</p>



<p>As seen in the code example above, interface variables must be defined in the initialisation section of the code, and may contain constants (such as, <span style="font-family: courier;">fs</span> and <span style="font-family: courier;">pi</span>) and simple mathematical operators, such as multiply <span style="font-family: courier;">*</span> and <span style="font-family: courier;">/</span> divide. Where, adding functions to an interface variable is not supported.</p>



<p>An interface variable is defined as vector expression:</p>



<pre class="brush: java; light: true; title: ; notranslate">interface name = {minimum, maximum, step_size, default_value};</pre>



<p>Where, all entries must be real scalars values. Vectors and complex values will not compile.<br>[arve mp4=&#8221;https://www.advsolned.com/wp-content/uploads/2018/07/peakingfilter.mp4&#8243; align=&#8221;right&#8221; loop=&#8221;true&#8221; autoplay=&#8221;true&#8221; nodownload nofullscreen noremoteplayback&#8230; /]</p>



<h3 class="wp-block-heading"><strong>Real-time updates</strong></h3>



<p>All interface variables are modified via the interface variable controller GUI. After compiling the code, use the interface variable controller to tweak the interface variables values and see the effects on the transfer function. If testing on live audio, you may stream a loaded audio file and adjust the interface variables in real-time in order to hear the effects of the new settings.</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-not-stacked-on-mobile is-layout-flex wp-container-core-columns-is-layout-15 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"><a href="https://www.advsolned.com/asn_filter_designer/"><img decoding="async" src="https://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox.png" alt="ASN Filter Designer Box"/></a></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%">
<div class="wp-block-buttons is-vertical is-nowrap is-layout-flex wp-container-core-buttons-is-layout-6 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-nowrap is-layout-flex wp-container-core-buttons-is-layout-7 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/pricing-and-licencing/" style="color:#ffffff">Pricing Information</a></div>
</div>
</div>
</div>
		<div class="wpulike wpulike-default " ><div class="wp_ulike_general_class wp_ulike_is_not_liked"><button type="button"
					aria-label="Like Button"
					data-ulike-id="6010"
					data-ulike-nonce="747f806dca"
					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_6010"></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/allpass-peaking-bell-filter/">All-pass Peaking/Bell filter</a> appeared first on <a rel="nofollow" href="https://www.advsolned.com">ASN Home</a>.</p>
]]></content:encoded>
					
		
		<enclosure url="https://www.advsolned.com/wp-content/uploads/2018/07/peakingfilter.mp4" length="144644" type="video/mp4" />

			</item>
	</channel>
</rss>
