KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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"
40
43#include "transline_ident.h"
45#include <properties/property.h>
46
47
48TRANSLINE_PRM::TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, const char* aKeywordCfg, const wxString& aDlgLabel,
49 const wxString& aToolTip, double aValue, bool aConvUnit, int aDefaultUnit )
50{
51 m_Type = aType;
52 m_Id = aId;
53 m_DlgLabel = aDlgLabel;
54 m_KeyWord = aKeywordCfg;
55 m_ToolTip = aToolTip;
56 m_Value = aValue;
57 m_DefaultValue = aValue;
58 m_DefaultUnit = aDefaultUnit;
59 m_ConvUnit = aConvUnit;
60 m_ValueCtrl = nullptr;
61 m_UnitCtrl = nullptr;
64 }
65
66
68{
69 if( m_UnitCtrl && m_ConvUnit )
70 return 1.0 / ( (UNIT_SELECTOR*) m_UnitCtrl )->GetUnitScale();
71 else
72 return 1.0;
73}
74
75
77{
78 if( m_UnitCtrl )
79 return ( (UNIT_SELECTOR*) m_UnitCtrl )->GetUnitScale();
80 else
81 return 1.0;
82}
83
84
86{
87 m_Type = aType; // The type of transline handled
88 m_BitmapName = BITMAPS::INVALID_BITMAP; // The icon to display
89 m_TLine = nullptr; // The TRANSLINE itself
90 m_HasPrmSelection = false; // true if selection of parameters must be enabled in dialog menu
91
92 // Add common prms:
93 // Default values are for FR4
95 "Er", wxT( "εr" ),
96 _( "Substrate relative permittivity (dielectric constant)" ),
97 4.5, false ) );
99 "TanD", wxT( "tan δ" ),
100 _( "Dielectric loss (dissipation factor)" ),
101 2e-2, false ) );
102
103 // Default value is for copper
105 "Rho", wxT( "ρ" ),
106 _( "Electrical resistivity or specific electrical resistance of "
107 "conductor (ohm*meter)" ),
108 1.72e-8, false ) );
109
110 // Default value is in GHz
112 "Frequency", _( "Frequency" ),
113 _( "Frequency of the input signal" ), 1.0, true ) );
114
115
116 switch( m_Type )
117 {
118 case MICROSTRIP_TYPE: // microstrip
119 m_TLine = new MICROSTRIP_UI();
121
122 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
123 m_Messages.Add( _( "Unit propagation delay:" ) );
124 m_Messages.Add( _( "Conductor losses:" ) );
125 m_Messages.Add( _( "Dielectric losses:" ) );
126 m_Messages.Add( _( "Skin depth:" ) );
127
129 "H", "H", _( "Height of substrate" ), 0.2, true ) );
131 "H_t", "H(top)", _( "Height of box top" ), 1e20, true ) );
133 "T", "T",
134 _( "Strip thickness" ), 0.035, true ) );
136 "Rough", _( "Roughness" ),
137 _( "Conductor roughness" ), 0.0, true ) );
139 "mu Rel S", wxString::Format( wxT( "μr (%s)" ),
140 _( "substrate" ) ),
141 _( "Relative permeability (mu) of substrate" ), 1, false ) );
143 "mu Rel C", wxString::Format( wxT( "μr (%s)" ),
144 _( "conductor" ) ),
145 _( "Relative permeability (mu) of conductor" ), 1,
146 false ) );
147
149 "W", "W", _( "Line width" ), 0.2, true ) );
151 "L", "L", _( "Line length" ), 50.0, true ) );
152
154 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
157 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
158 break;
159
160 case CPW_TYPE: // coplanar waveguide
161 m_TLine = new COPLANAR();
163 m_HasPrmSelection = true;
164
165 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
166 m_Messages.Add( _( "Unit propagation delay:" ) );
167 m_Messages.Add( _( "Conductor losses:" ) );
168 m_Messages.Add( _( "Dielectric losses:" ) );
169 m_Messages.Add( _( "Skin depth:" ) );
170
172 "H", "H", _( "Height of substrate" ), 0.2, true ) );
174 "T", "T", _( "Strip thickness" ), 0.035, true ) );
176 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
177 _( "conductor" ) ),
178 _( "Relative permeability (mu) of conductor" ), 1,
179 false ) );
180
182 "W", "W", _( "Line width" ), 0.2, true ) );
184 "S", "S", _( "Gap width" ), 0.2, true ) );
186 "L", "L", _( "Line length" ), 50.0, true ) );
187
189 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
192 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
193 break;
194
195 case GROUNDED_CPW_TYPE: // grounded coplanar waveguide
198 m_HasPrmSelection = true;
199
200 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
201 m_Messages.Add( _( "Unit propagation delay:" ) );
202 m_Messages.Add( _( "Conductor losses:" ) );
203 m_Messages.Add( _( "Dielectric losses:" ) );
204 m_Messages.Add( _( "Skin depth:" ) );
205
207 "H", "H", _( "Height of substrate" ), 0.2, true ) );
209 "T", "T", _( "Strip thickness" ), 0.035, true ) );
211 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
212 _( "conductor" ) ),
213 _( "Relative permeability (mu) of conductor" ), 1,
214 false ) );
215
217 "W", "W", _( "Line width" ), 0.2, true ) );
219 "S", "S", _( "Gap width" ), 0.2, true ) );
221 "L", "L", _( "Line length" ), 50.0, true ) );
222
224 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
227 "Ang_l", "Ang_l", _( "Electrical length" ), 0, true ) );
228 break;
229
230
231 case RECTWAVEGUIDE_TYPE: // rectangular waveguide
232 m_TLine = new RECTWAVEGUIDE();
234 m_HasPrmSelection = true;
235
236 m_Messages.Add( _( "ZF(H10) = Ey / Hx:" ) );
237 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
238 m_Messages.Add( _( "Conductor losses:" ) );
239 m_Messages.Add( _( "Dielectric losses:" ) );
240 m_Messages.Add( _( "TE-modes:" ) );
241 m_Messages.Add( _( "TM-modes:" ) );
242
244 "mu Rel I", wxString::Format( wxT( "μ(%s)" ),
245 _( "insulator" ) ),
246 _( "Relative permeability (mu) of insulator" ), 1, false ) );
248 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
249 _( "conductor" ) ),
250 _( "Relative permeability (mu) of conductor" ), 1,
251 false ) );
252
254 "a", "a", _( "Width of waveguide" ), 10.0, true ) );
256 "b", "b", _( "Height of waveguide" ), 5.0, true ) );
258 "L", "L", _( "Waveguide length" ), 50.0, true ) );
259
261 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
264 "Ang_l", "Ang_l", _( "Electrical length" ), 0, true ) );
265 break;
266
267 case COAX_TYPE: // coaxial cable
268 m_TLine = new COAX();
270 m_HasPrmSelection = true;
271
272 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
273 m_Messages.Add( _( "Conductor losses:" ) );
274 m_Messages.Add( _( "Dielectric losses:" ) );
275 m_Messages.Add( _( "TE-modes:" ) );
276 m_Messages.Add( _( "TM-modes:" ) );
277
279 "mu Rel I", wxString::Format( wxT( "μ(%s)" ),
280 _( "insulator" ) ),
281 _( "Relative permeability (mu) of insulator" ), 1, false ) );
283 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
284 _( "conductor" ) ),
285 _( "Relative permeability (mu) of conductor" ), 1,
286 false ) );
287
289 "Din", _( "Din" ),
290 _( "Inner diameter (conductor)" ), 1.0, true ) );
292 "Dout", _( "Dout" ),
293 _( "Outer diameter (insulator)" ), 8.0, true ) );
295 "L", "L", _( "Line length" ), 50.0, true ) );
296
298 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
301 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
302 break;
303
304 case C_MICROSTRIP_TYPE: // coupled microstrip
305 m_TLine = new C_MICROSTRIP();
307 m_HasPrmSelection = true;
308
309 m_Messages.Add( wxString::Format( _( "Effective %s (even):" ), wxT( "εr" ) ) );
310 m_Messages.Add( wxString::Format( _( "Effective %s (odd):" ), wxT( "εr" ) ) );
311 m_Messages.Add( _( "Unit propagation delay (even):" ) );
312 m_Messages.Add( _( "Unit propagation delay (odd):" ) );
313 m_Messages.Add( _( "Conductor losses (even):" ) );
314 m_Messages.Add( _( "Conductor losses (odd):" ) );
315 m_Messages.Add( _( "Dielectric losses (even):" ) );
316 m_Messages.Add( _( "Dielectric losses (odd):" ) );
317 m_Messages.Add( _( "Skin depth:" ) );
318 m_Messages.Add( _( "Differential Impedance (Zd):" ) );
319
321 "H", "H", _( "Height of substrate" ), 0.2, true ) );
323 "H_t", "H_t", _( "Height of box top" ), 1e20, true ) );
325 "T", "T", _( "Strip thickness" ), 0.035, true ) );
327 "Rough", _( "Roughness" ),
328 _( "Conductor roughness" ), 0.0, true ) );
330 "mu rel C", wxString::Format( wxT( "μ(%s)" ),
331 _( "conductor" ) ),
332 _( "Relative permeability (mu) of conductor" ), 1,
333 false ) );
334
336 "W", "W", _( "Line width" ), 0.2, true ) );
338 "S", "S", _( "Gap width" ), 0.2, true ) );
340 "L", "L", _( "Line length" ), 50.0, true ) );
341
342 AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_E_PRM, "Zeven", _( "Zeven" ),
343 _( "Even mode impedance (lines driven by common voltages)" ), 50.0, true ) );
344 AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_O_PRM, "Zodd", _( "Zodd" ),
345 _( "Odd mode impedance (lines driven by opposite "
346 "(differential) voltages)" ),
347 50.0, true ) );
348 AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM, "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
349 break;
350
351 case C_STRIPLINE_TYPE: // Coupled stripline
352 m_TLine = new C_STRIPLINE();
354 m_HasPrmSelection = true;
355
356 m_Messages.Add( wxString::Format( _( "Effective %s (even):" ), wxT( "εr" ) ) );
357 m_Messages.Add( wxString::Format( _( "Effective %s (odd):" ), wxT( "εr" ) ) );
358 m_Messages.Add( _( "Unit propagation delay (even):" ) );
359 m_Messages.Add( _( "Unit propagation delay (odd):" ) );
360 m_Messages.Add( _( "Skin depth:" ) );
361 m_Messages.Add( _( "Differential Impedance (Zd):" ) );
362
363 AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_PRM, "H", "H", _( "Height of substrate" ), 0.2, true ) );
364 AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM, "T", "T", _( "Strip thickness" ), 0.035, true ) );
365 AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM, "mu rel C",
366 wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ),
367 _( "Relative permeability (mu) of conductor" ), 1, false ) );
368
369 AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM, "W", "W", _( "Line width" ), 0.2, true ) );
370 AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_S_PRM, "S", "S", _( "Gap width" ), 0.2, true ) );
371 AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM, "L", "L", _( "Line length" ), 50.0, true ) );
372
374 "Zeven", _( "Zeven" ),
375 _( "Even mode impedance (lines driven by common voltages)" ),
376 50.0, true ) );
378 "Zodd", _( "Zodd" ),
379 _( "Odd mode impedance (lines driven by opposite "
380 "(differential) voltages)" ), 50.0, true ) );
382 "Ang_l", "Ang_l",
383 _( "Electrical length" ), 0.0, true ) );
384 break;
385
386 case STRIPLINE_TYPE: // stripline
387 m_TLine = new STRIPLINE_UI();
389
390 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
391 m_Messages.Add( _( "Unit propagation delay:" ) );
392 m_Messages.Add( _( "Conductor losses:" ) );
393 m_Messages.Add( _( "Dielectric losses:" ) );
394 m_Messages.Add( _( "Skin depth:" ) );
395
397 "H", "H", _( "Height of substrate" ), 0.2, true ) );
399 "a", "a", _( "Distance between strip and top metal" ), 0.2,
400 true ) );
402 "T", "T", _( "Strip thickness" ), 0.035, true ) );
404 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
405 _( "conductor" ) ),
406 _( "Relative permeability (mu) of conductor" ), 1, false ) );
407
409 "W", "W", _( "Line width" ), 0.2, true ) );
411 "L", "L", _( "Line length" ), 50.0, true ) );
412
414 "Z0", "Z0", _( "Characteristic impedance" ), 50, true ) );
417 "Ang_l", "Ang_l", _( "Electrical length" ), 0, true ) );
418 break;
419
420 case TWISTEDPAIR_TYPE: // twisted pair
421 m_TLine = new TWISTEDPAIR();
423 m_HasPrmSelection = true;
424
425 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
426 m_Messages.Add( _( "Conductor losses:" ) );
427 m_Messages.Add( _( "Dielectric losses:" ) );
428 m_Messages.Add( _( "Skin depth:" ) );
429
431 "Twists", _( "Twists" ),
432 _( "Number of twists per length" ), 0.0, false ) );
434 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
435 _( "conductor" ) ),
436 _( "Relative permeability (mu) of conductor" ), 1,
437 false ) );
439 "ErEnv", wxString::Format( wxT( "εr(%s)" ),
440 _( "environment" ) ),
441 _( "Relative permittivity of environment" ), 1,
442 false ) );
444 "Din", _( "Din" ),
445 _( "Inner diameter (conductor)" ), 1.0, true ) );
447 "Dout", _( "Dout" ),
448 _( "Outer diameter (insulator)" ), 8.0, true ) );
450 "L", "L", _( "Cable length" ), 50.0, true ) );
451
453 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
456 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
457 break;
458
459 case END_OF_LIST_TYPE: // Not really used
460 break;
461 }
462}
463
465{
466 delete m_TLine;
467
468 for( auto& ii : m_prms_List )
469 delete ii;
470
471 m_prms_List.clear();
472}
473
474
476{
477 auto cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( Kiface().KifaceSettings() );
478 std::string name( m_TLine->m_Name );
479
480 if( cfg->m_TransLine.param_values.count( name ) )
481 {
482 wxASSERT( cfg->m_TransLine.param_units.count( name ) );
483
484 for( auto& p : m_prms_List )
485 {
486 try
487 {
488 p->m_Value = cfg->m_TransLine.param_values.at( name ).at( p->m_KeyWord );
489 p->m_UnitSelection = cfg->m_TransLine.param_units.at( name ).at( p->m_KeyWord );
490 }
491 catch( ... )
492 {}
493 }
494 }
495}
496
497
499{
500 auto cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( Kiface().KifaceSettings() );
501 std::string name( m_TLine->m_Name );
502
503 for( auto& param : m_prms_List )
504 {
505 if( !std::isfinite( param->m_Value ) )
506 param->m_Value = 0;
507
508 cfg->m_TransLine.param_values[ name ][ param->m_KeyWord ] = param->m_Value;
509 cfg->m_TransLine.param_units[ name ][ param->m_KeyWord ] = param->m_UnitSelection;
510 }
511}
512
const char * name
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
@ coupled_stripline
@ INVALID_BITMAP
Definition coax.h:31
APP_SETTINGS_BASE * KifaceSettings() const
Definition kiface_base.h:95
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, int aDefaultUnit=0)
double m_NormalizedValue
wxString m_DlgLabel
std::string m_KeyWord
#define _(s)
PRMS_ID
Definition transline.h:39
@ TWISTEDPAIR_EPSILONR_ENV_PRM
Definition transline.h:51
@ Z0_O_PRM
Definition transline.h:56
@ FREQUENCY_PRM
Definition transline.h:53
@ DUMMY_PRM
Definition transline.h:63
@ RHO_PRM
Definition transline.h:43
@ PHYS_DIAM_OUT_PRM
Definition transline.h:61
@ T_PRM
Definition transline.h:48
@ Z0_E_PRM
Definition transline.h:55
@ MURC_PRM
Definition transline.h:52
@ MUR_PRM
Definition transline.h:50
@ STRIPLINE_A_PRM
Definition transline.h:47
@ Z0_PRM
Definition transline.h:54
@ TAND_PRM
Definition transline.h:42
@ PHYS_LEN_PRM
Definition transline.h:62
@ ANG_L_PRM
Definition transline.h:57
@ H_T_PRM
Definition transline.h:46
@ TWISTEDPAIR_TWIST_PRM
Definition transline.h:45
@ PHYS_DIAM_IN_PRM
Definition transline.h:59
@ ROUGH_PRM
Definition transline.h:49
@ EPSILONR_PRM
Definition transline.h:41
@ PHYS_S_PRM
Definition transline.h:60
@ H_PRM
Definition transline.h:44
@ PHYS_WIDTH_PRM
Definition transline.h:58
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
@ C_STRIPLINE_TYPE