<?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>50Hz mains interference &#8211; ASN Home</title>
	<atom:link href="https://www.advsolned.com/tag/50hz-mains-interference/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.advsolned.com</link>
	<description>ASN home site</description>
	<lastBuildDate>Mon, 10 Jul 2023 08:07:57 +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>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-1 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 fetchpriority="high" 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 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="(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 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="(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-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>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-3 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-2 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="ba2493111b"
					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>FIR Comb Filter: powerline harmonic cancellation and CIC</title>
		<link>https://www.advsolned.com/fir-comb-filter/</link>
					<comments>https://www.advsolned.com/fir-comb-filter/#respond</comments>
		
		<dc:creator><![CDATA[ASN consultancy team]]></dc:creator>
		<pubDate>Wed, 04 Jul 2018 14:18:48 +0000</pubDate>
				<category><![CDATA[ASN FilterScript]]></category>
		<category><![CDATA[50Hz mains interference]]></category>
		<category><![CDATA[50Hz powerline]]></category>
		<category><![CDATA[60Hz powerline]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[CIC]]></category>
		<category><![CDATA[comb]]></category>
		<category><![CDATA[FIR]]></category>
		<category><![CDATA[harmonics]]></category>
		<guid isPermaLink="false">http://www.advsolned.com/?p=5990</guid>

					<description><![CDATA[<p>Comb filters: powerline (50/60Hz) harmonic cancellation filters, audio applications; cascaded integrator–comb (CIC) filters: anti-aliasing, anti-imaging</p>
<p>The post <a rel="nofollow" href="https://www.advsolned.com/fir-comb-filter/">FIR Comb Filter: powerline harmonic cancellation and CIC</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"  >FIR Comb Filter: powerline harmonic cancellation and CIC</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>Comb filters have found use as powerline (50/60Hz) harmonic cancellation filters in audio applications, and form the basis of so called CIC (cascaded integrator–comb) filters used for anti-aliasing in decimation (sample rate reduction), and anti-imaging in interpolation (sample rate increase) applications.</p>
<p style="text-align: left;">The frequency response of a comb filter consists of a series of regularly-spaced troughs, giving the appearance of a comb. As seen in the plot below, the spacing of each trough appears at either odd or even harmonics of the desired fundamental frequency.</p>
<p style="text-align: center;"><a href="http://www.advsolned.com/wp-content/uploads/2018/07/fircomb.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-5991" src="http://www.advsolned.com/wp-content/uploads/2018/07/fircomb.png" alt="Comb filters have found use as powerline (50/60Hz) harmonic cancellation filters in audio applications, and form the basis of so called CIC (cascaded integrator–comb) filters used for anti-aliasing in decimation (sample rate reduction), and anti-imaging in interpolation (sample rate increase) application" width="453" height="536" srcset="https://www.advsolned.com/wp-content/uploads/2018/07/fircomb.png 464w, https://www.advsolned.com/wp-content/uploads/2018/07/fircomb-254x300.png 254w, https://www.advsolned.com/wp-content/uploads/2018/07/fircomb-450x532.png 450w" sizes="auto, (max-width: 453px) 100vw, 453px" /></a><em>Frequency response of a typical FIR comb filter (odd harmonics cancellation):<br />
</em><em>\(f_s=500Hz\),  \(f_c=25Hz\), \(L=10\) and \(\alpha=1\)<br />
</em></p>
<p style="text-align: left;"><span class="" style="display:block;clear:both;height: 0px;padding-top: 25px;border-top-width:0px;border-bottom-width:0px;"></span>An FIR comb filter can be described by the following transfer function:</p>
<p style="text-align: center;">\(H(z)=1+\alpha z^{-L}\)<span class="" style="display:block;clear:both;height: 0px;padding-top: 2px;border-top-width:0px;border-bottom-width:0px;"></span><br />
\(\Rightarrow Y(z)=X(z)\left[1+\alpha z^{-L}\right]\)</p>
<p style="text-align: left;">Clearly, the comb filter is simply a weighted delayed replica of itself, specifiied by \(L\). Taking inverse z-transforms, we obtain the difference equation needed for implementation,</p>
<p style="text-align: center;">\(y(n)=x(n)+\alpha x(n-L)\)</p>
<p>where, \(\alpha\) is used to set the Q (bandwidth) of the notch and may be either positive or negative depending on what type of frequency response is required. In order to elaborate on this, negative values of \(\alpha\) have their first trough at DC and their second trough at the fundamental frequency. Clearly this type of comb filter can be used to remove any DC components from a measured waveform if so required. All subsequent troughs appear at even harmonics up to and including the Nyquist frequency.</p>
<p>Positive values of \(\alpha\) on the other hand, only have troughs at the fundamental and odd harmonic frequencies, and as such cannot be used to remove any DC components.</p>
<h2>Application to powerline interference cancellation</h2>
<p>The affectivity of the comb filter is dependent on the sampling frequency, \(f_s\), as \(L\) is limited to integer values only. Also, a relationship between \(f_s\), as \(L\) and will be dependent on the sign of \(\alpha\). Thus, for the purposes of the mains cancellation application considered in this discussion, only positive values of will be considered, as we need only cancel odd harmonics.</p>
<p>A simple relationship for determining  \(L\) can be summarized for positive values of \(\alpha\) as follows:</p>
<p style="text-align: center;">\(L=ceil\left( \large{\frac{f_s}{2f_c}}\right)\)</p>
<p>where, \(f_c\) is the desired centre point of the fundamental notch frequency. Based on this expression, we can re-calculate the sampling frequency, such that \(f_c\) is a true multiple of \(f_s\)</p>
<p style="text-align: center;">\(f_{snew}=2f_c L\)</p>
<h2>Example of a comb filter</h2>
<p>For the example considered herein, i.e. \(f_s=500Hz\) and \(f_c=25Hz\), we obtain \(L=10\). However, if \(f_c=60Hz\), we would need \(L=5\), and a new sampling rate of \(600Hz\) respectively, although it&#8217;s interesting to note that \(f_s=480Hz\) for \(L=4\) would also suffice.</p>
<span class="" style="display:block;clear:both;height: 0px;padding-top: 20px;border-top-width:0px;border-bottom-width:0px;"></span>
<h2>Implementation</h2>
<p>An FIR comb 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<br />
interface L = {4,20,1,5}; // delay<br />
interface alpha = {-1,1,0.01,1};</p>
<p>Main()<br />
Num = {1,zeros(L-1),alpha}; // numerator coefficients<br />
Den = {1};<br />
Gain = 1/sum(abs(Num));<br />
[/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="http://www.advsolned.com/wp-content/uploads/2018/02/ASNFDbox.png"><img loading="lazy" decoding="async" class="alignleft wp-image-3310" style="margin: 10px 80px 10px 20px;" src="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>
<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></section>
</div></div></div><!-- close content main div --></div></div><div id='av_section_1' class='avia-section main_color avia-section-default avia-no-border-styling avia-bg-style-scroll   container_wrap sidebar_right' style=' '  ><div class='container' ><div class='template-page content  av-content-small alpha units'><div class='post-entry post-entry-type-page post-entry-5990'><div class='entry-content-wrapper clearfix'></div></div></div><!-- close content main div --></div></div><div id='after_section_1' class='main_color av_default_container_wrap container_wrap sidebar_right' style=' '  ><div class='container' ><div class='template-page content  av-content-small alpha units'><div class='post-entry post-entry-type-page post-entry-5990'><div class='entry-content-wrapper clearfix'>
</div></div></div><!-- close content main div --></div></div><div id='av_section_2' class='avia-section main_color avia-section-default avia-no-border-styling avia-bg-style-scroll   container_wrap sidebar_right' style=' '  ><div class='container' ><div class='template-page content  av-content-small alpha units'><div class='post-entry post-entry-type-page post-entry-5990'><div class='entry-content-wrapper clearfix'></div></div></div><!-- close content main div --></div></div><div id='after_section_2' class='main_color av_default_container_wrap container_wrap sidebar_right' style=' '  ><div class='container' ><div class='template-page content  av-content-small alpha units'><div class='post-entry post-entry-type-page post-entry-5990'><div class='entry-content-wrapper clearfix'>
		<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="5990"
					data-ulike-nonce="f04d83cdb2"
					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_5990"></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/fir-comb-filter/">FIR Comb Filter: powerline harmonic cancellation and CIC</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-comb-filter/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
