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 (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_DefaultValue = aValue;
56 m_ConvUnit = aConvUnit;
57 m_ValueCtrl = nullptr;
58 m_UnitCtrl = nullptr;
61 }
62
63
65{
66 if( m_UnitCtrl && m_ConvUnit )
67 return 1.0 / ( (UNIT_SELECTOR*) m_UnitCtrl )->GetUnitScale();
68 else
69 return 1.0;
70}
71
72
74{
75 if( m_UnitCtrl )
76 return ( (UNIT_SELECTOR*) m_UnitCtrl )->GetUnitScale();
77 else
78 return 1.0;
79}
80
81
83{
84 m_Type = aType; // The type of transline handled
85 m_BitmapName = BITMAPS::INVALID_BITMAP; // The icon to display
86 m_TLine = nullptr; // The TRANSLINE itself
87 m_HasPrmSelection = false; // true if selection of parameters must be enabled in dialog menu
88
89 // Add common prms:
90 // Default values are for FR4
92 "Er", wxT( "εr" ),
93 _( "Substrate relative permittivity (dielectric constant)" ),
94 4.5, false ) );
96 "TanD", wxT( "tan δ" ),
97 _( "Dielectric loss (dissipation factor)" ),
98 2e-2, false ) );
99
100 // Default value is for copper
102 "Rho", wxT( "ρ" ),
103 _( "Electrical resistivity or specific electrical resistance of "
104 "conductor (ohm*meter)" ),
105 1.72e-8, false ) );
106
107 // Default value is in GHz
109 "Frequency", _( "Frequency" ),
110 _( "Frequency of the input signal" ), 1.0, true ) );
111
112
113 switch( m_Type )
114 {
115 case MICROSTRIP_TYPE: // microstrip
116 m_TLine = new MICROSTRIP();
117 m_BitmapName = BITMAPS::microstrip;
118
119 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
120 m_Messages.Add( _( "Conductor losses:" ) );
121 m_Messages.Add( _( "Dielectric losses:" ) );
122 m_Messages.Add( _( "Skin depth:" ) );
123
125 "H", "H", _( "Height of substrate" ), 0.2, true ) );
127 "H_t", "H(top)", _( "Height of box top" ), 1e20, true ) );
129 "T", "T",
130 _( "Strip thickness" ), 0.035, true ) );
132 "Rough", _( "Roughness" ),
133 _( "Conductor roughness" ), 0.0, true ) );
135 "mu Rel S", wxString::Format( wxT( "μ(%s)" ),
136 _( "substrate" ) ),
137 _( "Relative permeability (mu) of substrate" ), 1, false ) );
139 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
140 _( "conductor" ) ),
141 _( "Relative permeability (mu) of conductor" ), 1,
142 false ) );
143
145 "W", "W", _( "Line width" ), 0.2, true ) );
147 "L", "L", _( "Line length" ), 50.0, true ) );
148
150 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
153 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
154 break;
155
156 case CPW_TYPE: // coplanar waveguide
157 m_TLine = new COPLANAR();
158 m_BitmapName = BITMAPS::cpw;
159 m_HasPrmSelection = true;
160
161 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
162 m_Messages.Add( _( "Conductor losses:" ) );
163 m_Messages.Add( _( "Dielectric losses:" ) );
164 m_Messages.Add( _( "Skin depth:" ) );
165
167 "H", "H", _( "Height of substrate" ), 0.2, true ) );
169 "T", "T", _( "Strip thickness" ), 0.035, true ) );
171 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
172 _( "conductor" ) ),
173 _( "Relative permeability (mu) of conductor" ), 1,
174 false ) );
175
177 "W", "W", _( "Line width" ), 0.2, true ) );
179 "S", "S", _( "Gap width" ), 0.2, true ) );
181 "L", "L", _( "Line length" ), 50.0, true ) );
182
184 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
187 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
188 break;
189
190 case GROUNDED_CPW_TYPE: // grounded coplanar waveguide
192 m_BitmapName = BITMAPS::cpw_back;
193 m_HasPrmSelection = true;
194
195 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
196 m_Messages.Add( _( "Conductor losses:" ) );
197 m_Messages.Add( _( "Dielectric losses:" ) );
198 m_Messages.Add( _( "Skin depth:" ) );
199
201 "H", "H", _( "Height of substrate" ), 0.2, true ) );
203 "T", "T", _( "Strip thickness" ), 0.035, true ) );
205 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
206 _( "conductor" ) ),
207 _( "Relative permeability (mu) of conductor" ), 1,
208 false ) );
209
211 "W", "W", _( "Line width" ), 0.2, true ) );
213 "S", "S", _( "Gap width" ), 0.2, true ) );
215 "L", "L", _( "Line length" ), 50.0, true ) );
216
218 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
221 "Ang_l", "Ang_l", _( "Electrical length" ), 0, true ) );
222 break;
223
224
225 case RECTWAVEGUIDE_TYPE: // rectangular waveguide
226 m_TLine = new RECTWAVEGUIDE();
227 m_BitmapName = BITMAPS::rectwaveguide;
228 m_HasPrmSelection = true;
229
230 m_Messages.Add( _( "ZF(H10) = Ey / Hx:" ) );
231 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
232 m_Messages.Add( _( "Conductor losses:" ) );
233 m_Messages.Add( _( "Dielectric losses:" ) );
234 m_Messages.Add( _( "TE-modes:" ) );
235 m_Messages.Add( _( "TM-modes:" ) );
236
238 "mu Rel I", wxString::Format( wxT( "μ(%s)" ),
239 _( "insulator" ) ),
240 _( "Relative permeability (mu) of insulator" ), 1, false ) );
242 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
243 _( "conductor" ) ),
244 _( "Relative permeability (mu) of conductor" ), 1,
245 false ) );
246
248 "a", "a", _( "Width of waveguide" ), 10.0, true ) );
250 "b", "b", _( "Height of waveguide" ), 5.0, true ) );
252 "L", "L", _( "Waveguide length" ), 50.0, true ) );
253
255 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
258 "Ang_l", "Ang_l", _( "Electrical length" ), 0, true ) );
259 break;
260
261 case COAX_TYPE: // coaxial cable
262 m_TLine = new COAX();
263 m_BitmapName = BITMAPS::coax;
264 m_HasPrmSelection = true;
265
266 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
267 m_Messages.Add( _( "Conductor losses:" ) );
268 m_Messages.Add( _( "Dielectric losses:" ) );
269 m_Messages.Add( _( "TE-modes:" ) );
270 m_Messages.Add( _( "TM-modes:" ) );
271
273 "mu Rel I", wxString::Format( wxT( "μ(%s)" ),
274 _( "insulator" ) ),
275 _( "Relative permeability (mu) of insulator" ), 1, false ) );
277 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
278 _( "conductor" ) ),
279 _( "Relative permeability (mu) of conductor" ), 1,
280 false ) );
281
283 "Din", _( "Din" ),
284 _( "Inner diameter (conductor)" ), 1.0, true ) );
286 "Dout", _( "Dout" ),
287 _( "Outer diameter (insulator)" ), 8.0, true ) );
289 "L", "L", _( "Line length" ), 50.0, true ) );
290
292 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
295 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
296 break;
297
298 case C_MICROSTRIP_TYPE: // coupled microstrip
299 m_TLine = new C_MICROSTRIP();
300 m_BitmapName = BITMAPS::c_microstrip;
301 m_HasPrmSelection = true;
302
303 m_Messages.Add( wxString::Format( _( "Effective %s (even):" ), wxT( "εr" ) ) );
304 m_Messages.Add( wxString::Format( _( "Effective %s (odd):" ), wxT( "εr" ) ) );
305 m_Messages.Add( _( "Conductor losses (even):" ) );
306 m_Messages.Add( _( "Conductor losses (odd):" ) );
307 m_Messages.Add( _( "Dielectric losses (even):" ) );
308 m_Messages.Add( _( "Dielectric losses (odd):" ) );
309 m_Messages.Add( _( "Skin depth:" ) );
310 m_Messages.Add( _( "Differential Impedance (Zd):" ) );
311
313 "H", "H", _( "Height of substrate" ), 0.2, true ) );
315 "H_t", "H_t", _( "Height of box top" ), 1e20, true ) );
317 "T", "T", _( "Strip thickness" ), 0.035, true ) );
319 "Rough", _( "Roughness" ),
320 _( "Conductor roughness" ), 0.0, true ) );
322 "mu rel C", wxString::Format( wxT( "μ(%s)" ),
323 _( "conductor" ) ),
324 _( "Relative permeability (mu) of conductor" ), 1,
325 false ) );
326
328 "W", "W", _( "Line width" ), 0.2, true ) );
330 "S", "S", _( "Gap width" ), 0.2, true ) );
332 "L", "L", _( "Line length" ), 50.0, true ) );
333
335 "Zeven", _( "Zeven" ),
336 _( "Even mode impedance (lines driven by common voltages)" ),
337 50.0, true ) );
339 "Zodd", _( "Zodd" ),
340 _( "Odd mode impedance (lines driven by opposite "
341 "(differential) voltages)" ), 50.0, true ) );
343 "Ang_l", "Ang_l",
344 _( "Electrical length" ), 0.0, true ) );
345 break;
346
347 case STRIPLINE_TYPE: // stripline
348 m_TLine = new STRIPLINE();
349 m_BitmapName = BITMAPS::stripline;
350
351 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
352 m_Messages.Add( _( "Conductor losses:" ) );
353 m_Messages.Add( _( "Dielectric losses:" ) );
354 m_Messages.Add( _( "Skin depth:" ) );
355
357 "H", "H", _( "Height of substrate" ), 0.2, true ) );
359 "a", "a", _( "Distance between strip and top metal" ), 0.2,
360 true ) );
362 "T", "T", _( "Strip thickness" ), 0.035, true ) );
364 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
365 _( "conductor" ) ),
366 _( "Relative permeability (mu) of conductor" ), 1, false ) );
367
369 "W", "W", _( "Line width" ), 0.2, true ) );
371 "L", "L", _( "Line length" ), 50.0, true ) );
372
374 "Z0", "Z0", _( "Characteristic impedance" ), 50, true ) );
377 "Ang_l", "Ang_l", _( "Electrical length" ), 0, true ) );
378 break;
379
380 case TWISTEDPAIR_TYPE: // twisted pair
381 m_TLine = new TWISTEDPAIR();
382 m_BitmapName = BITMAPS::twistedpair;
383 m_HasPrmSelection = true;
384
385 m_Messages.Add( wxString::Format( _( "Effective %s:" ), wxT( "εr" ) ) );
386 m_Messages.Add( _( "Conductor losses:" ) );
387 m_Messages.Add( _( "Dielectric losses:" ) );
388 m_Messages.Add( _( "Skin depth:" ) );
389
391 "Twists", _( "Twists" ),
392 _( "Number of twists per length" ), 0.0, false ) );
394 "mu Rel C", wxString::Format( wxT( "μ(%s)" ),
395 _( "conductor" ) ),
396 _( "Relative permeability (mu) of conductor" ), 1,
397 false ) );
399 "ErEnv", wxString::Format( wxT( "εr(%s)" ),
400 _( "environment" ) ),
401 _( "Relative permittivity of environment" ), 1,
402 false ) );
404 "Din", _( "Din" ),
405 _( "Inner diameter (conductor)" ), 1.0, true ) );
407 "Dout", _( "Dout" ),
408 _( "Outer diameter (insulator)" ), 8.0, true ) );
410 "L", "L", _( "Cable length" ), 50.0, true ) );
411
413 "Z0", "Z0", _( "Characteristic impedance" ), 50.0, true ) );
416 "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) );
417 break;
418
419 case END_OF_LIST_TYPE: // Not really used
420 break;
421 }
422}
423
425{
426 delete m_TLine;
427
428 for( auto& ii : m_prms_List )
429 delete ii;
430
431 m_prms_List.clear();
432}
433
434
436{
437 auto cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( Kiface().KifaceSettings() );
438 std::string name( m_TLine->m_Name );
439
440 if( cfg->m_TransLine.param_values.count( name ) )
441 {
442 wxASSERT( cfg->m_TransLine.param_units.count( name ) );
443
444 for( auto& p : m_prms_List )
445 {
446 try
447 {
448 p->m_Value = cfg->m_TransLine.param_values.at( name ).at( p->m_KeyWord );
449 p->m_UnitSelection = cfg->m_TransLine.param_units.at( name ).at( p->m_KeyWord );
450 }
451 catch( ... )
452 {}
453 }
454 }
455}
456
457
459{
460 auto cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( Kiface().KifaceSettings() );
461 std::string name( m_TLine->m_Name );
462
463 for( auto& param : m_prms_List )
464 {
465 if( !std::isfinite( param->m_Value ) )
466 param->m_Value = 0;
467
468 cfg->m_TransLine.param_values[ name ][ param->m_KeyWord ] = param->m_Value;
469 cfg->m_TransLine.param_units[ name ][ param->m_KeyWord ] = param->m_UnitSelection;
470 }
471}
472
const char * name
Definition: DXF_plotter.cpp:57
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.
double m_DefaultValue
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)
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