ra3xdh / qucs_s

Qucs-S is a circuit simulation program with Qt-based GUI
https://ra3xdh.github.io/
GNU General Public License v2.0
840 stars 108 forks source link

Potential error in cauer band(pass|stop) center frequency calculation #716

Open jcolafrancesco opened 4 months ago

jcolafrancesco commented 4 months ago

Context:

  1. For bandpass and bandstop filters, the qucsfilter interface is taking as input low and high corner frequencies
  2. The qf_cauer filter is, on its end, taking as input an alternative representation: bandwidth and center frequency.
  3. In the code, the conversion is done this way: https://github.com/ra3xdh/qucs_s/blob/f9b3441de7d42151d9c004cb7f5de466d5422183/qucs-filter/qucsfilter.cpp#L426C1-L426C73

Issue: Basically, the center frequency is computed as the arithmetic mean between the two corner frequencies, although I really though we shall use the geometric mean here.

Looking at the transfer function of a generated filter, we can see a slight shift in frequency (1GHz to 2GHz band-pass):

Screenshot from 2024-05-10 11-55-06

With a small patch implementing a geometric mean, I obtain the following results:

Screenshot from 2024-05-10 11-54-16

This looks much more satisfying.

I'll prepare a pull request, but in the meantime, I'd be happy to have some confirmation by an RF expert.

tomhajjar commented 4 months ago

It's always best if a tool uses the same definition for variables for all choices.

As I stated before about this tool, in real life, you can't buy components with the values calculated by the tool. Also component "Q" and package parasitics isn't taken into account so the analysis will be flawed. The higher the frequency and narrower the bandwidth, the more the measured results will deviate.

The only way to have accurate simulations is to measure every component on a LCR meter capable of measuring at the actual filter frequency. Components must be measured using a jig replicating the PCB or circuit parasitics. Measured component data is then used to update the schematic. Manufacturers data is always suspect.

Attached is a filter I designed decades ago for an Intelsat satellite receiver. 70MHz BPF with amplitude and group delay equalization.

Intelsat 70MHz BPF

ra3xdh commented 3 months ago

I am unsure what source was used for Qucs-filter tool design. The Handbuch zum Filterentwurf by R.Saal recommends to use geometric mean for the center frequency of the band pass filter. You can find some notes in the Qucs technical manual section 14.2 https://qucs.sourceforge.net/docs/technical/technical.pdf