← Back to team overview

kicad-developers team mailing list archive

[Patch] Pcb Calculator: Convert tracks width versus current formula

 

Hi Jean-Pierre,

This came from discussion on bug 1818998. I hope that this patch will work correctly.

I will also look at eeschema/dialogs/dialog_bom_help.html

Jakub

>From 5c8995a9721963d01997ac85e9df128bfab0caac Mon Sep 17 00:00:00 2001
From: Jakub Kozdon <fldrivers@xxxxxxxxx>
Date: Fri, 4 Oct 2019 17:05:50 +0200
Subject: [PATCH] Pcb Calculator: Convert tracks width versus current formula
 to markdown.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.11.0"

This is a multi-part message in MIME format.
--------------2.11.0
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 .gitignore                                         |  1 +
 pcb_calculator/CMakeLists.txt                      |  2 ++
 pcb_calculator/tracks_width_versus_current.cpp     | 36 ++++++++--------------
 .../tracks_width_versus_current_formula.md         | 15 +++++++++
 4 files changed, 30 insertions(+), 24 deletions(-)
 create mode 100644 pcb_calculator/tracks_width_versus_current_formula.md


--------------2.11.0
Content-Type: text/x-patch; name="0001-Pcb-Calculator-Convert-tracks-width-versus-current-f.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-Pcb-Calculator-Convert-tracks-width-versus-current-f.patch"

diff --git a/.gitignore b/.gitignore
index 7a4c04491..682c35f2f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,7 @@ pcb_calculator/attenuators/bridget_tee_formula.h
 pcb_calculator/attenuators/pi_formula.h
 pcb_calculator/attenuators/splitter_formula.h
 pcb_calculator/attenuators/tee_formula.h
+pcb_calculator/tracks_width_versus_current_formula.h
 Makefile
 CMakeCache.txt
 auto_renamed_to_cpp
diff --git a/pcb_calculator/CMakeLists.txt b/pcb_calculator/CMakeLists.txt
index 76dfba056..34b0d432c 100644
--- a/pcb_calculator/CMakeLists.txt
+++ b/pcb_calculator/CMakeLists.txt
@@ -191,12 +191,14 @@ endfunction()
     md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/splitter_formula )
     md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/pi_formula )
     md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/tee_formula )
+    md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/tracks_width_versus_current_formula )
 
 set( DOCS_LIST
         ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/pi_formula.h
         ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/tee_formula.h
         ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/bridget_tee_formula.h
         ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/splitter_formula.h
+        ${CMAKE_CURRENT_SOURCE_DIR}/tracks_width_versus_current_formula.h
     )
 
 set_source_files_properties( attenuators/attenuator_classes.cpp
diff --git a/pcb_calculator/tracks_width_versus_current.cpp b/pcb_calculator/tracks_width_versus_current.cpp
index f77683e17..859e91c08 100644
--- a/pcb_calculator/tracks_width_versus_current.cpp
+++ b/pcb_calculator/tracks_width_versus_current.cpp
@@ -28,6 +28,7 @@
 #include <cmath>
 #include <wx/wx.h>
 #include <wx/config.h>
+#include <dialog_helpers.h>
 
 #include <pcb_calculator_frame_base.h>
 
@@ -35,6 +36,9 @@
 #include <UnitSelector.h>
 #include <units_scales.h>
 
+wxString tracks_width_versus_current_formula =
+#include <tracks_width_versus_current_formula.h>
+
 extern double DoubleFromString( const wxString& TextValue );
 
 // Key words to read/write some parameters in config:
@@ -440,30 +444,14 @@ void PCB_CALCULATOR_FRAME::TW_Init( wxConfigBase* aCfg )
     aCfg->Read( KEYWORD_TW_INTTRACK_THICKNESS_UNIT, &tmp, 0 );
     m_IntTrackThicknessUnit->SetSelection( tmp );
 
-    // Init formulas text
-    msg = "<br>";
-    msg << _( "If you specify the maximum current, then the trace "
-              "widths will be calculated to suit." )
-        << "<br>" << _( "If you specify one of the trace widths, the maximum "
-                        "current it can handle will be calculated. The width "
-                        "for the other trace to also handle this current will "
-                        "then be calculated." )
-        << "<br>" << _( "The controlling value is shown in bold." ) << "<br><br>"
-        <<  _( "The calculations are valid for currents up to 35A "
-               "(external) or 17.5A (internal), temperature rises "
-               "up to 100 deg C, and widths of up to 400mil (10mm)." )<< "<br>"
-        << _( "The formula, from IPC 2221, is" )
-        << "<center><b>I = K * dT<sup>0.44</sup> * (W*H)<sup>0.725</sup></b></center>"
-        << _( "where:" ) << "<br><b>I</b> = "
-        << _( "maximum current in amps" )
-        << "<br><b>dT</b> = "
-        << _( "temperature rise above ambient in deg C" )
-        << "<br><b>W,H</b> = "
-        << _( "width and thickness in mils" ) << "<br>"
-        << "<b>K</b> = "
-        << _( "0.024 for internal traces or 0.048 for external traces" );
-
-    m_htmlWinFormulas->AppendToPage( msg );
+    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 );
+    }
 
     // Make sure the correct master mode is displayed.
     TWUpdateModeDisplay();
diff --git a/pcb_calculator/tracks_width_versus_current_formula.md b/pcb_calculator/tracks_width_versus_current_formula.md
new file mode 100644
index 000000000..3578d7cd5
--- /dev/null
+++ b/pcb_calculator/tracks_width_versus_current_formula.md
@@ -0,0 +1,15 @@
+If you specify the maximum current, then the trace widths will be calculated to suit.
+
+If you specify one of the trace widths, the maximum current it can handle will be calculated. The width for the other trace to also handle this current will then be calculated.
+
+The controlling value is shown in bold.
+
+The calculations are valid for currents up to 35A (external) or 17.5A (internal), temperature rises up to 100 deg C, and widths of up to 400mil (10mm).
+
+The formula, from IPC 2221, is
+<center>__I = K * dT<sup>0.44</sup> * (W*H)<sup>0.725</sup>__</center>
+where:  
+__I__ = maximum current in amps  
+__dt__ = temperature rise above ambient in deg C  
+__W,H__ = width and thickness in mils  
+__K__ = 0.024 for internal traces or 0.048 for external traces

--------------2.11.0--



Follow ups