2019-04-10 10:24:52 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
2021-02-27 15:48:09 +00:00
|
|
|
* Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors.
|
2019-04-10 10:24:52 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
2019-05-01 18:57:59 +00:00
|
|
|
* as published by the Free Software Foundation; either version 3
|
2019-04-10 10:24:52 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2019-05-01 18:57:59 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2019-04-10 10:24:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* All calculations are based on this [1] online calculator:
|
|
|
|
*
|
|
|
|
* References:
|
|
|
|
*
|
|
|
|
* [1]: The CircuitCalculator.com Blog - PCB Via Calculator
|
|
|
|
* http://circuitcalculator.com/wordpress/2006/03/12/pcb-via-calculator/
|
|
|
|
*
|
|
|
|
* [2]: Constructing Your Power Supply - Layout Considerations
|
|
|
|
* https://www.ti.com/seclit/ml/slup230/slup230.pdf
|
|
|
|
*
|
|
|
|
* [3]: Current Carrying Capacity of Vias - Some Conceptual Observations
|
|
|
|
* https://www.ultracad.com/articles/viacurrents.pdf
|
|
|
|
*
|
|
|
|
* [4]: IPC-2221A - Generic Standard on Printed Board Design
|
|
|
|
* http://www.sphere.bc.ca/class/downloads/ipc_2221a-pcb%20standards.pdf
|
|
|
|
*
|
|
|
|
* [5]: Copper - online catalogue source - Goodfellow
|
|
|
|
* http://www.goodfellow.com/E/Copper.html
|
|
|
|
*
|
|
|
|
* [6]: Thermal Conductivity of Metals, Metallic Elements and Alloys
|
|
|
|
* https://www.engineeringtoolbox.com/thermal-conductivity-metals-d_858.html
|
|
|
|
*
|
|
|
|
* [7]: Johnson & Graham, High Speed Digital Design: A Handbook of Black Magic
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cmath>
|
2021-06-07 22:26:55 +00:00
|
|
|
#include <wx/choicdlg.h>
|
2019-04-10 10:24:52 +00:00
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
//#include <kiface_base.h>
|
|
|
|
#include <bitmaps.h>
|
2019-04-10 10:24:52 +00:00
|
|
|
|
2020-10-13 01:01:25 +00:00
|
|
|
#include "attenuators/attenuator_classes.h"
|
|
|
|
#include "common_data.h"
|
2021-10-04 14:13:46 +00:00
|
|
|
//#include "pcb_calculator_frame.h"
|
2020-10-13 01:01:25 +00:00
|
|
|
#include "pcb_calculator_settings.h"
|
|
|
|
#include "units_scales.h"
|
2021-10-04 14:13:46 +00:00
|
|
|
#include "panel_via_size.h"
|
2019-05-01 18:57:59 +00:00
|
|
|
|
2019-04-10 10:24:52 +00:00
|
|
|
extern double DoubleFromString( const wxString& TextValue );
|
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
|
|
|
|
PANEL_VIA_SIZE::PANEL_VIA_SIZE( wxWindow* parent, wxWindowID id,
|
|
|
|
const wxPoint& pos, const wxSize& size,
|
|
|
|
long style, const wxString& name ) :
|
|
|
|
PANEL_VIA_SIZE_BASE( parent, id, pos, size, style, name )
|
2019-04-10 10:24:52 +00:00
|
|
|
{
|
2021-10-04 14:13:46 +00:00
|
|
|
m_viaResistivityUnits->SetLabel( wxT( "Ω•m" ) );
|
|
|
|
m_viaTempUnits->SetLabel( wxT( "°C" ) );
|
|
|
|
m_viaResUnits->SetLabel( wxT( "Ω" ) );
|
|
|
|
m_viaThermalResUnits->SetLabel( wxT( "°C/W" ) );
|
|
|
|
m_viaReactanceUnits->SetLabel( wxT( "Ω" ) );
|
|
|
|
|
|
|
|
m_viaBitmap->SetBitmap( KiBitmap( BITMAPS::viacalc ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PANEL_VIA_SIZE::~PANEL_VIA_SIZE()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_VIA_SIZE::OnViaEpsilonR_Button( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
//Shows a list of current relative dielectric constant(Er) and select a value.
|
2019-05-01 18:57:59 +00:00
|
|
|
wxArrayString list = StandardRelativeDielectricConstantList();
|
2019-04-10 10:24:52 +00:00
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
wxString value = wxGetSingleChoice( wxEmptyString, _("Relative Dielectric Constants"),
|
|
|
|
list).BeforeFirst( ' ' );
|
|
|
|
|
2019-04-10 10:24:52 +00:00
|
|
|
if( ! value.IsEmpty() )
|
|
|
|
m_textCtrlPlatingPermittivity->SetValue( value );
|
|
|
|
}
|
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
|
|
|
|
void PANEL_VIA_SIZE::OnViaRho_Button( wxCommandEvent& event )
|
2019-04-10 10:24:52 +00:00
|
|
|
{
|
2019-05-01 18:57:59 +00:00
|
|
|
wxArrayString list = StandardResistivityList();
|
2019-04-10 10:24:52 +00:00
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
// Shows a list of current Specific resistance list (rho) and select a value
|
2019-04-10 10:24:52 +00:00
|
|
|
wxString value = wxGetSingleChoice( wxEmptyString,
|
2019-09-20 16:14:52 +00:00
|
|
|
_("Electrical Resistivity in Ohm*m"), list).BeforeFirst( ' ' );
|
2021-10-04 14:13:46 +00:00
|
|
|
|
2019-04-10 10:24:52 +00:00
|
|
|
if( ! value.IsEmpty() )
|
|
|
|
m_textCtrlPlatingResistivity->SetValue( value );
|
|
|
|
}
|
|
|
|
|
2019-09-20 16:14:52 +00:00
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
void PANEL_VIA_SIZE::onUpdateViaCalcErrorText( wxUpdateUIEvent& event )
|
2019-09-20 16:14:52 +00:00
|
|
|
{
|
|
|
|
// Update the Error message if a via has a external diameter
|
|
|
|
// bigger than the clearance area diameter
|
2019-11-10 09:36:26 +00:00
|
|
|
// (therefore the via is inside a copper zone and some parameters cannot be calculated)
|
2019-09-20 16:14:52 +00:00
|
|
|
double clearanceDia = std::abs( DoubleFromString( m_textCtrlClearanceDia->GetValue() ) );
|
|
|
|
clearanceDia *= m_choiceClearanceDia->GetUnitScale();
|
|
|
|
double padDia = std::abs( DoubleFromString( m_textCtrlViaPadDia->GetValue() ) );
|
|
|
|
padDia *= m_choiceViaPadDia->GetUnitScale();
|
|
|
|
|
|
|
|
m_staticTextWarning->Show( clearanceDia <= padDia );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
void PANEL_VIA_SIZE::OnViaResetButtonClick( wxCommandEvent& event )
|
2019-11-10 09:36:26 +00:00
|
|
|
{
|
|
|
|
#define DEFAULT_UNIT_SEL_MM 0
|
2021-02-27 15:48:09 +00:00
|
|
|
#define DEFAULT_UNIT_SEL_OHM 0
|
2019-11-10 09:36:26 +00:00
|
|
|
|
2021-02-27 15:48:09 +00:00
|
|
|
m_textCtrlHoleDia->SetValue( wxString::Format( "%g", 0.4 ) );
|
2019-11-10 09:36:26 +00:00
|
|
|
m_choiceHoleDia->SetSelection( DEFAULT_UNIT_SEL_MM );
|
2021-02-27 15:48:09 +00:00
|
|
|
m_textCtrlPlatingThickness->SetValue( wxString::Format( "%g", 0.035 ) );
|
2019-11-10 09:36:26 +00:00
|
|
|
m_choicePlatingThickness->SetSelection( DEFAULT_UNIT_SEL_MM );
|
2021-02-27 15:48:09 +00:00
|
|
|
m_textCtrlViaLength->SetValue( wxString::Format( "%g", 1.6 ) );
|
2019-11-10 09:36:26 +00:00
|
|
|
m_choiceViaLength->SetSelection( DEFAULT_UNIT_SEL_MM );
|
2021-02-27 15:48:09 +00:00
|
|
|
m_textCtrlViaPadDia->SetValue( wxString::Format( "%g", 0.6 ) );
|
2019-11-10 09:36:26 +00:00
|
|
|
m_choiceViaPadDia->SetSelection( DEFAULT_UNIT_SEL_MM );
|
2021-02-27 15:48:09 +00:00
|
|
|
m_textCtrlClearanceDia->SetValue( wxString::Format( "%g", 1.0 ) );
|
2019-11-10 09:36:26 +00:00
|
|
|
m_choiceClearanceDia->SetSelection( DEFAULT_UNIT_SEL_MM );
|
2021-02-27 15:48:09 +00:00
|
|
|
m_textCtrlImpedance->SetValue( wxString::Format( "%g", 50.0 ) );
|
|
|
|
m_choiceImpedance->SetSelection( DEFAULT_UNIT_SEL_OHM );
|
|
|
|
m_textCtrlAppliedCurrent->SetValue( wxString::Format( "%g", 1.0 ) );
|
|
|
|
m_textCtrlPlatingResistivity->SetValue( wxString::Format( "%g", 1.72e-8 ) );
|
|
|
|
m_textCtrlPlatingPermittivity->SetValue( wxString::Format( "%g", 4.5 ) );
|
|
|
|
m_textCtrlTemperatureDiff->SetValue( wxString::Format( "%g", 10.0 ) );
|
|
|
|
m_textCtrlRiseTime->SetValue( wxString::Format( "%g", 1.0 ) );
|
2019-11-10 09:36:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
void PANEL_VIA_SIZE::LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg )
|
2019-04-10 10:24:52 +00:00
|
|
|
{
|
2021-10-04 14:13:46 +00:00
|
|
|
m_textCtrlHoleDia->SetValue( aCfg->m_ViaSize.hole_diameter );
|
|
|
|
m_choiceHoleDia->SetSelection( aCfg->m_ViaSize.hole_diameter_units );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
m_textCtrlPlatingThickness->SetValue( aCfg->m_ViaSize.thickness );
|
|
|
|
m_choicePlatingThickness->SetSelection( aCfg->m_ViaSize.thickness_units );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
m_textCtrlViaLength->SetValue( aCfg->m_ViaSize.length );
|
|
|
|
m_choiceViaLength->SetSelection( aCfg->m_ViaSize.length_units );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
m_textCtrlViaPadDia->SetValue( aCfg->m_ViaSize.pad_diameter );
|
|
|
|
m_choiceViaPadDia->SetSelection( aCfg->m_ViaSize.pad_diameter_units );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
m_textCtrlClearanceDia->SetValue( aCfg->m_ViaSize.clearance_diameter );
|
|
|
|
m_choiceClearanceDia->SetSelection( aCfg->m_ViaSize.clearance_diameter_units );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
m_textCtrlImpedance->SetValue( aCfg->m_ViaSize.characteristic_impedance );
|
|
|
|
m_choiceImpedance->SetSelection( aCfg->m_ViaSize.characteristic_impedance_units );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
m_textCtrlAppliedCurrent->SetValue( aCfg->m_ViaSize.applied_current );
|
|
|
|
m_textCtrlPlatingResistivity->SetValue( aCfg->m_ViaSize.plating_resistivity );
|
|
|
|
m_textCtrlPlatingPermittivity->SetValue( aCfg->m_ViaSize.permittivity );
|
|
|
|
m_textCtrlTemperatureDiff->SetValue( aCfg->m_ViaSize.temp_rise );
|
|
|
|
m_textCtrlRiseTime->SetValue( aCfg->m_ViaSize.pulse_rise_time );
|
2019-04-10 10:24:52 +00:00
|
|
|
}
|
|
|
|
|
2021-02-12 00:47:08 +00:00
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
void PANEL_VIA_SIZE::SaveSettings( PCB_CALCULATOR_SETTINGS* aCfg )
|
2019-04-10 10:24:52 +00:00
|
|
|
{
|
2021-10-04 14:13:46 +00:00
|
|
|
aCfg->m_ViaSize.hole_diameter = m_textCtrlHoleDia->GetValue();
|
|
|
|
aCfg->m_ViaSize.hole_diameter_units = m_choiceHoleDia->GetSelection();
|
|
|
|
aCfg->m_ViaSize.thickness = m_textCtrlPlatingThickness->GetValue();
|
|
|
|
aCfg->m_ViaSize.thickness_units = m_choicePlatingThickness->GetSelection();
|
|
|
|
aCfg->m_ViaSize.length = m_textCtrlViaLength->GetValue();
|
|
|
|
aCfg->m_ViaSize.length_units = m_choiceViaLength->GetSelection();
|
|
|
|
aCfg->m_ViaSize.pad_diameter = m_textCtrlViaPadDia->GetValue();
|
|
|
|
aCfg->m_ViaSize.pad_diameter_units = m_choiceViaPadDia->GetSelection();
|
|
|
|
aCfg->m_ViaSize.clearance_diameter = m_textCtrlClearanceDia->GetValue();
|
|
|
|
aCfg->m_ViaSize.clearance_diameter_units = m_choiceClearanceDia->GetSelection();
|
|
|
|
aCfg->m_ViaSize.characteristic_impedance = m_textCtrlImpedance->GetValue();
|
|
|
|
aCfg->m_ViaSize.characteristic_impedance_units = m_choiceImpedance->GetSelection();
|
|
|
|
aCfg->m_ViaSize.applied_current = m_textCtrlAppliedCurrent->GetValue();
|
|
|
|
aCfg->m_ViaSize.plating_resistivity = m_textCtrlPlatingResistivity->GetValue();
|
|
|
|
aCfg->m_ViaSize.permittivity = m_textCtrlPlatingPermittivity->GetValue();
|
|
|
|
aCfg->m_ViaSize.temp_rise = m_textCtrlTemperatureDiff->GetValue();
|
|
|
|
aCfg->m_ViaSize.pulse_rise_time = m_textCtrlRiseTime->GetValue();
|
2019-04-10 10:24:52 +00:00
|
|
|
}
|
|
|
|
|
2021-02-12 00:47:08 +00:00
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
void PANEL_VIA_SIZE::OnViaCalculate( wxCommandEvent& event )
|
2019-04-10 10:24:52 +00:00
|
|
|
{
|
|
|
|
// Load parameters
|
|
|
|
double finishedHoleDia = std::abs( DoubleFromString( m_textCtrlHoleDia->GetValue() ) );
|
|
|
|
double platingThickness = std::abs( DoubleFromString( m_textCtrlPlatingThickness->GetValue() ) );
|
|
|
|
double viaLength = std::abs( DoubleFromString( m_textCtrlViaLength->GetValue() ) );
|
|
|
|
double padDia = std::abs( DoubleFromString( m_textCtrlViaPadDia->GetValue() ) );
|
|
|
|
double clearanceDia = std::abs( DoubleFromString( m_textCtrlClearanceDia->GetValue() ) );
|
|
|
|
double charImpedance = std::abs( DoubleFromString( m_textCtrlImpedance->GetValue() ) );
|
|
|
|
double appliedCurrent = std::abs( DoubleFromString( m_textCtrlAppliedCurrent->GetValue() ) );
|
|
|
|
double platingResistivity = std::abs( DoubleFromString( m_textCtrlPlatingResistivity->GetValue() ) );
|
|
|
|
double relativePermitivity = std::abs( DoubleFromString( m_textCtrlPlatingPermittivity->GetValue() ) );
|
|
|
|
double temperatureDiff = std::abs( DoubleFromString( m_textCtrlTemperatureDiff->GetValue() ) );
|
|
|
|
double pulseRiseTime = std::abs( DoubleFromString( m_textCtrlRiseTime->GetValue() ) );
|
|
|
|
|
|
|
|
// Normalize units
|
|
|
|
finishedHoleDia *= m_choiceHoleDia->GetUnitScale();
|
|
|
|
platingThickness *= m_choicePlatingThickness->GetUnitScale();
|
|
|
|
viaLength *= m_choiceViaLength->GetUnitScale();
|
|
|
|
padDia *= m_choiceViaPadDia->GetUnitScale();
|
|
|
|
clearanceDia *= m_choiceClearanceDia->GetUnitScale();
|
|
|
|
charImpedance *= m_choiceImpedance->GetUnitScale();
|
2019-09-20 16:14:52 +00:00
|
|
|
// platingResistivity is ok: it is in Ohm*m in tables
|
2019-04-10 10:24:52 +00:00
|
|
|
|
|
|
|
// Calculate cross-sectional area of the via's cylindrical structure [3]
|
|
|
|
double area = M_PI * (finishedHoleDia + platingThickness) * platingThickness; // m^2
|
|
|
|
|
|
|
|
double viaResistance = platingResistivity * viaLength / area; // Ohms
|
|
|
|
|
|
|
|
// Using thermal resistivity value 2.49e-3 meter-Kelvin/Watt, equivalent to
|
|
|
|
// thermal conductivity of 401 Watt/(meter-Kelvin) [5][6]
|
|
|
|
const double thermalResistivity = 2.49e-3; // m K/W
|
|
|
|
double thermalResistance = thermalResistivity * viaLength / area; // deg C/W
|
|
|
|
|
|
|
|
double voltageDrop = appliedCurrent * viaResistance;
|
|
|
|
|
|
|
|
double powerLoss = appliedCurrent * voltageDrop;
|
|
|
|
|
|
|
|
// Estimate current carrying capacity of the via
|
|
|
|
// See comment #17 in [1] for a brief discussion on the formula
|
|
|
|
// This formula from IPC-2221 [4] is also used in the Track Width calculator
|
|
|
|
area /= pow( UNIT_MIL, 2 ); // m^2 to mil^2
|
|
|
|
const double k = 0.048;
|
|
|
|
const double b = 0.44;
|
|
|
|
const double c = 0.725;
|
|
|
|
double estimatedAmpacity = k * pow( temperatureDiff, b ) * pow( area, c );
|
|
|
|
|
|
|
|
// Equation 7.6 in [7]
|
|
|
|
double capacitance = 55.51 * relativePermitivity * viaLength * padDia;
|
|
|
|
capacitance /= clearanceDia - padDia;
|
|
|
|
|
|
|
|
// Equation 7.8 in [7]
|
|
|
|
double timeDegradation = 2.2 * capacitance * charImpedance / 2;
|
|
|
|
|
|
|
|
// Equation 7.9 in [7]
|
|
|
|
double inductance = 200 * viaLength;
|
|
|
|
inductance *= log( 4 * viaLength / finishedHoleDia ) + 1;
|
|
|
|
|
|
|
|
// Equation 7.11 in [7]
|
|
|
|
double reactance = M_PI * inductance / pulseRiseTime;
|
|
|
|
|
|
|
|
// Update the display
|
|
|
|
VSDisplayValues( viaResistance, voltageDrop, powerLoss, estimatedAmpacity,
|
|
|
|
thermalResistance, capacitance, timeDegradation, inductance, reactance );
|
|
|
|
}
|
|
|
|
|
2021-10-04 14:13:46 +00:00
|
|
|
void PANEL_VIA_SIZE::VSDisplayValues( double aViaResistance, double aVoltageDrop,
|
2019-04-10 10:24:52 +00:00
|
|
|
double aPowerLoss, double aEstimatedAmpacity, double aThermalResistance,
|
|
|
|
double aCapacitance, double aTimeDegradation, double aInductance, double aReactance )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
2019-05-01 18:57:59 +00:00
|
|
|
msg.Printf( "%g", aViaResistance );
|
2019-04-10 10:24:52 +00:00
|
|
|
m_ViaResistance->SetLabel( msg );
|
|
|
|
|
2019-05-01 18:57:59 +00:00
|
|
|
msg.Printf( "%g", aVoltageDrop );
|
2019-04-10 10:24:52 +00:00
|
|
|
m_ViaVoltageDrop->SetLabel( msg );
|
|
|
|
|
2019-05-01 18:57:59 +00:00
|
|
|
msg.Printf( "%g", aPowerLoss );
|
2019-04-10 10:24:52 +00:00
|
|
|
m_ViaPowerLoss->SetLabel( msg );
|
|
|
|
|
2019-05-01 18:57:59 +00:00
|
|
|
msg.Printf( "%g", aEstimatedAmpacity );
|
2019-04-10 10:24:52 +00:00
|
|
|
m_ViaAmpacity->SetLabel( msg );
|
|
|
|
|
2019-05-01 18:57:59 +00:00
|
|
|
msg.Printf( "%g", aThermalResistance );
|
2019-04-10 10:24:52 +00:00
|
|
|
m_ViaThermalResistance->SetLabel( msg );
|
|
|
|
|
2019-05-01 18:57:59 +00:00
|
|
|
msg.Printf( "%g", aCapacitance );
|
2019-04-10 10:24:52 +00:00
|
|
|
m_ViaCapacitance->SetLabel( msg );
|
|
|
|
|
2019-05-01 18:57:59 +00:00
|
|
|
msg.Printf( "%g", aTimeDegradation );
|
2019-04-10 10:24:52 +00:00
|
|
|
m_RiseTimeOutput->SetLabel( msg );
|
|
|
|
|
2019-05-01 18:57:59 +00:00
|
|
|
msg.Printf( "%g", aInductance );
|
2019-04-10 10:24:52 +00:00
|
|
|
m_Inductance->SetLabel( msg );
|
|
|
|
|
2019-05-01 18:57:59 +00:00
|
|
|
msg.Printf( "%g", aReactance );
|
2019-04-10 10:24:52 +00:00
|
|
|
m_Reactance->SetLabel( msg );
|
|
|
|
}
|