{"id":319,"date":"2016-09-29T01:12:36","date_gmt":"2016-09-29T08:12:36","guid":{"rendered":"http:\/\/www.earlevel.com\/main\/?p=319"},"modified":"2019-02-24T15:09:54","modified_gmt":"2019-02-24T23:09:54","slug":"cascading-filters","status":"publish","type":"post","link":"https:\/\/www.earlevel.com\/main\/2016\/09\/29\/cascading-filters\/","title":{"rendered":"Cascading filters"},"content":{"rendered":"<p>Sometimes we\u2019d like to cascade biquads to get\u00a0a higher filter order. This calculator gives the Q values for each filter to achieve Butterworth response for lowpass and highpass filters.<\/p>\n<p>Order: <select id=\"filter_order\" onchange=\"updateSplane();\"><option value=\"2\">2<\/option><option value=\"3\">3<\/option><option value=\"4\">4<\/option><option value=\"5\">5<\/option><option value=\"6\">6<\/option><option value=\"7\">7<\/option><option value=\"8\">8<\/option><option value=\"9\">9<\/option><option value=\"10\">10<\/option><option value=\"11\">11<\/option><option value=\"12\">12<\/option><option value=\"13\">13<\/option><option value=\"14\">14<\/option><option value=\"15\">15<\/option><option value=\"16\">16<\/option><option value=\"17\">17<\/option><option value=\"18\">18<\/option><option value=\"19\">19<\/option><option value=\"20\">20<\/option><\/select><br \/>\nQ values:<br \/>\n<textarea id=\"Qlist\" rows=\"10\" cols=\"16\" readonly=\"readonly\"><\/textarea><\/p>\n<p>You can calculate coefficients for all biquad (and one-pole) filters with the <a href=\"\/main\/2013\/10\/13\/biquad-calculator-v2\/\">biquad calculator<\/a>.<\/p>\n<h3>Motivation for cascading filters<\/h3>\n<p>Sometimes we\u2019d like a steeper cutoff than a biquad\u2014a second order filter\u2014gives us. We could design a higher order filter directly, but the direct forms suffer from numerical problems due to limited computational precision. So, we typically combine one- and two-pole (biquad) filters to get the order we need. The lower order filters are less sensitive to precision errors. And we maintain the same number of math operations and delay elements as the equivalent higher order filter, so think of cascading as simply rearranging the math.<\/p>\n<h3>Adjusting the corner<\/h3>\n<p>The main problem with cascading is that if you take two Buterworth filters in cascade, the result is no longer Butterworth. Consider a Butterworth\u2014maximally flat passband\u2014lowpass filter. At the defined corner frequency, the magnitude response is -3 dB. If you cascade two of these filter, the response is now -6 dB. We can\u2019t simply move the frequency up to compensate, since the slope into the corner is also not as sharp. Increasing the Q of both filters to sharpen the corner would degrade the passband\u2019s flatness. We need a combination of Q values to get the correct Butterworth response.<\/p>\n<h3>How to calculate Q values<\/h3>\n<p>The problem of figuring out what the Q should be for each stage of a biquad cascade becomes very simple if we look at the pole positions of the Butterworth filter we want to achieve in the s-plane. In the s-plane, the poles of a Butterworth filter are distributed evenly, at a constant radius from the origin and with a constant angular spacing. Since the radius corresponds to frequency, and the pole angle corresponds to Q, we know that all of the component filters should be set to the same frequency, and their Q is simple to calculate from the pole angles. For a given pole angle, <em>\u03b8<\/em>, Q is 1 \/ (2cos(<em>\u03b8<\/em>)).<\/p>\n<p>Calculating pole positions is easy: For a filter of order <i>n<\/i>, poles are spaced by an angle of \u03c0\/<em>n<\/em>. For an odd order, we\u2019ll have a one-pole filter on the real (horizontal) axis, and the remaining pole pairs spaced at the calculated angle. For even orders, the poles will be mirrored about the real axis, so the first pole pairs will start\u00a0at plus and minus half the calculated angle. The biquad poles are conjugate pairs, corresponding to a single biquad, so we need only pay attention to the positive half for Q values.<\/p>\n<h3>Examples<\/h3>\n<p>For a 2-pole filter, a single biquad, the poles are \u03c0\/2 radians apart, mirrored on both sides of the horizontal axis. So, our single Q value is based on the angle \u03c0\/4; 1\/(2cos(\u03c0\/4)) equals a Q value of 0.7071.<\/p>\n<p>For a 3-pole filter, the pole spacing angle is \u03c0\/3 radians. We start with a one-pole filter on the real (\u03c3) axis, so the biquad\u2019s pole angle is \u03c0\/3; 1\/(2cos(\u03c0\/3)) equals a Q of 1.0.<\/p>\n<p>For a 4-pole filter, we have two biquads, with poles spaced \u03c0\/4 radians apart, mirrored about the real axis. That means the first biquad\u2019s pole angle is \u03c0\/8, and the second is 3\u03c0\/8, yielding Q values of 0.541196 and 1.306563.<\/p>\n<p><a href=\"\/main\/wp-content\/uploads\/2016\/09\/s-plane-filters.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-329\" src=\"\/main\/wp-content\/uploads\/2016\/09\/s-plane-filters.png\" alt=\"s-plane-filters\" width=\"402\" height=\"342\" srcset=\"https:\/\/www.earlevel.com\/main\/wp-content\/uploads\/2016\/09\/s-plane-filters.png 402w, https:\/\/www.earlevel.com\/main\/wp-content\/uploads\/2016\/09\/s-plane-filters-300x255.png 300w\" sizes=\"(max-width: 402px) 100vw, 402px\" \/><\/a><br \/>\n<script type=\"text\/javascript\" src=\"\/scripts\/widgets\/20160929\/CombiningBiquads.js\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes we\u2019d like to cascade biquads to get\u00a0a higher filter order. This calculator gives the Q values for each filter to achieve Butterworth response for lowpass and highpass filters. Order: 234567891011121314151617181920 Q values: You can calculate coefficients for all biquad &hellip; <a href=\"https:\/\/www.earlevel.com\/main\/2016\/09\/29\/cascading-filters\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,8,9,30],"tags":[],"_links":{"self":[{"href":"https:\/\/www.earlevel.com\/main\/wp-json\/wp\/v2\/posts\/319"}],"collection":[{"href":"https:\/\/www.earlevel.com\/main\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.earlevel.com\/main\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.earlevel.com\/main\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.earlevel.com\/main\/wp-json\/wp\/v2\/comments?post=319"}],"version-history":[{"count":23,"href":"https:\/\/www.earlevel.com\/main\/wp-json\/wp\/v2\/posts\/319\/revisions"}],"predecessor-version":[{"id":835,"href":"https:\/\/www.earlevel.com\/main\/wp-json\/wp\/v2\/posts\/319\/revisions\/835"}],"wp:attachment":[{"href":"https:\/\/www.earlevel.com\/main\/wp-json\/wp\/v2\/media?parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.earlevel.com\/main\/wp-json\/wp\/v2\/categories?post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.earlevel.com\/main\/wp-json\/wp\/v2\/tags?post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}