Pcb Calculator: Via Calculator gives too low resistance values (100 times).

Fixes: lp:1844804
https://bugs.launchpad.net/kicad/+bug/1844804
This commit is contained in:
jean-pierre charras 2019-09-20 18:14:52 +02:00
parent 7355ed3bda
commit 130d52dd80
5 changed files with 114 additions and 5 deletions

View File

@ -623,7 +623,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow
m_staticTextAppliedCurrentUnits->Wrap( -1 );
fgSizerVS_Inputs->Add( m_staticTextAppliedCurrentUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_staticTextResistivity = new wxStaticText( sbSizerVS_Inputs->GetStaticBox(), wxID_ANY, _("Plating resistivity:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextResistivity = new wxStaticText( sbSizerVS_Inputs->GetStaticBox(), wxID_ANY, _("Plating resistivity (Ohm.m):"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextResistivity->Wrap( -1 );
m_staticTextResistivity->SetToolTip( _("Specific resistance in ohms * meters") );
@ -824,6 +824,15 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow
sbSizerVS_Result->Add( fgSizerTW_Results11, 0, wxEXPAND, 5 );
sbSizerVS_Result->Add( 30, 30, 0, 0, 5 );
m_staticTextWarning = new wxStaticText( sbSizerVS_Result->GetStaticBox(), wxID_ANY, _("Warning:\nVia pad diameter >= Clearance hole diameter.\nSome parameters cannot be calculated for a via\ninside a copper zone."), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextWarning->Wrap( -1 );
m_staticTextWarning->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
sbSizerVS_Result->Add( m_staticTextWarning, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
bSizerViaSize->Add( sbSizerVS_Result, 1, wxEXPAND|wxALL, 5 );
@ -1694,6 +1703,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow
m_button_Permittivity->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnViaEpsilonR_Button ), NULL, this );
m_textCtrlTemperatureDiff->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnViaCalculate ), NULL, this );
m_textCtrlRiseTime->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnViaCalculate ), NULL, this );
m_staticTextWarning->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PCB_CALCULATOR_FRAME_BASE::onUpdateViaCalcErrorText ), NULL, this );
m_ElectricalSpacingUnitsSelector->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnElectricalSpacingUnitsSelection ), NULL, this );
m_buttonElectSpacingRefresh->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnElectricalSpacingRefresh ), NULL, this );
m_TranslineSelection->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnTranslineSelection ), NULL, this );
@ -1756,6 +1766,7 @@ PCB_CALCULATOR_FRAME_BASE::~PCB_CALCULATOR_FRAME_BASE()
m_button_Permittivity->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnViaEpsilonR_Button ), NULL, this );
m_textCtrlTemperatureDiff->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnViaCalculate ), NULL, this );
m_textCtrlRiseTime->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnViaCalculate ), NULL, this );
m_staticTextWarning->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PCB_CALCULATOR_FRAME_BASE::onUpdateViaCalcErrorText ), NULL, this );
m_ElectricalSpacingUnitsSelector->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnElectricalSpacingUnitsSelection ), NULL, this );
m_buttonElectSpacingRefresh->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnElectricalSpacingRefresh ), NULL, this );
m_TranslineSelection->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnTranslineSelection ), NULL, this );

View File

@ -14,6 +14,7 @@
<property name="file">pcb_calculator_frame_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">pcb_calculator_frame_base</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Frame" expanded="1">
@ -3295,6 +3297,7 @@
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
@ -3306,6 +3309,7 @@
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
@ -7272,7 +7276,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Plating resistivity:</property>
<property name="label">Plating resistivity (Ohm.m):</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
@ -8144,7 +8148,7 @@
<property name="orient">wxVERTICAL</property>
<property name="parent">1</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
@ -9809,6 +9813,78 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag"></property>
<property name="proportion">0</property>
<object class="spacer" expanded="1">
<property name="height">30</property>
<property name="permission">protected</property>
<property name="width">30</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font">,90,92,-1,70,0</property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Warning:&#x0A;Via pad diameter &gt;= Clearance hole diameter.&#x0A;Some parameters cannot be calculated for a via&#x0A;inside a copper zone.</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticTextWarning</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnUpdateUI">onUpdateViaCalcErrorText</event>
</object>
</object>
</object>
</object>
</object>

View File

@ -208,6 +208,7 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER
wxStaticText* m_staticTextReactance;
wxStaticText* m_Reactance;
wxStaticText* m_staticTextReactanceUnits;
wxStaticText* m_staticTextWarning;
wxPanel* m_panelElectricalSpacing;
UNIT_SELECTOR_LEN* m_ElectricalSpacingUnitsSelector;
wxStaticLine* m_staticline2;
@ -355,6 +356,7 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER
virtual void OnViaCalculate( wxCommandEvent& event ) { event.Skip(); }
virtual void OnViaRho_Button( wxCommandEvent& event ) { event.Skip(); }
virtual void OnViaEpsilonR_Button( wxCommandEvent& event ) { event.Skip(); }
virtual void onUpdateViaCalcErrorText( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnElectricalSpacingUnitsSelection( wxCommandEvent& event ) { event.Skip(); }
virtual void OnElectricalSpacingRefresh( wxCommandEvent& event ) { event.Skip(); }
virtual void OnTranslineSelection( wxCommandEvent& event ) { event.Skip(); }

View File

@ -202,6 +202,11 @@ private:
*/
void OnViaRho_Button( wxCommandEvent& event ) override;
/**
* Update the Error message in Via calculation panel
*/
void onUpdateViaCalcErrorText( wxUpdateUIEvent& event ) override;
/**
* Function VSDisplayValues
* Displays the results of the calculation.

View File

@ -98,11 +98,26 @@ void PCB_CALCULATOR_FRAME::OnViaRho_Button( wxCommandEvent& event )
wxArrayString list = StandardResistivityList();
wxString value = wxGetSingleChoice( wxEmptyString,
_("Specific Resistance"), list).BeforeFirst( ' ' );
_("Electrical Resistivity in Ohm*m"), list).BeforeFirst( ' ' );
if( ! value.IsEmpty() )
m_textCtrlPlatingResistivity->SetValue( value );
}
void PCB_CALCULATOR_FRAME::onUpdateViaCalcErrorText( wxUpdateUIEvent& event )
{
// Update the Error message if a via has a external diameter
// bigger than the clearance area diameter
// (therefore the via is inside a copper zone and some parameters connot be calculated)
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 );
}
void PCB_CALCULATOR_FRAME::VS_Init( wxConfigBase* aCfg )
{
int tmp;
@ -196,7 +211,7 @@ void PCB_CALCULATOR_FRAME::OnViaCalculate( wxCommandEvent& event )
padDia *= m_choiceViaPadDia->GetUnitScale();
clearanceDia *= m_choiceClearanceDia->GetUnitScale();
charImpedance *= m_choiceImpedance->GetUnitScale();
platingResistivity = platingResistivity / 100; // Ohm-cm to Ohm-m
// platingResistivity is ok: it is in Ohm*m in tables
// Calculate cross-sectional area of the via's cylindrical structure [3]
double area = M_PI * (finishedHoleDia + platingThickness) * platingThickness; // m^2