KiCad PCB EDA Suite
twistedpair.cpp
Go to the documentation of this file.
1/*
2 * twistedpair.h - twisted pair class definition
3 *
4 * Copyright (C) 2011 Michael Margraf <[email protected]>
5 * Modifications 2011 for Kicad: Jean-Pierre Charras
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this package; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 */
23
24
25#include <cmath>
26#include <cstdio>
27#include <cstdlib>
28#include <cstring>
29
30#include "twistedpair.h"
31#include "units.h"
32
34{
35 m_Name = "TwistedPair";
36 Init();
37}
38
39
69{
70
71 double tw = atan( m_parameters[TWISTEDPAIR_TWIST_PRM] * M_PI
72 * m_parameters[PHYS_DIAM_OUT_PRM] ); // pitch angle
73
76 + ( 0.25 + 0.0007 * tw * tw )
78
80 ZF0 / M_PI / sqrt( m_parameters[EPSILON_EFF_PRM] )
82
87
88 m_parameters[LOSS_DIELECTRIC_PRM] = 20.0 / log( 10.0 ) * m_parameters[PHYS_LEN_PRM] * M_PI / C0
92
95 / C0; // in radians
96}
97
98
99// -------------------------------------------------------------------
101{
106}
107
109{
112
113 // Check for errors
114 if( !std::isfinite( m_parameters[Z0_PRM] ) || m_parameters[Z0_PRM] < 0 )
116
117 if( !std::isfinite( m_parameters[ANG_L_PRM] ) || m_parameters[ANG_L_PRM] < 0 )
119
120 // Find warnings to display - physical parameters
121 if( !std::isfinite( m_parameters[PHYS_DIAM_IN_PRM] ) || m_parameters[PHYS_DIAM_IN_PRM] <= 0.0 )
123
124 if( !std::isfinite( m_parameters[PHYS_DIAM_OUT_PRM] )
126 {
128 }
129
131 {
134 }
135
136 if( !std::isfinite( m_parameters[PHYS_LEN_PRM] ) || m_parameters[PHYS_LEN_PRM] < 0.0 )
138}
139
141{
144 else if( isSelected( PHYS_DIAM_OUT_PRM ) )
146
148
149 // Check for errors
150 if( !std::isfinite( m_parameters[PHYS_DIAM_IN_PRM] ) || m_parameters[PHYS_DIAM_IN_PRM] <= 0.0 )
151 {
154 else
156 }
157
158 if( !std::isfinite( m_parameters[PHYS_DIAM_OUT_PRM] )
160 {
163 else
165 }
166
168 {
171 else if( isSelected( PHYS_DIAM_OUT_PRM ) )
173 }
174
175 if( !std::isfinite( m_parameters[PHYS_LEN_PRM] ) || m_parameters[PHYS_LEN_PRM] < 0.0 )
177
178 // Check for warnings
179 if( !std::isfinite( m_parameters[Z0_PRM] ) || m_parameters[Z0_PRM] < 0 )
181
182 if( !std::isfinite( m_parameters[ANG_L_PRM] ) || m_parameters[ANG_L_PRM] < 0 )
184}
185
186
187#define MAX_ERROR 0.000001
188
189// -------------------------------------------------------------------
191{
194 else
196}
bool isSelected(enum PRMS_ID aPrmId)
Definition: transline.cpp:119
void Init()
Definition: transline.cpp:90
void setResult(int, double, const char *)
Definition: transline.cpp:133
bool minimizeZ0Error1D(double *)
@function minimizeZ0Error1D
Definition: transline.cpp:349
double m_parameters[EXTRA_PRMS_COUNT]
Definition: transline.h:131
const char * m_Name
Definition: transline.h:84
void setProperty(enum PRMS_ID aPrmId, double aValue)
Definition: transline.cpp:109
void setErrorLevel(PRMS_ID, char)
@function setErrorLevel
Definition: transline.cpp:435
void showAnalyze() override
Shows synthesis results and checks for errors / warnings.
void showSynthesize() override
Shows analysis results and checks for errors / warnings.
void show_results() override
Shows results.
void calcSynthesize() override
Computation for synthesis.
void calcAnalyze() override
Definition: twistedpair.cpp:68
@ LOSS_DIELECTRIC_PRM
Definition: transline.h:71
@ EPSILON_EFF_PRM
Definition: transline.h:74
@ LOSS_CONDUCTOR_PRM
Definition: transline.h:72
@ SIGMA_PRM
Definition: transline.h:69
@ SKIN_DEPTH_PRM
Definition: transline.h:70
@ TWISTEDPAIR_EPSILONR_ENV_PRM
Definition: transline.h:49
@ FREQUENCY_PRM
Definition: transline.h:51
@ PHYS_DIAM_OUT_PRM
Definition: transline.h:59
@ 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
@ TWISTEDPAIR_TWIST_PRM
Definition: transline.h:43
@ PHYS_DIAM_IN_PRM
Definition: transline.h:57
@ EPSILONR_PRM
Definition: transline.h:39
#define TRANSLINE_WARNING
Definition: transline.h:30
#define TRANSLINE_ERROR
Definition: transline.h:31
#define ZF0
Definition: units.h:62
#define C0
Definition: units.h:61
double acosh(double x)
Definition: units.h:40
#define UNIT_MICRON
Definition: units_scales.h:35