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"
44
45
46TRANSLINE_PRM::TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, const char* aKeywordCfg, const wxString& aDlgLabel,
47 const wxString& aToolTip, double aValue, bool aConvUnit, int aDefaultUnit )
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_DefaultValue = aValue;
56 m_DefaultUnit = aDefaultUnit;
57 m_ConvUnit = aConvUnit;
58 m_ValueCtrl = nullptr;
59 m_UnitCtrl = nullptr;
62 }
63
64
66{
67 if( m_UnitCtrl && m_ConvUnit )
68 return 1.0 / ( (UNIT_SELECTOR*) m_UnitCtrl )->GetUnitScale();
69 else
70 return 1.0;
71}
72
73
75{
76 if( m_UnitCtrl )
77 return ( (UNIT_SELECTOR*) m_UnitCtrl )->GetUnitScale();
78 else
79 return 1.0;
80}
81
82
84{
85 m_Type = aType; // The type of transline handled
86 m_BitmapName = BITMAPS::INVALID_BITMAP; // The icon to display
87 m_TLine = nullptr; // The TRANSLINE itself
88 m_HasPrmSelection = false; // true if selection of parameters must be enabled in dialog menu
89
90 // Add common prms:
91 // Default values are for FR4
93 "Er", wxT( "εr" ),
94 _( "Substrate relative permittivity (dielectric constant)" ),
95 4.5, false ) );
97 "TanD", wxT( "tan δ" ),
98 _( "Dielectric loss (dissipation factor)" ),
99 2e-2, false ) );
100
101 // Default value is for copper
103 "Rho", wxT( "ρ" ),
104 _( "Electrical resistivity or specific electrical resistance of "
105 "conductor (ohm*meter)" ),
106 1.72e-8, false ) );
107
108 // Default value is in GHz
110 "Frequency", _( "Frequency" ),
111 _( "Frequency of the input signal" ), 1.0, true ) );
112
113
114 switch( m_Type )
115 {
116 case MICROSTRIP_TYPE: // microstrip
117 m_TLine = new MICROSTRIP_UI();
118 m_BitmapName = BITMAPS::microstrip;
119
120 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
121 m_Messages.Add( _( "Unit propagation delay:" ) );
122 m_Messages.Add( _( "Conductor losses:" ) );
123 m_Messages.Add( _( "Dielectric losses:" ) );
124 m_Messages.Add( _( "Skin depth:" ) );
125
127 "H", "H", _( "Height of substrate" ), 0.2, true ) );
129 "H_t", "H(top)", _( "Height of box top" ), 1e20, true ) );
131 "T", "T",
132 _( "Strip thickness" ), 0.035, true ) );
134 "Rough", _( "Roughness" ),
135 _( "Conductor roughness" ), 0.0, true ) );
137 "mu Rel S", wxString::Format( wxT( "μr (%s)" ),
138 _( "substrate" ) ),
139 _( "Relative permeability (mu) of substrate" ), 1, false ) );
141 "mu Rel C", wxString::Format( wxT( "μr (%s)" ),
142 _( "conductor" ) ),
143 _( "Relative permeability (mu) of conductor" ), 1,
144 false ) );
145
147 "W", "W", _( "Line width" ), 0.2, true ) );
149 "L", "L", _( "Line length" ), 50.0, true ) );
150
152 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
155 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
156 break;
157
158 case CPW_TYPE: // coplanar waveguide
159 m_TLine = new COPLANAR();
160 m_BitmapName = BITMAPS::cpw;
161 m_HasPrmSelection = true;
162
163 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
164 m_Messages.Add( _( "Unit propagation delay:" ) );
165 m_Messages.Add( _( "Conductor losses:" ) );
166 m_Messages.Add( _( "Dielectric losses:" ) );
167 m_Messages.Add( _( "Skin depth:" ) );
168
170 "H", "H", _( "Height of substrate" ), 0.2, true ) );
172 "T", "T", _( "Strip thickness" ), 0.035, true ) );
174 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
175 _( "conductor" ) ),
176 _( "Relative permeability (mu) of conductor" ), 1,
177 false ) );
178
180 "W", "W", _( "Line width" ), 0.2, true ) );
182 "S", "S", _( "Gap width" ), 0.2, true ) );
184 "L", "L", _( "Line length" ), 50.0, true ) );
185
187 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
190 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
191 break;
192
193 case GROUNDED_CPW_TYPE: // grounded coplanar waveguide
195 m_BitmapName = BITMAPS::cpw_back;
196 m_HasPrmSelection = true;
197
198 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
199 m_Messages.Add( _( "Unit propagation delay:" ) );
200 m_Messages.Add( _( "Conductor losses:" ) );
201 m_Messages.Add( _( "Dielectric losses:" ) );
202 m_Messages.Add( _( "Skin depth:" ) );
203
205 "H", "H", _( "Height of substrate" ), 0.2, true ) );
207 "T", "T", _( "Strip thickness" ), 0.035, true ) );
209 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
210 _( "conductor" ) ),
211 _( "Relative permeability (mu) of conductor" ), 1,
212 false ) );
213
215 "W", "W", _( "Line width" ), 0.2, true ) );
217 "S", "S", _( "Gap width" ), 0.2, true ) );
219 "L", "L", _( "Line length" ), 50.0, true ) );
220
222 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
225 "Ang_l", "Ang_l", _( "Electrical length" ), 0, true ) );
226 break;
227
228
229 case RECTWAVEGUIDE_TYPE: // rectangular waveguide
230 m_TLine = new RECTWAVEGUIDE();
231 m_BitmapName = BITMAPS::rectwaveguide;
232 m_HasPrmSelection = true;
233
234 m_Messages.Add( _( "ZF(H10) = Ey / Hx:" ) );
235 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
236 m_Messages.Add( _( "Conductor losses:" ) );
237 m_Messages.Add( _( "Dielectric losses:" ) );
238 m_Messages.Add( _( "TE-modes:" ) );
239 m_Messages.Add( _( "TM-modes:" ) );
240
242 "mu Rel I", wxString::Format( wxT( "μ(%s)" ),
243 _( "insulator" ) ),
244 _( "Relative permeability (mu) of insulator" ), 1, false ) );
246 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
247 _( "conductor" ) ),
248 _( "Relative permeability (mu) of conductor" ), 1,
249 false ) );
250
252 "a", "a", _( "Width of waveguide" ), 10.0, true ) );
254 "b", "b", _( "Height of waveguide" ), 5.0, true ) );
256 "L", "L", _( "Waveguide length" ), 50.0, true ) );
257
259 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
262 "Ang_l", "Ang_l", _( "Electrical length" ), 0, true ) );
263 break;
264
265 case COAX_TYPE: // coaxial cable
266 m_TLine = new COAX();
267 m_BitmapName = BITMAPS::coax;
268 m_HasPrmSelection = true;
269
270 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
271 m_Messages.Add( _( "Conductor losses:" ) );
272 m_Messages.Add( _( "Dielectric losses:" ) );
273 m_Messages.Add( _( "TE-modes:" ) );
274 m_Messages.Add( _( "TM-modes:" ) );
275
277 "mu Rel I", wxString::Format( wxT( "μ(%s)" ),
278 _( "insulator" ) ),
279 _( "Relative permeability (mu) of insulator" ), 1, false ) );
281 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
282 _( "conductor" ) ),
283 _( "Relative permeability (mu) of conductor" ), 1,
284 false ) );
285
287 "Din", _( "Din" ),
288 _( "Inner diameter (conductor)" ), 1.0, true ) );
290 "Dout", _( "Dout" ),
291 _( "Outer diameter (insulator)" ), 8.0, true ) );
293 "L", "L", _( "Line length" ), 50.0, true ) );
294
296 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
299 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
300 break;
301
302 case C_MICROSTRIP_TYPE: // coupled microstrip
303 m_TLine = new C_MICROSTRIP();
304 m_BitmapName = BITMAPS::c_microstrip;
305 m_HasPrmSelection = true;
306
307 m_Messages.Add( wxString::Format( _( "Effective %s (even):" ), wxT( "εr" ) ) );
308 m_Messages.Add( wxString::Format( _( "Effective %s (odd):" ), wxT( "εr" ) ) );
309 m_Messages.Add( _( "Unit propagation delay (even):" ) );
310 m_Messages.Add( _( "Unit propagation delay (odd):" ) );
311 m_Messages.Add( _( "Conductor losses (even):" ) );
312 m_Messages.Add( _( "Conductor losses (odd):" ) );
313 m_Messages.Add( _( "Dielectric losses (even):" ) );
314 m_Messages.Add( _( "Dielectric losses (odd):" ) );
315 m_Messages.Add( _( "Skin depth:" ) );
316 m_Messages.Add( _( "Differential Impedance (Zd):" ) );
317
319 "H", "H", _( "Height of substrate" ), 0.2, true ) );
321 "H_t", "H_t", _( "Height of box top" ), 1e20, true ) );
323 "T", "T", _( "Strip thickness" ), 0.035, true ) );
325 "Rough", _( "Roughness" ),
326 _( "Conductor roughness" ), 0.0, true ) );
328 "mu rel C", wxString::Format( wxT( "μ(%s)" ),
329 _( "conductor" ) ),
330 _( "Relative permeability (mu) of conductor" ), 1,
331 false ) );
332
334 "W", "W", _( "Line width" ), 0.2, true ) );
336 "S", "S", _( "Gap width" ), 0.2, true ) );
338 "L", "L", _( "Line length" ), 50.0, true ) );
339
340 AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_E_PRM, "Zeven", _( "Zeven" ),
341 _( "Even mode impedance (lines driven by common voltages)" ), 50.0, true ) );
342 AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_O_PRM, "Zodd", _( "Zodd" ),
343 _( "Odd mode impedance (lines driven by opposite "
344 "(differential) voltages)" ),
345 50.0, true ) );
346 AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM, "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
347 break;
348
349 case C_STRIPLINE_TYPE: // Coupled stripline
350 m_TLine = new C_STRIPLINE();
351 m_BitmapName = BITMAPS::coupled_stripline;
352 m_HasPrmSelection = true;
353
354 m_Messages.Add( wxString::Format( _( "Effective %s (even):" ), wxT( "εr" ) ) );
355 m_Messages.Add( wxString::Format( _( "Effective %s (odd):" ), wxT( "εr" ) ) );
356 m_Messages.Add( _( "Unit propagation delay (even):" ) );
357 m_Messages.Add( _( "Unit propagation delay (odd):" ) );
358 m_Messages.Add( _( "Skin depth:" ) );
359 m_Messages.Add( _( "Differential Impedance (Zd):" ) );
360
361 AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_PRM, "H", "H", _( "Height of substrate" ), 0.2, true ) );
362 AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM, "T", "T", _( "Strip thickness" ), 0.035, true ) );
363 AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM, "mu rel C",
364 wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ),
365 _( "Relative permeability (mu) of conductor" ), 1, false ) );
366
367 AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM, "W", "W", _( "Line width" ), 0.2, true ) );
368 AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_S_PRM, "S", "S", _( "Gap width" ), 0.2, true ) );
369 AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM, "L", "L", _( "Line length" ), 50.0, true ) );
370
372 "Zeven", _( "Zeven" ),
373 _( "Even mode impedance (lines driven by common voltages)" ),
374 50.0, true ) );
376 "Zodd", _( "Zodd" ),
377 _( "Odd mode impedance (lines driven by opposite "
378 "(differential) voltages)" ), 50.0, true ) );
380 "Ang_l", "Ang_l",
381 _( "Electrical length" ), 0.0, true ) );
382 break;
383
384 case STRIPLINE_TYPE: // stripline
385 m_TLine = new STRIPLINE_UI();
386 m_BitmapName = BITMAPS::stripline;
387
388 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
389 m_Messages.Add( _( "Unit propagation delay:" ) );
390 m_Messages.Add( _( "Conductor losses:" ) );
391 m_Messages.Add( _( "Dielectric losses:" ) );
392 m_Messages.Add( _( "Skin depth:" ) );
393
395 "H", "H", _( "Height of substrate" ), 0.2, true ) );
397 "a", "a", _( "Distance between strip and top metal" ), 0.2,
398 true ) );
400 "T", "T", _( "Strip thickness" ), 0.035, true ) );
402 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
403 _( "conductor" ) ),
404 _( "Relative permeability (mu) of conductor" ), 1, false ) );
405
407 "W", "W", _( "Line width" ), 0.2, true ) );
409 "L", "L", _( "Line length" ), 50.0, true ) );
410
412 "Z0", "Z0", _( "Characteristic impedance" ), 50, true ) );
415 "Ang_l", "Ang_l", _( "Electrical length" ), 0, true ) );
416 break;
417
418 case TWISTEDPAIR_TYPE: // twisted pair
419 m_TLine = new TWISTEDPAIR();
420 m_BitmapName = BITMAPS::twistedpair;
421 m_HasPrmSelection = true;
422
423 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
424 m_Messages.Add( _( "Conductor losses:" ) );
425 m_Messages.Add( _( "Dielectric losses:" ) );
426 m_Messages.Add( _( "Skin depth:" ) );
427
429 "Twists", _( "Twists" ),
430 _( "Number of twists per length" ), 0.0, false ) );
432 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
433 _( "conductor" ) ),
434 _( "Relative permeability (mu) of conductor" ), 1,
435 false ) );
437 "ErEnv", wxString::Format( wxT( "εr(%s)" ),
438 _( "environment" ) ),
439 _( "Relative permittivity of environment" ), 1,
440 false ) );
442 "Din", _( "Din" ),
443 _( "Inner diameter (conductor)" ), 1.0, true ) );
445 "Dout", _( "Dout" ),
446 _( "Outer diameter (insulator)" ), 8.0, true ) );
448 "L", "L", _( "Cable length" ), 50.0, true ) );
449
451 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
454 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
455 break;
456
457 case END_OF_LIST_TYPE: // Not really used
458 break;
459 }
460}
461
463{
464 delete m_TLine;
465
466 for( auto& ii : m_prms_List )
467 delete ii;
468
469 m_prms_List.clear();
470}
471
472
474{
475 auto cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( Kiface().KifaceSettings() );
476 std::string name( m_TLine->m_Name );
477
478 if( cfg->m_TransLine.param_values.count( name ) )
479 {
480 wxASSERT( cfg->m_TransLine.param_units.count( name ) );
481
482 for( auto& p : m_prms_List )
483 {
484 try
485 {
486 p->m_Value = cfg->m_TransLine.param_values.at( name ).at( p->m_KeyWord );
487 p->m_UnitSelection = cfg->m_TransLine.param_units.at( name ).at( p->m_KeyWord );
488 }
489 catch( ... )
490 {}
491 }
492 }
493}
494
495
497{
498 auto cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( Kiface().KifaceSettings() );
499 std::string name( m_TLine->m_Name );
500
501 for( auto& param : m_prms_List )
502 {
503 if( !std::isfinite( param->m_Value ) )
504 param->m_Value = 0;
505
506 cfg->m_TransLine.param_values[ name ][ param->m_KeyWord ] = param->m_Value;
507 cfg->m_TransLine.param_units[ name ][ param->m_KeyWord ] = param->m_UnitSelection;
508 }
509}
510
const char * name
Definition: DXF_plotter.cpp:62
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
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_DefaultValue
double m_NormalizedValue
wxString m_ToolTip
wxString m_DlgLabel
std::string m_KeyWord
double FromUserUnit()
const char * m_Name
Definition: transline.h:86
#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