KiCad PCB EDA Suite
transline_ident.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2011-2014 Jean-Pierre Charras
5 * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
24#include <wx/intl.h>
25#include <wx/arrstr.h>
26
27#include <kiface_base.h>
28#include <bitmaps.h>
29
30// transline specific functions:
31#include "transline/transline.h"
33#include "transline/coplanar.h"
35#include "transline/coax.h"
37#include "transline/stripline.h"
39
42#include "transline_ident.h"
43
44
45TRANSLINE_PRM::TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, const char* aKeywordCfg,
46 const wxString& aDlgLabel, const wxString& aToolTip,
47 double aValue, bool aConvUnit )
48{
49 m_Type = aType;
50 m_Id = aId;
51 m_DlgLabel = aDlgLabel;
52 m_KeyWord = aKeywordCfg;
53 m_ToolTip = aToolTip;
54 m_Value = aValue;
55 m_ConvUnit = aConvUnit;
56 m_ValueCtrl = nullptr;
57 m_UnitCtrl = nullptr;
60 }
61
62
64{
65 if( m_UnitCtrl && m_ConvUnit )
66 return 1.0 / ( (UNIT_SELECTOR*) m_UnitCtrl )->GetUnitScale();
67 else
68 return 1.0;
69}
70
71
73{
74 if( m_UnitCtrl )
75 return ( (UNIT_SELECTOR*) m_UnitCtrl )->GetUnitScale();
76 else
77 return 1.0;
78}
79
80
82{
83 m_Type = aType; // The type of transline handled
84 m_BitmapName = BITMAPS::INVALID_BITMAP; // The icon to display
85 m_TLine = nullptr; // The TRANSLINE itself
86 m_HasPrmSelection = false; // true if selection of parameters must be enabled in dialog menu
87
88 // Add common prms:
89 // Default values are for FR4
91 "Er", wxT( "εr" ),
92 _( "Substrate relative permittivity (dielectric constant)" ),
93 4.6, false ) );
95 "TanD", wxT( "tan δ" ),
96 _( "Dielectric loss (dissipation factor)" ),
97 2e-2, false ) );
98
99 // Default value is for copper
101 "Rho", wxT( "ρ" ),
102 _( "Electrical resistivity or specific electrical resistance of "
103 "conductor (ohm*meter)" ),
104 1.72e-8, false ) );
105
106 // Default value is in GHz
108 "Frequency", _( "Frequency" ),
109 _( "Frequency of the input signal" ), 1.0, true ) );
110
111
112 switch( m_Type )
113 {
114 case MICROSTRIP_TYPE: // microstrip
115 m_TLine = new MICROSTRIP();
117
118 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
119 m_Messages.Add( _( "Conductor losses:" ) );
120 m_Messages.Add( _( "Dielectric losses:" ) );
121 m_Messages.Add( _( "Skin depth:" ) );
122
124 "H", "H", _( "Height of substrate" ), 0.2, true ) );
126 "H_t", "H(top)", _( "Height of box top" ), 1e20, true ) );
128 "T", "T",
129 _( "Strip thickness" ), 0.035, true ) );
131 "Rough", _( "Roughness" ),
132 _( "Conductor roughness" ), 0.0, true ) );
134 "mu Rel S", wxString::Format( wxT( "μ(%s)" ),
135 _( "substrate" ) ),
136 _( "Relative permeability (mu) of substrate" ), 1, false ) );
138 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
139 _( "conductor" ) ),
140 _( "Relative permeability (mu) of conductor" ), 1,
141 false ) );
142
144 "W", "W", _( "Line width" ), 0.2, true ) );
146 "L", "L", _( "Line length" ), 50.0, true ) );
147
149 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
152 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
153 break;
154
155 case CPW_TYPE: // coplanar waveguide
156 m_TLine = new COPLANAR();
158 m_HasPrmSelection = true;
159
160 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
161 m_Messages.Add( _( "Conductor losses:" ) );
162 m_Messages.Add( _( "Dielectric losses:" ) );
163 m_Messages.Add( _( "Skin depth:" ) );
164
166 "H", "H", _( "Height of substrate" ), 0.2, true ) );
168 "T", "T", _( "Strip thickness" ), 0.035, true ) );
170 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
171 _( "conductor" ) ),
172 _( "Relative permeability (mu) of conductor" ), 1,
173 false ) );
174
176 "W", "W", _( "Line width" ), 0.2, true ) );
178 "S", "S", _( "Gap width" ), 0.2, true ) );
180 "L", "L", _( "Line length" ), 50.0, true ) );
181
183 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
186 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
187 break;
188
189 case GROUNDED_CPW_TYPE: // grounded coplanar waveguide
192 m_HasPrmSelection = true;
193
194 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
195 m_Messages.Add( _( "Conductor losses:" ) );
196 m_Messages.Add( _( "Dielectric losses:" ) );
197 m_Messages.Add( _( "Skin depth:" ) );
198
200 "H", "H", _( "Height of substrate" ), 0.2, true ) );
202 "T", "T", _( "Strip thickness" ), 0.035, true ) );
204 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
205 _( "conductor" ) ),
206 _( "Relative permeability (mu) of conductor" ), 1,
207 false ) );
208
210 "W", "W", _( "Line width" ), 0.2, true ) );
212 "S", "S", _( "Gap width" ), 0.2, true ) );
214 "L", "L", _( "Line length" ), 50.0, true ) );
215
217 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
220 "Ang_l", "Ang_l", _( "Electrical length" ), 0, true ) );
221 break;
222
223
224 case RECTWAVEGUIDE_TYPE: // rectangular waveguide
225 m_TLine = new RECTWAVEGUIDE();
227 m_HasPrmSelection = true;
228
229 m_Messages.Add( _( "ZF(H10) = Ey / Hx:" ) );
230 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
231 m_Messages.Add( _( "Conductor losses:" ) );
232 m_Messages.Add( _( "Dielectric losses:" ) );
233 m_Messages.Add( _( "TE-modes:" ) );
234 m_Messages.Add( _( "TM-modes:" ) );
235
237 "mu Rel I", wxString::Format( wxT( "μ(%s)" ),
238 _( "insulator" ) ),
239 _( "Relative permeability (mu) of insulator" ), 1, false ) );
241 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
242 _( "conductor" ) ),
243 _( "Relative permeability (mu) of conductor" ), 1,
244 false ) );
245
247 "a", "a", _( "Width of waveguide" ), 10.0, true ) );
249 "b", "b", _( "Height of waveguide" ), 5.0, true ) );
251 "L", "L", _( "Waveguide length" ), 50.0, true ) );
252
254 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
257 "Ang_l", "Ang_l", _( "Electrical length" ), 0, true ) );
258 break;
259
260 case COAX_TYPE: // coaxial cable
261 m_TLine = new COAX();
263 m_HasPrmSelection = true;
264
265 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
266 m_Messages.Add( _( "Conductor losses:" ) );
267 m_Messages.Add( _( "Dielectric losses:" ) );
268 m_Messages.Add( _( "TE-modes:" ) );
269 m_Messages.Add( _( "TM-modes:" ) );
270
272 "mu Rel I", wxString::Format( wxT( "μ(%s)" ),
273 _( "insulator" ) ),
274 _( "Relative permeability (mu) of insulator" ), 1, false ) );
276 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
277 _( "conductor" ) ),
278 _( "Relative permeability (mu) of conductor" ), 1,
279 false ) );
280
282 "Din", _( "Din" ),
283 _( "Inner diameter (conductor)" ), 1.0, true ) );
285 "Dout", _( "Dout" ),
286 _( "Outer diameter (insulator)" ), 8.0, true ) );
288 "L", "L", _( "Line length" ), 50.0, true ) );
289
291 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
294 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
295 break;
296
297 case C_MICROSTRIP_TYPE: // coupled microstrip
298 m_TLine = new C_MICROSTRIP();
300 m_HasPrmSelection = true;
301
302 m_Messages.Add( wxString::Format( _( "Effective %s (even):" ), wxT( "εr" ) ) );
303 m_Messages.Add( wxString::Format( _( "Effective %s (odd):" ), wxT( "εr" ) ) );
304 m_Messages.Add( _( "Conductor losses (even):" ) );
305 m_Messages.Add( _( "Conductor losses (odd):" ) );
306 m_Messages.Add( _( "Dielectric losses (even):" ) );
307 m_Messages.Add( _( "Dielectric losses (odd):" ) );
308 m_Messages.Add( _( "Skin depth:" ) );
309 m_Messages.Add( _( "Differential Impedance (Zd):" ) );
310
312 "H", "H", _( "Height of substrate" ), 0.2, true ) );
314 "H_t", "H_t", _( "Height of box top" ), 1e20, true ) );
316 "T", "T", _( "Strip thickness" ), 0.035, true ) );
318 "Rough", _( "Roughness" ),
319 _( "Conductor roughness" ), 0.0, true ) );
321 "mu rel C", wxString::Format( wxT( "μ(%s)" ),
322 _( "conductor" ) ),
323 _( "Relative permeability (mu) of conductor" ), 1,
324 false ) );
325
327 "W", "W", _( "Line width" ), 0.2, true ) );
329 "S", "S", _( "Gap width" ), 0.2, true ) );
331 "L", "L", _( "Line length" ), 50.0, true ) );
332
334 "Zeven", _( "Zeven" ),
335 _( "Even mode impedance (lines driven by common voltages)" ),
336 50.0, true ) );
338 "Zodd", _( "Zodd" ),
339 _( "Odd mode impedance (lines driven by opposite "
340 "(differential) voltages)" ), 50.0, true ) );
342 "Ang_l", "Ang_l",
343 _( "Electrical length" ), 0.0, true ) );
344 break;
345
346 case STRIPLINE_TYPE: // stripline
347 m_TLine = new STRIPLINE();
349
350 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
351 m_Messages.Add( _( "Conductor losses:" ) );
352 m_Messages.Add( _( "Dielectric losses:" ) );
353 m_Messages.Add( _( "Skin depth:" ) );
354
356 "H", "H", _( "Height of substrate" ), 0.2, true ) );
358 "a", "a", _( "Distance between strip and top metal" ), 0.2,
359 true ) );
361 "T", "T", _( "Strip thickness" ), 0.035, true ) );
363 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
364 _( "conductor" ) ),
365 _( "Relative permeability (mu) of conductor" ), 1, false ) );
366
368 "W", "W", _( "Line width" ), 0.2, true ) );
370 "L", "L", _( "Line length" ), 50.0, true ) );
371
373 "Z0", "Z0", _( "Characteristic impedance" ), 50, true ) );
376 "Ang_l", "Ang_l", _( "Electrical length" ), 0, true ) );
377 break;
378
379 case TWISTEDPAIR_TYPE: // twisted pair
380 m_TLine = new TWISTEDPAIR();
382 m_HasPrmSelection = true;
383
384 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
385 m_Messages.Add( _( "Conductor losses:" ) );
386 m_Messages.Add( _( "Dielectric losses:" ) );
387 m_Messages.Add( _( "Skin depth:" ) );
388
390 "Twists", _( "Twists" ),
391 _( "Number of twists per length" ), 0.0, false ) );
393 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
394 _( "conductor" ) ),
395 _( "Relative permeability (mu) of conductor" ), 1,
396 false ) );
398 "ErEnv", wxString::Format( wxT( "εr(%s)" ),
399 _( "environment" ) ),
400 _( "Relative permittivity of environment" ), 1,
401 false ) );
403 "Din", _( "Din" ),
404 _( "Inner diameter (conductor)" ), 1.0, true ) );
406 "Dout", _( "Dout" ),
407 _( "Outer diameter (insulator)" ), 8.0, true ) );
409 "L", "L", _( "Cable length" ), 50.0, true ) );
410
412 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
415 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
416 break;
417
418 case END_OF_LIST_TYPE: // Not really used
419 break;
420 }
421}
422
424{
425 delete m_TLine;
426
427 for( auto& ii : m_prms_List )
428 delete ii;
429
430 m_prms_List.clear();
431}
432
433
435{
436 auto cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( Kiface().KifaceSettings() );
437 std::string name( m_TLine->m_Name );
438
439 if( cfg->m_TransLine.param_values.count( name ) )
440 {
441 wxASSERT( cfg->m_TransLine.param_units.count( name ) );
442
443 for( auto& p : m_prms_List )
444 {
445 try
446 {
447 p->m_Value = cfg->m_TransLine.param_values.at( name ).at( p->m_KeyWord );
448 p->m_UnitSelection = cfg->m_TransLine.param_units.at( name ).at( p->m_KeyWord );
449 }
450 catch( ... )
451 {}
452 }
453 }
454}
455
456
458{
459 auto cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( Kiface().KifaceSettings() );
460 std::string name( m_TLine->m_Name );
461
462 for( auto& param : m_prms_List )
463 {
464 if( !std::isfinite( param->m_Value ) )
465 param->m_Value = 0;
466
467 cfg->m_TransLine.param_values[ name ][ param->m_KeyWord ] = param->m_Value;
468 cfg->m_TransLine.param_units[ name ][ param->m_KeyWord ] = param->m_UnitSelection;
469 }
470}
471
const char * name
Definition: DXF_plotter.cpp:56
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
@ c_microstrip
@ INVALID_BITMAP
@ rectwaveguide
Definition: coax.h:31
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:93
TRANSLINE * m_TLine
enum TRANSLINE_TYPE_ID m_Type
void AddPrm(TRANSLINE_PRM *aParam)
TRANSLINE_IDENT(enum TRANSLINE_TYPE_ID aType)
wxArrayString m_Messages
std::vector< TRANSLINE_PRM * > m_prms_List
A class to handle one parameter of transline.
TRANSLINE_PRM(PRM_TYPE aType, PRMS_ID aId, const char *aKeywordCfg="", const wxString &aDlgLabel=wxEmptyString, const wxString &aToolTip=wxEmptyString, double aValue=0.0, bool aConvUnit=false)
double m_NormalizedValue
wxString m_ToolTip
wxString m_DlgLabel
std::string m_KeyWord
double FromUserUnit()
const char * m_Name
Definition: transline.h:84
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
PRMS_ID
Definition: transline.h:37
@ TWISTEDPAIR_EPSILONR_ENV_PRM
Definition: transline.h:49
@ Z0_O_PRM
Definition: transline.h:54
@ FREQUENCY_PRM
Definition: transline.h:51
@ DUMMY_PRM
Definition: transline.h:61
@ RHO_PRM
Definition: transline.h:41
@ PHYS_DIAM_OUT_PRM
Definition: transline.h:59
@ T_PRM
Definition: transline.h:46
@ Z0_E_PRM
Definition: transline.h:53
@ MURC_PRM
Definition: transline.h:50
@ MUR_PRM
Definition: transline.h:48
@ STRIPLINE_A_PRM
Definition: transline.h:45
@ Z0_PRM
Definition: transline.h:52
@ TAND_PRM
Definition: transline.h:40
@ PHYS_LEN_PRM
Definition: transline.h:60
@ ANG_L_PRM
Definition: transline.h:55
@ H_T_PRM
Definition: transline.h:44
@ TWISTEDPAIR_TWIST_PRM
Definition: transline.h:43
@ PHYS_DIAM_IN_PRM
Definition: transline.h:57
@ ROUGH_PRM
Definition: transline.h:47
@ EPSILONR_PRM
Definition: transline.h:39
@ PHYS_S_PRM
Definition: transline.h:58
@ H_PRM
Definition: transline.h:42
@ PHYS_WIDTH_PRM
Definition: transline.h:56
PRM_TYPE
@ PRM_TYPE_FREQUENCY
@ PRM_TYPE_SUBS
@ PRM_TYPE_ELEC
@ PRM_TYPE_PHYS
TRANSLINE_TYPE_ID
@ RECTWAVEGUIDE_TYPE
@ MICROSTRIP_TYPE
@ CPW_TYPE
@ GROUNDED_CPW_TYPE
@ C_MICROSTRIP_TYPE
@ COAX_TYPE
@ TWISTEDPAIR_TYPE
@ END_OF_LIST_TYPE
@ STRIPLINE_TYPE