2011-08-07 16:02:58 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 jean-pierre.charras
|
2019-05-01 18:57:59 +00:00
|
|
|
* Copyright (C) 1992-2015 Kicad Developers, see AUTHORS.txt for contributors.
|
2011-08-07 16:02:58 +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
|
2011-08-07 16:02:58 +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/>.
|
2011-08-07 16:02:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* see
|
|
|
|
* http://www.desmith.net/NMdS/Electronics/TraceWidth.html
|
|
|
|
* http://www.ultracad.com/articles/pcbtemp.pdf
|
|
|
|
* for more info
|
|
|
|
*/
|
|
|
|
|
2015-08-09 07:15:42 +00:00
|
|
|
#include <cassert>
|
2014-02-07 16:09:15 +00:00
|
|
|
#include <cmath>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <wx/wx.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <kiface_i.h>
|
|
|
|
#include <dialog_helpers.h>
|
2011-08-07 16:02:58 +00:00
|
|
|
|
2020-10-13 01:01:25 +00:00
|
|
|
#include "attenuators/attenuator_classes.h"
|
|
|
|
#include "class_regulator_data.h"
|
|
|
|
#include "pcb_calculator_frame.h"
|
|
|
|
#include "pcb_calculator_settings.h"
|
|
|
|
#include "units_scales.h"
|
2011-08-07 16:02:58 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
wxString tracks_width_versus_current_formula =
|
2020-10-13 01:01:25 +00:00
|
|
|
#include "tracks_width_versus_current_formula.h"
|
2020-01-13 01:44:19 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
extern double DoubleFromString( const wxString& TextValue );
|
2011-08-07 16:02:58 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2021-02-12 00:47:08 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::writeTrackWidthConfig()
|
2011-08-07 16:02:58 +00:00
|
|
|
{
|
2015-08-09 07:15:42 +00:00
|
|
|
// Save current parameters values in config.
|
2020-01-13 01:44:19 +00:00
|
|
|
auto cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( Kiface().KifaceSettings() );
|
|
|
|
|
|
|
|
cfg->m_TrackWidth.current = m_TrackCurrentValue->GetValue();
|
|
|
|
cfg->m_TrackWidth.delta_tc = m_TrackDeltaTValue->GetValue();
|
|
|
|
cfg->m_TrackWidth.track_len = m_TrackLengthValue->GetValue();
|
|
|
|
cfg->m_TrackWidth.track_len_units = m_TW_CuLength_choiceUnit->GetSelection();
|
|
|
|
cfg->m_TrackWidth.resistivity = m_TWResistivity->GetValue();
|
|
|
|
cfg->m_TrackWidth.ext_track_width = m_ExtTrackWidthValue->GetValue();
|
|
|
|
cfg->m_TrackWidth.ext_track_width_units = m_TW_ExtTrackWidth_choiceUnit->GetSelection();
|
|
|
|
cfg->m_TrackWidth.ext_track_thickness = m_ExtTrackThicknessValue->GetValue();
|
|
|
|
cfg->m_TrackWidth.ext_track_thickness_units = m_ExtTrackThicknessUnit->GetSelection();
|
|
|
|
cfg->m_TrackWidth.int_track_width = m_IntTrackWidthValue->GetValue();
|
|
|
|
cfg->m_TrackWidth.int_track_width_units = m_TW_IntTrackWidth_choiceUnit->GetSelection();
|
|
|
|
cfg->m_TrackWidth.int_track_thickness = m_IntTrackThicknessValue->GetValue();
|
|
|
|
cfg->m_TrackWidth.int_track_thickness_units = m_IntTrackThicknessUnit->GetSelection();
|
2011-08-07 16:02:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-09 07:15:42 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::OnTWParametersChanged( wxCommandEvent& event )
|
2011-08-07 16:02:58 +00:00
|
|
|
{
|
2015-08-09 07:15:42 +00:00
|
|
|
switch(m_TWMode)
|
|
|
|
{
|
|
|
|
case TW_MASTER_CURRENT:
|
|
|
|
OnTWCalculateFromCurrent( event );
|
|
|
|
break;
|
|
|
|
case TW_MASTER_EXT_WIDTH:
|
|
|
|
OnTWCalculateFromExtWidth( event );
|
|
|
|
break;
|
|
|
|
case TW_MASTER_INT_WIDTH:
|
|
|
|
OnTWCalculateFromIntWidth( event );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_CALCULATOR_FRAME::OnTWCalculateFromCurrent( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Setting the calculated values generates further events. Stop them.
|
|
|
|
if( m_TWNested )
|
|
|
|
{
|
|
|
|
event.StopPropagation();
|
|
|
|
return;
|
|
|
|
}
|
2015-08-09 15:04:49 +00:00
|
|
|
|
2015-08-09 07:15:42 +00:00
|
|
|
m_TWNested = true;
|
|
|
|
|
|
|
|
// Update state.
|
|
|
|
if( m_TWMode != TW_MASTER_CURRENT )
|
|
|
|
{
|
|
|
|
m_TWMode = TW_MASTER_CURRENT;
|
|
|
|
TWUpdateModeDisplay();
|
|
|
|
}
|
|
|
|
|
2011-08-07 16:02:58 +00:00
|
|
|
// Prepare parameters:
|
2015-08-09 07:15:42 +00:00
|
|
|
double current = std::abs( DoubleFromString( m_TrackCurrentValue->GetValue() ) );
|
|
|
|
double extThickness = std::abs( DoubleFromString( m_ExtTrackThicknessValue->GetValue() ) );
|
|
|
|
double intThickness = std::abs( DoubleFromString( m_IntTrackThicknessValue->GetValue() ) );
|
|
|
|
double deltaT_C = std::abs( DoubleFromString( m_TrackDeltaTValue->GetValue() ) );
|
2011-08-07 16:02:58 +00:00
|
|
|
|
2016-01-07 20:01:45 +00:00
|
|
|
// Normalize by units.
|
2015-08-09 07:15:42 +00:00
|
|
|
extThickness *= m_ExtTrackThicknessUnit->GetUnitScale();
|
|
|
|
intThickness *= m_IntTrackThicknessUnit->GetUnitScale();
|
2011-08-07 16:02:58 +00:00
|
|
|
|
2015-08-09 07:15:42 +00:00
|
|
|
// Calculate the widths.
|
2016-01-07 20:01:45 +00:00
|
|
|
double extTrackWidth = TWCalculateWidth( current, extThickness, deltaT_C, false );
|
|
|
|
double intTrackWidth = TWCalculateWidth( current, intThickness, deltaT_C, true );
|
2015-08-09 07:15:42 +00:00
|
|
|
|
|
|
|
// Update the display.
|
|
|
|
TWDisplayValues( current, extTrackWidth, intTrackWidth, extThickness, intThickness );
|
|
|
|
|
|
|
|
// Re-enable the events.
|
|
|
|
m_TWNested = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_CALCULATOR_FRAME::OnTWCalculateFromExtWidth( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Setting the calculated values generates further events. Stop them.
|
|
|
|
if( m_TWNested )
|
|
|
|
{
|
|
|
|
event.StopPropagation();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_TWNested = true;
|
|
|
|
|
|
|
|
// Update state.
|
|
|
|
if( m_TWMode != TW_MASTER_EXT_WIDTH )
|
|
|
|
{
|
|
|
|
m_TWMode = TW_MASTER_EXT_WIDTH;
|
|
|
|
TWUpdateModeDisplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load parameters.
|
|
|
|
double current;
|
|
|
|
double extThickness = std::abs( DoubleFromString( m_ExtTrackThicknessValue->GetValue() ) );
|
|
|
|
double intThickness = std::abs( DoubleFromString( m_IntTrackThicknessValue->GetValue() ) );
|
|
|
|
double deltaT_C = std::abs( DoubleFromString( m_TrackDeltaTValue->GetValue() ) );
|
|
|
|
double extTrackWidth = std::abs( DoubleFromString( m_ExtTrackWidthValue->GetValue() ) );
|
|
|
|
double intTrackWidth;
|
|
|
|
|
|
|
|
// Normalize units.
|
|
|
|
extThickness *= m_ExtTrackThicknessUnit->GetUnitScale();
|
|
|
|
intThickness *= m_IntTrackThicknessUnit->GetUnitScale();
|
|
|
|
extTrackWidth *= m_TW_ExtTrackWidth_choiceUnit->GetUnitScale();
|
|
|
|
|
|
|
|
// Calculate the maximum current.
|
|
|
|
current = TWCalculateCurrent( extTrackWidth, extThickness, deltaT_C, false );
|
|
|
|
|
|
|
|
// And now calculate the corresponding internal width.
|
|
|
|
intTrackWidth = TWCalculateWidth( current, intThickness, deltaT_C, true );
|
|
|
|
|
|
|
|
// Update the display.
|
|
|
|
TWDisplayValues( current, extTrackWidth, intTrackWidth, extThickness, intThickness );
|
|
|
|
|
|
|
|
// Re-enable the events.
|
|
|
|
m_TWNested = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_CALCULATOR_FRAME::OnTWCalculateFromIntWidth( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Setting the calculated values generates further events. Stop them.
|
|
|
|
if( m_TWNested )
|
|
|
|
{
|
|
|
|
event.StopPropagation();
|
|
|
|
return;
|
|
|
|
}
|
2015-08-09 15:04:49 +00:00
|
|
|
|
2015-08-09 07:15:42 +00:00
|
|
|
m_TWNested = true;
|
|
|
|
|
|
|
|
// Update state.
|
|
|
|
if( m_TWMode != TW_MASTER_INT_WIDTH )
|
|
|
|
{
|
|
|
|
m_TWMode = TW_MASTER_INT_WIDTH;
|
|
|
|
TWUpdateModeDisplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load parameters.
|
|
|
|
double current;
|
|
|
|
double extThickness = std::abs( DoubleFromString( m_ExtTrackThicknessValue->GetValue() ) );
|
|
|
|
double intThickness = std::abs( DoubleFromString( m_IntTrackThicknessValue->GetValue() ) );
|
|
|
|
double deltaT_C = std::abs( DoubleFromString( m_TrackDeltaTValue->GetValue() ) );
|
|
|
|
double extTrackWidth;
|
|
|
|
double intTrackWidth = std::abs( DoubleFromString( m_IntTrackWidthValue->GetValue() ) );
|
|
|
|
|
|
|
|
// Normalize units.
|
|
|
|
extThickness *= m_ExtTrackThicknessUnit->GetUnitScale();
|
|
|
|
intThickness *= m_IntTrackThicknessUnit->GetUnitScale();
|
|
|
|
intTrackWidth *= m_TW_IntTrackWidth_choiceUnit->GetUnitScale();
|
|
|
|
|
|
|
|
// Calculate the maximum current.
|
|
|
|
current = TWCalculateCurrent( intTrackWidth, intThickness, deltaT_C, true );
|
|
|
|
|
|
|
|
// And now calculate the corresponding external width.
|
|
|
|
extTrackWidth = TWCalculateWidth( current, extThickness, deltaT_C, false );
|
2011-08-07 16:02:58 +00:00
|
|
|
|
2015-08-09 07:15:42 +00:00
|
|
|
// Update the display.
|
|
|
|
TWDisplayValues( current, extTrackWidth, intTrackWidth, extThickness, intThickness );
|
2014-02-07 16:09:15 +00:00
|
|
|
|
2015-08-09 07:15:42 +00:00
|
|
|
// Re-enable the events.
|
|
|
|
m_TWNested = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-10 09:36:26 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::OnTWResetButtonClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
m_TrackCurrentValue->SetValue( wxT( "1.0" ) );
|
|
|
|
m_TrackDeltaTValue->SetValue( wxT( "10.0" ) );
|
|
|
|
m_TrackLengthValue->SetValue( wxT( "20" ) );
|
|
|
|
m_TW_CuLength_choiceUnit->SetSelection( 0 );
|
|
|
|
m_TWResistivity->SetValue( wxT( "1.72e-8" ) );
|
|
|
|
m_ExtTrackWidthValue->SetValue( wxT( "0.2" ) );
|
|
|
|
m_TW_ExtTrackWidth_choiceUnit->SetSelection( 0 );
|
|
|
|
m_ExtTrackThicknessValue->SetValue( wxT( "0.035" ) );
|
|
|
|
m_ExtTrackThicknessUnit->SetSelection( 0 );
|
|
|
|
m_IntTrackWidthValue->SetValue( wxT( "0.2" ) );
|
|
|
|
m_TW_IntTrackWidth_choiceUnit->SetSelection( 0 );
|
|
|
|
m_IntTrackThicknessValue->SetValue( wxT( "0.035" ) );
|
|
|
|
m_IntTrackThicknessUnit->SetSelection( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-09 07:15:42 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::TWDisplayValues( double aCurrent, double aExtWidth,
|
|
|
|
double aIntWidth, double aExtThickness, double aIntThickness )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
// Show the current.
|
|
|
|
if( m_TWMode != TW_MASTER_CURRENT )
|
|
|
|
{
|
|
|
|
msg.Printf( wxT( "%g" ), aCurrent );
|
|
|
|
m_TrackCurrentValue->SetValue( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load scale factors to convert into output units.
|
|
|
|
double extScale = m_TW_ExtTrackWidth_choiceUnit->GetUnitScale();
|
|
|
|
double intScale = m_TW_IntTrackWidth_choiceUnit->GetUnitScale();
|
|
|
|
|
|
|
|
// Display the widths.
|
|
|
|
if( m_TWMode != TW_MASTER_EXT_WIDTH )
|
|
|
|
{
|
|
|
|
msg.Printf( wxT( "%g" ), aExtWidth / extScale );
|
|
|
|
m_ExtTrackWidthValue->SetValue( msg );
|
|
|
|
}
|
2015-08-09 15:04:49 +00:00
|
|
|
|
2015-08-09 07:15:42 +00:00
|
|
|
if( m_TWMode != TW_MASTER_INT_WIDTH )
|
|
|
|
{
|
|
|
|
msg.Printf( wxT( "%g" ), aIntWidth / intScale );
|
|
|
|
m_IntTrackWidthValue->SetValue( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Display cross-sectional areas.
|
|
|
|
msg.Printf( wxT( "%g" ), (aExtWidth * aExtThickness) / (extScale * extScale) );
|
|
|
|
m_ExtTrackAreaValue->SetLabel( msg );
|
|
|
|
msg.Printf( wxT( "%g" ), (aIntWidth * aIntThickness) / (intScale * intScale) );
|
|
|
|
m_IntTrackAreaValue->SetLabel( msg );
|
|
|
|
|
|
|
|
// Show area units.
|
2011-08-07 16:02:58 +00:00
|
|
|
wxString strunit = m_TW_ExtTrackWidth_choiceUnit->GetUnitName();
|
2021-02-13 22:28:43 +00:00
|
|
|
msg = strunit + wxT( "²" );
|
|
|
|
m_extTrackAreaUnitLabel->SetLabel( msg );
|
2011-08-07 16:02:58 +00:00
|
|
|
strunit = m_TW_IntTrackWidth_choiceUnit->GetUnitName();
|
2021-02-13 22:28:43 +00:00
|
|
|
msg = strunit + wxT( "²" );
|
|
|
|
m_intTrackAreaUnitLabel->SetLabel( msg );
|
2011-08-07 16:02:58 +00:00
|
|
|
|
2015-08-09 07:15:42 +00:00
|
|
|
// Load resistivity and length of traces.
|
|
|
|
double rho = std::abs( DoubleFromString( m_TWResistivity->GetValue() ) );
|
|
|
|
double trackLen = std::abs( DoubleFromString( m_TrackLengthValue->GetValue() ) );
|
|
|
|
trackLen *= m_TW_CuLength_choiceUnit->GetUnitScale();
|
|
|
|
|
|
|
|
// Calculate resistance.
|
|
|
|
double extResistance = ( rho * trackLen ) / ( aExtWidth * aExtThickness );
|
|
|
|
double intResistance = ( rho * trackLen ) / ( aIntWidth * aIntThickness );
|
|
|
|
|
|
|
|
// Display resistance.
|
|
|
|
msg.Printf( wxT( "%g" ), extResistance );
|
|
|
|
m_ExtTrackResistValue->SetLabel( msg );
|
|
|
|
msg.Printf( wxT( "%g" ), intResistance );
|
|
|
|
m_IntTrackResistValue->SetLabel( msg );
|
|
|
|
|
|
|
|
// Display voltage drop along trace.
|
|
|
|
double extV = extResistance * aCurrent;
|
|
|
|
msg.Printf( wxT( "%g" ), extV );
|
|
|
|
m_ExtTrackVDropValue->SetLabel( msg );
|
|
|
|
double intV = intResistance * aCurrent;
|
|
|
|
msg.Printf( wxT( "%g" ), intV );
|
|
|
|
m_IntTrackVDropValue->SetLabel( msg );
|
|
|
|
|
|
|
|
// And power loss.
|
|
|
|
msg.Printf( wxT( "%g" ), extV * aCurrent );
|
|
|
|
m_ExtTrackLossValue->SetLabel( msg );
|
|
|
|
msg.Printf( wxT( "%g" ), intV * aCurrent );
|
|
|
|
m_IntTrackLossValue->SetLabel( msg );
|
2011-08-07 16:02:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-09 07:15:42 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::TWUpdateModeDisplay()
|
|
|
|
{
|
|
|
|
wxFont labelfont;
|
|
|
|
wxFont controlfont;
|
|
|
|
|
|
|
|
// Set the font weight of the current.
|
|
|
|
labelfont = m_staticTextCurrent->GetFont();
|
|
|
|
controlfont = m_TrackCurrentValue->GetFont();
|
|
|
|
|
|
|
|
if( m_TWMode == TW_MASTER_CURRENT )
|
|
|
|
{
|
|
|
|
labelfont.SetWeight( wxFONTWEIGHT_BOLD );
|
|
|
|
controlfont.SetWeight( wxFONTWEIGHT_BOLD );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
labelfont.SetWeight( wxFONTWEIGHT_NORMAL );
|
|
|
|
controlfont.SetWeight( wxFONTWEIGHT_NORMAL );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_staticTextCurrent->SetFont( labelfont );
|
|
|
|
m_TrackCurrentValue->SetFont( controlfont );
|
|
|
|
|
|
|
|
// Set the font weight of the external track width.
|
|
|
|
labelfont = m_staticTextExtWidth->GetFont();
|
|
|
|
controlfont = m_ExtTrackWidthValue->GetFont();
|
|
|
|
|
|
|
|
if( m_TWMode == TW_MASTER_EXT_WIDTH )
|
|
|
|
{
|
|
|
|
labelfont.SetWeight( wxFONTWEIGHT_BOLD );
|
|
|
|
controlfont.SetWeight( wxFONTWEIGHT_BOLD );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
labelfont.SetWeight( wxFONTWEIGHT_NORMAL );
|
|
|
|
controlfont.SetWeight( wxFONTWEIGHT_NORMAL );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_staticTextExtWidth->SetFont( labelfont );
|
|
|
|
m_ExtTrackWidthValue->SetFont( controlfont );
|
|
|
|
|
|
|
|
// Set the font weight of the internal track width.
|
|
|
|
labelfont = m_staticTextIntWidth->GetFont();
|
|
|
|
controlfont = m_IntTrackWidthValue->GetFont();
|
|
|
|
|
|
|
|
if( m_TWMode == TW_MASTER_INT_WIDTH )
|
|
|
|
{
|
|
|
|
labelfont.SetWeight( wxFONTWEIGHT_BOLD );
|
|
|
|
controlfont.SetWeight( wxFONTWEIGHT_BOLD );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
labelfont.SetWeight( wxFONTWEIGHT_NORMAL );
|
|
|
|
controlfont.SetWeight( wxFONTWEIGHT_NORMAL );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_staticTextIntWidth->SetFont( labelfont );
|
|
|
|
m_IntTrackWidthValue->SetFont( controlfont );
|
2016-01-07 20:01:45 +00:00
|
|
|
|
|
|
|
// Text sizes have changed when the font weight was changes
|
|
|
|
// So, run the page layout to reflect the changes
|
|
|
|
wxWindow* page = m_Notebook->GetPage ( 1 );
|
|
|
|
page->GetSizer()->Layout();
|
2015-08-09 07:15:42 +00:00
|
|
|
}
|
|
|
|
|
2011-08-07 16:02:58 +00:00
|
|
|
/* calculate track width for external or internal layers
|
|
|
|
*
|
|
|
|
* Imax = 0.048 * dT^0.44 * A^0.725 for external layer
|
|
|
|
* Imax = 0.024 * dT^0.44 * A^0.725 for internal layer
|
|
|
|
* with A = area = aThickness * trackWidth ( in mils )
|
|
|
|
* and dT = temperature rise in degree C
|
|
|
|
* Of course we want to know trackWidth
|
|
|
|
*/
|
2015-08-09 07:15:42 +00:00
|
|
|
double PCB_CALCULATOR_FRAME::TWCalculateWidth( double aCurrent, double aThickness, double aDeltaT_C,
|
2011-08-07 16:02:58 +00:00
|
|
|
bool aUseInternalLayer )
|
|
|
|
{
|
2015-08-09 07:15:42 +00:00
|
|
|
// Appropriate scale for requested layer.
|
|
|
|
double scale = aUseInternalLayer ? 0.024 : 0.048;
|
2011-08-07 16:02:58 +00:00
|
|
|
|
|
|
|
// aThickness is given in normalize units (in meters) and we need mil
|
|
|
|
aThickness /= UNIT_MIL;
|
|
|
|
|
|
|
|
/* formula is Imax = scale * dT^0.44 * A^0.725
|
|
|
|
* or
|
|
|
|
* log(Imax) = log(scale) + 0.44*log(dT)
|
|
|
|
* +(0.725*(log(aThickness) + log(trackWidth))
|
2015-08-09 07:15:42 +00:00
|
|
|
* log(trackWidth) * 0.725 = log(Imax) - log(scale) - 0.44*log(dT) - 0.725*log(aThickness)
|
2011-08-07 16:02:58 +00:00
|
|
|
*/
|
|
|
|
double dtmp = log( aCurrent ) - log( scale ) - 0.44 * log( aDeltaT_C ) - 0.725 * log( aThickness );
|
|
|
|
dtmp /= 0.725;
|
|
|
|
double trackWidth = exp( dtmp );
|
|
|
|
|
|
|
|
trackWidth *= UNIT_MIL; // We are using normalize units (sizes in meters) and we have mil
|
|
|
|
return trackWidth; // in meters
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-09 07:15:42 +00:00
|
|
|
double PCB_CALCULATOR_FRAME::TWCalculateCurrent( double aWidth, double aThickness, double aDeltaT_C,
|
|
|
|
bool aUseInternalLayer )
|
|
|
|
{
|
|
|
|
// Appropriate scale for requested layer.
|
|
|
|
double scale = aUseInternalLayer ? 0.024 : 0.048;
|
|
|
|
|
|
|
|
// Convert thickness and width to mils.
|
|
|
|
aThickness /= UNIT_MIL;
|
|
|
|
aWidth /= UNIT_MIL;
|
|
|
|
|
|
|
|
double area = aThickness * aWidth;
|
|
|
|
double current = scale * pow( aDeltaT_C, 0.44 ) * pow( area, 0.725 );
|
|
|
|
return current;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-12 00:47:08 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::initTrackWidthPanel()
|
2011-08-07 16:02:58 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
2015-08-09 07:15:42 +00:00
|
|
|
// Disable calculations while we initialise.
|
|
|
|
m_TWNested = true;
|
|
|
|
|
|
|
|
// Read parameter values.
|
2020-01-13 01:44:19 +00:00
|
|
|
auto cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( Kiface().KifaceSettings() );
|
2020-10-13 01:01:25 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_TrackCurrentValue->SetValue( cfg->m_TrackWidth.current );
|
|
|
|
m_TrackDeltaTValue->SetValue( cfg->m_TrackWidth.delta_tc );
|
|
|
|
m_TrackLengthValue->SetValue( cfg->m_TrackWidth.track_len );
|
|
|
|
m_TW_CuLength_choiceUnit->SetSelection( cfg->m_TrackWidth.track_len_units );
|
|
|
|
m_TWResistivity->SetValue( cfg->m_TrackWidth.resistivity );
|
|
|
|
m_ExtTrackWidthValue->SetValue( cfg->m_TrackWidth.ext_track_width );
|
|
|
|
m_TW_ExtTrackWidth_choiceUnit->SetSelection( cfg->m_TrackWidth.ext_track_width_units );
|
|
|
|
m_ExtTrackThicknessValue->SetValue( cfg->m_TrackWidth.ext_track_thickness );
|
|
|
|
m_ExtTrackThicknessUnit->SetSelection( cfg->m_TrackWidth.ext_track_thickness_units );
|
|
|
|
m_IntTrackWidthValue->SetValue( cfg->m_TrackWidth.int_track_width );
|
|
|
|
m_TW_IntTrackWidth_choiceUnit->SetSelection( cfg->m_TrackWidth.int_track_width_units );
|
|
|
|
m_IntTrackThicknessValue->SetValue( cfg->m_TrackWidth.int_track_thickness );
|
|
|
|
m_IntTrackThicknessUnit->SetSelection( cfg->m_TrackWidth.int_track_thickness_units );
|
|
|
|
|
|
|
|
if( tracks_width_versus_current_formula.StartsWith( "<!" ) )
|
|
|
|
m_htmlWinFormulas->SetPage( tracks_width_versus_current_formula );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxString html_txt;
|
|
|
|
ConvertMarkdown2Html( wxGetTranslation( tracks_width_versus_current_formula ), html_txt );
|
|
|
|
m_htmlWinFormulas->SetPage( html_txt );
|
|
|
|
}
|
2015-08-09 07:15:42 +00:00
|
|
|
|
|
|
|
// Make sure the correct master mode is displayed.
|
|
|
|
TWUpdateModeDisplay();
|
|
|
|
|
|
|
|
// Enable calculations and perform the initial one.
|
|
|
|
m_TWNested = false;
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
OnTWParametersChanged( dummy );
|
2011-08-07 16:02:58 +00:00
|
|
|
}
|