From 428970eb1386fba2c4cae6c81f120daeb87602ef Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 7 Nov 2021 17:07:50 -0800 Subject: [PATCH] PCB_Calculator: Fix coupled microstrip diff Z bffff6c1bf was well-meaning but mistook Zodd for Zsingle. 2*Zodd is the appropriate value for differential impedance --- .../panel_transline_base.cpp | 25 +-- .../panel_transline_base.fbp | 146 +----------------- .../calculator_panels/panel_transline_base.h | 5 +- pcb_calculator/transline/c_microstrip.cpp | 10 +- pcb_calculator/transline_dlg_funct.cpp | 1 - 5 files changed, 12 insertions(+), 175 deletions(-) diff --git a/pcb_calculator/calculator_panels/panel_transline_base.cpp b/pcb_calculator/calculator_panels/panel_transline_base.cpp index cd821fdeb3..9ba1d0955a 100644 --- a/pcb_calculator/calculator_panels/panel_transline_base.cpp +++ b/pcb_calculator/calculator_panels/panel_transline_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) +// C++ code generated with wxFormBuilder (version 3.10.0) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -22,7 +22,7 @@ PANEL_TRANSLINE_BASE::PANEL_TRANSLINE_BASE( wxWindow* parent, wxWindowID id, con wxString m_TranslineSelectionChoices[] = { _("Microstrip Line"), _("Coplanar wave guide"), _("Coplanar wave guide w/ ground plane"), _("Rectangular Waveguide"), _("Coaxial Line"), _("Coupled Microstrip Line"), _("Stripline"), _("Twisted Pair") }; int m_TranslineSelectionNChoices = sizeof( m_TranslineSelectionChoices ) / sizeof( wxString ); m_TranslineSelection = new wxRadioBox( this, wxID_ANY, _("Transmission Line Type"), wxDefaultPosition, wxDefaultSize, m_TranslineSelectionNChoices, m_TranslineSelectionChoices, 1, wxRA_SPECIFY_COLS ); - m_TranslineSelection->SetSelection( 2 ); + m_TranslineSelection->SetSelection( 0 ); bLeftSizer->Add( m_TranslineSelection, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 5 ); @@ -216,27 +216,6 @@ PANEL_TRANSLINE_BASE::PANEL_TRANSLINE_BASE( wxWindow* parent, wxWindowID id, con m_bmCMicrostripZoddZeven = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); bSizerHelpBitmaps->Add( m_bmCMicrostripZoddZeven, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 10 ); - m_fgSizerZcomment = new wxFlexGridSizer( 0, 2, 0, 15 ); - m_fgSizerZcomment->AddGrowableCol( 0 ); - m_fgSizerZcomment->AddGrowableCol( 1 ); - m_fgSizerZcomment->SetFlexibleDirection( wxBOTH ); - m_fgSizerZcomment->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_staticTextZdiff = new wxStaticText( this, wxID_ANY, _("Zdiff =\n2*Z0( (1 - 0.48exp( -0.96*S/H ) )"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextZdiff->Wrap( -1 ); - m_staticTextZdiff->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); - - m_fgSizerZcomment->Add( m_staticTextZdiff, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - m_staticTextZcommon = new wxStaticText( this, wxID_ANY, _("Zcommon = Zeven / 2"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL ); - m_staticTextZcommon->Wrap( -1 ); - m_staticTextZcommon->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); - - m_fgSizerZcomment->Add( m_staticTextZcommon, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); - - - bSizerHelpBitmaps->Add( m_fgSizerZcomment, 0, wxEXPAND, 5 ); - bMiddleSizer->Add( bSizerHelpBitmaps, 1, wxALIGN_CENTER_HORIZONTAL, 5 ); diff --git a/pcb_calculator/calculator_panels/panel_transline_base.fbp b/pcb_calculator/calculator_panels/panel_transline_base.fbp index 47b275ce40..bc7b6cfc66 100644 --- a/pcb_calculator/calculator_panels/panel_transline_base.fbp +++ b/pcb_calculator/calculator_panels/panel_transline_base.fbp @@ -116,7 +116,7 @@ 1 Resizable - 2 + 0 1 wxRA_SPECIFY_COLS @@ -2038,11 +2038,11 @@ - + 5 wxEXPAND|wxTOP 0 - + wxID_ANY Component Parameters @@ -2326,146 +2326,6 @@ - - 5 - wxEXPAND - 0 - - 2 - wxBOTH - 0,1 - - 15 - - m_fgSizerZcomment - wxFLEX_GROWMODE_SPECIFIED - protected - 0 - 0 - - 5 - wxALL|wxALIGN_CENTER_HORIZONTAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,93,92,-1,70,0 - 0 - 0 - wxID_ANY - Zdiff = 2*Z0( (1 - 0.48exp( -0.96*S/H ) ) - 0 - - 0 - - - 0 - - 1 - m_staticTextZdiff - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_HORIZONTAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,93,92,-1,70,0 - 0 - 0 - wxID_ANY - Zcommon = Zeven / 2 - 0 - - 0 - - - 0 - - 1 - m_staticTextZcommon - 1 - - - protected - 1 - - Resizable - 1 - - wxALIGN_CENTER_HORIZONTAL - - 0 - - - - - -1 - - - - diff --git a/pcb_calculator/calculator_panels/panel_transline_base.h b/pcb_calculator/calculator_panels/panel_transline_base.h index cbae05b6df..1ddc7f2331 100644 --- a/pcb_calculator/calculator_panels/panel_transline_base.h +++ b/pcb_calculator/calculator_panels/panel_transline_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) +// C++ code generated with wxFormBuilder (version 3.10.0) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -80,9 +80,6 @@ class PANEL_TRANSLINE_BASE : public CALCULATOR_PANEL wxTextCtrl* m_Value_Frequency_Ctrl; UNIT_SELECTOR_FREQUENCY* m_choiceUnit_Frequency; wxStaticBitmap* m_bmCMicrostripZoddZeven; - wxFlexGridSizer* m_fgSizerZcomment; - wxStaticText* m_staticTextZdiff; - wxStaticText* m_staticTextZcommon; wxStaticText* m_phys_prm1_label; wxTextCtrl* m_Phys_prm1_Value; UNIT_SELECTOR_LEN* m_choiceUnit_Param1; diff --git a/pcb_calculator/transline/c_microstrip.cpp b/pcb_calculator/transline/c_microstrip.cpp index 1189cdfeff..fcde0e9018 100644 --- a/pcb_calculator/transline/c_microstrip.cpp +++ b/pcb_calculator/transline/c_microstrip.cpp @@ -583,12 +583,14 @@ void C_MICROSTRIP::line_angle() } -/* -* diff_impedance() - calculate differential impedance -*/ +/** + * Note that differential impedance is exactly twice the odd mode impedance. + * Odd mode is not the same as single-ended impedance, so avoid approximations found + * on websites that use static single ended impedance as the starting point + */ void C_MICROSTRIP::diff_impedance() { - Zdiff = 2*Z0_o_0*(1 - 0.48*exp(-0.96*(m_parameters[PHYS_S_PRM] /m_parameters[H_PRM]))); + Zdiff = 2 * Z0_o_0; } diff --git a/pcb_calculator/transline_dlg_funct.cpp b/pcb_calculator/transline_dlg_funct.cpp index 7190fd6922..c03fb71856 100644 --- a/pcb_calculator/transline_dlg_funct.cpp +++ b/pcb_calculator/transline_dlg_funct.cpp @@ -187,7 +187,6 @@ void PANEL_TRANSLINE::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType ) // This helper bitmap is shown for coupled microstrip only: m_bmCMicrostripZoddZeven->Show( aType == C_MICROSTRIP_TYPE ); m_bmCMicrostripZoddZeven->SetBitmap( KiBitmap( BITMAPS::microstrip_zodd_zeven ) ); - m_fgSizerZcomment->Show( aType == C_MICROSTRIP_TYPE ); TRANSLINE_IDENT* tr_ident = m_transline_list[m_currTransLineType]; m_currTransLine = tr_ident->m_TLine;