{"id":28282705,"url":"https://github.com/ymich9963/twc","last_synced_at":"2026-02-28T16:31:06.088Z","repository":{"id":255945120,"uuid":"851912449","full_name":"ymich9963/twc","owner":"ymich9963","description":"Trace Width Calculator to calculate the required trace width for PCB traces using IPC2221 and IPC2152.","archived":false,"fork":false,"pushed_at":"2025-08-29T14:41:12.000Z","size":1171,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-29T17:14:09.563Z","etag":null,"topics":["electronics","electronics-design","electronics-tools","pcb","pcb-design","pcb-layout","twc"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ymich9963.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-09-03T22:43:25.000Z","updated_at":"2025-08-29T14:41:16.000Z","dependencies_parsed_at":"2024-12-05T23:22:14.620Z","dependency_job_id":"bad54828-2b0e-4d41-9915-b3c2097fe3df","html_url":"https://github.com/ymich9963/twc","commit_stats":null,"previous_names":["ymich9963/electronics-tools-cli","ymich9963/twc"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/ymich9963/twc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymich9963%2Ftwc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymich9963%2Ftwc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymich9963%2Ftwc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymich9963%2Ftwc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ymich9963","download_url":"https://codeload.github.com/ymich9963/twc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymich9963%2Ftwc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29942789,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T13:49:17.081Z","status":"ssl_error","status_checked_at":"2026-02-28T13:48:50.396Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electronics","electronics-design","electronics-tools","pcb","pcb-design","pcb-layout","twc"],"created_at":"2025-05-21T15:19:46.246Z","updated_at":"2026-02-28T16:31:06.049Z","avatar_url":"https://github.com/ymich9963.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Trace Width Calculator (TWC)\n![badge](https://badgen.net/badge/Coverage/100/blue) ![coverity](https://scan.coverity.com/projects/31168/badge.svg) \n\nA CLI calculator tool used to assist designing rigid PCB traces. Implements both the IPC2221 and IPC2152 standards and has the ability to choose between the two, with the latter having three methods available. Each method used for the standards was derived from one of the various websites that claim to implement an trace width calculator. More information regarding certain formulas used are under `docs/`.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./docs/screenshot.png\" alt=\"screenshot\" width=\"500\"/\u003e\n\u003c/p\u003e\n\n## Features\n- Four total methods for calculating trace widths in rigid PCBs, listed in the next section.\n- Default units are metric. Choose to change units for any input and change the output units from imperial to metric.\n- Convert any value used in the tool with the conversion functions (use `--help` to list them or see below).\n- Optionally output the results to a file for saving.\n\n## Motivation\nI always found confusing how an open-source tool for this type of electronics design use didn't exist, therefore I decided to make one! Through the project I wanted to allow the study of how trace widths are calculated, since I found the complexities behind that interesting. Also I wanted to collect most of the available online trace width calculator implementations, and try to improve on them, while implementing them on an open-source offline command-line tool. The completely different implementations of the IPC2152 standard does put in question the validity of these calculators and their implementations. Thankfully, due to the open-source nature of the project, the differences between the implementations are clearly viewable, and the user can freely choose the one that seems best. Future development is definitely to encourage the creation of a TWC implementation of the IPC2152 method.\n\n## Methods\nOne method is implemented for IPC2221 and three methods for IPC2152. The tool defaults to the IPC2152 standard, Method A.\n\n### IPC2221\n- Method: The ubiquitous way of calculating trace widths. Derived from [The CircuitCalculator.com Blog](https://circuitcalculator.com/wordpress/2006/01/31/pcb-trace-width-calculator/) and [Omni Calculator](https://www.omnicalculator.com/other/pcb-trace-width#how-to-calculate-the-width-of-a-pcb-trace). This is the only available method with this standard.\n\n### IPC2152\n- Method A: Derived from [NinjaCalc](https://ninjacalc.mbedded.ninja/calculators/electronics/pcb-design/track-current-ipc2152). Default method for the TWC.\n- Method B: Derived from [SMPS.us](https://www.smps.us/pcb-calculator.html) which was also posted on the [Altium Resources](https://resources.altium.com/p/using-ipc-2152-calculator-designing-standards).\n- Method C: Derived from [Sierra Circuits](https://twcalculator.app.protoexpress.com/).\n\n## Installing\nCurrently an automatic installation exists only for Windows, and binaries are built only for Windows. For other Operating Systems you need to build from source.\n\n### Windows\nTo install automatically, use the install script located in `install/` by executing the command below in a PowerShell terminal with Admin rights,\n\n```\nirm \"https://raw.githubusercontent.com/ymich9963/twc/refs/heads/main/install/twc-windows-install.ps1\" | iex\n```\n\nThe script downloads the executable, moves it to `C:\\Program Files\\twc\\`, and adds that path to the system environment variable. If you do not want the automated script feel free to download the executable or build from source. In case your organisation doesn't allow you to install from the script due to protected paths, download the script and change the `$TWC_install_path` variable to a location that suits you.\n\n### macOS \u0026 Linux\nPlease the Building section. Use `make` to build from source.\n\n## Using\nMandatory inputs to get any kind of output are *Copper Weight* and *Current* specified with `-w` and `-c` respectively. TWC defaults to metric units for input and output, as well as the IPC2152 standard using Method A. TWC accepts SI prefixes on all SI units used in the software (Amps, metres, etc.) from Terrra (T) down to pico (p).\n\n### Example Uses \nMost basic type of output where the current is 1 A and the copper weight is the 35 um standard, \n```\ntwc -c 1 -w 35u\n```\nChanging standards can be done with the `--standard` and `--method` flags. For example to use the IPC2221 standard,\n```\ntwc -c 1 -w 35u --standard IPC2221\n```\nCan instead use imperial inputs like oz/ft^2 to specify the copper weight. This can be done for all the options listed in the `--help`,\n```\ntwc -c 1 -w-oz 1 --standard IPC2221\n```\nOptionally specify the `-q` or `--quiet` flags to remove the appendix section from the outputs.\n```\ntwc -c 1 -w-oz 1 --standard IPC2221 -q\n```\nFeel free to add more options for use with the desired method. Some options won't have any effect on other methods, and that's easy to figure out from the output or the details in the `--help` option. Example below shows how to use trace length and plane distance in IPC2152, Method A,\n```\ntwc -c 1 -w-oz 1 -l 2c -d 1c\n```\nChoose to place a small note at the top of your output to remind yourself what this output is for,\n```\ntwc -c 1 -w-oz 1 -l 2c -d 1c --note \"Example note!\"\n```\nOutput from that command is shown below,\n```terminal\nNOTE:\nExample note!\n\n                -INPUTS-\nCurrent:................  1.00000 [A]\nCopper Weight:..........  1.00000 [oz/ft^2]\nTemperature, Rise:...... 10.00000 [C]\nTrace Length:...........  2.00000 [cm]\nPCB Thickness:..........  1.60000 [mm]\nPlane Distance:.........  1.00000 [cm]\nPCB Thermal Cond.:......  0.20000 [W/mK]\n\n                -OUTPUTS-\nArea:...................  0.00992 [mm^2]\nCorrected Area:.........  0.01652 [mm^2]\n\nWidth:..................  0.28340 [mm]\nCorrected Width:........  0.47207 [mm]\n\nResistance:.............  0.03332 [Ohm]\nVoltage Drop:...........  0.03332 [V]\nPower Loss:.............  0.03332 [W]\n\n           -CORRECTION FACTORS-\nCopper Weight CF:.......  0.90343 [units]\nPCB Thickness CF:.......  1.09200 [units]\nPCB Thermal Cond. CF:...  1.03161 [units]\nPlane Distance CF:......  1.63674 [units]\n\n                -APPENDIX-\n- Constants used for the P/I/V calculations were,\n\n          a = 3.930e-03 [1/C] (Temperature Coefficient)\n        rho = 1.720e-08 [Ohm m] (Resistivity)\n\nTWC used IPC2152 Method A derived from: \nhttps://ninjacalc.mbedded.ninja/calculators/electronics/pcb-design/track-current-ipc2152\n\nDISCLAIMER:\nDesign assistance by the TWC tool is provided with no liability whatsover.\nFor final decisions on electronics designs, please consult an actual qualified person.\n\n```\nChoose to output this to a text file by using the `-o` option and by either inputting a name or a '.' to use the autogenerated output.\n```\ntwc -c 1 -w-oz 1 -l 2c -d 1c --note \"Example note!\" -o .\n```\nThe internal conversion functions are also available for quick and easy conversion for some of the inputs to the TWC, for example convert um to oz/ft^2.\n```\ntwc --convert-m-to-ozft2 35u\n```\nSee the `--help` output below for the available options,\n```terminal\nHelp option for the Trace Width Calculator (TWC). Use '--version' to get the version output.\n                --standard \u003cStandard\u003e                           = Choose the standard to use to calculate trace widths. Options are 'IPC2221' and `IPC2152`.\n\n                --method \u003cMethod\u003e                               = Choose the method for the desired standard. Currently only used by the IPC2152 procedure with method options 'A', 'B', and 'C'.\n\n        -n,     --note \"\u003cText\u003e\"                                 = Add a note to the start of the output. Make sure to put the note between quotes.\n\n        -c,     --current \u003cCurrent [A]\u003e                         = Input the trace current in Amps.\n\n        -w,     --copper-weight \u003cCopper Weight [m]\u003e             = Input the copper weight in meters. Use the other options below for imperial units.\n        -w-mil, --copper-weight-mil\n        -w-oz,  --copper-weight-oz\n\n        -r[-C], --temperature-rise \u003cTemp. Rise [C]\u003e             = Input the maximum allowed temperature rise in C.\n        -r-F,   --temperature-rise-F\n\n        -a[-C], --temperature-ambient \u003cTemp. Ambient  [C]\u003e      = Input the ambient temperature of the trace in C.\n        -r-F,   --temperature-ambient-F\n\n        -l,     --trace--length \u003cTrace Length [m]\u003e              = Input the trace length in centimeters. Use the other options below for imperial units.\n        -l-mil, --trace--length-mil\n        -l-in,  --trace--length-inches\n\n        -t,     --pcb-thickness \u003cThickness [m]\u003e                 = Input the PCB thickness in meters. Use the other options below for imperial units.\n        -t-mil, --pcb-thickness-mil\n        -t-in,  --pcb-thickness-in\n\n        -e,     --pcb-thermal-conductivity \u003cTherm. Con. [W/mK]\u003e = Input the PCB thermal conductivity in Watts per meter Kelvin.\n\n        -p,     --plane-area \u003cPlane Area [m^2]\u003e                 = Input the plane cross sectional area in meters squared. Use the other options below for imperial units.\n        -p-in2, --plane-area-in2\n        -p-mil2,--plane-area-mil2\n\n        -d,     --plane-distance \u003cPlane Distance [m]\u003e           = Input the plane distance in meters. Use the other options below for imperial units.\n        -d-mil, --plane-distance-mil\n        -d-in,  --plane-distance-inches\n\n                --resistivity \u003cResistivity [Ohm m]\u003e             = Input the resistivity in Ohm meters.\n\n                --temperature-coefficient \u003cTemp. Coef. [1/C]\u003e   = Input the temperature coefficient.\n\n        -o,     --output \u003cFile Name\u003e                            = Write the name of the outputted file. Use '.txt' to create a text file. Use a single '.' to auto-generate\n                                                                  the name based on date/time. Can also write the full path to the file, e.g. 'C:/Users/user/output.txt'\n                                                                  or stop at 'C:/Users/user/' to use the auto-generated file name.\n\n        -m,     --metric                                        = Make the output units be metric.\n\n        -i,     --imperial                                      = Make the output units be imperial. Default behaviour, therefore just implemented for completion.\n\n        -q,     --quiet                                         = Remove the appendix from the output. Credits and disclaimer cannot be removed.\n\n        -x,     --no-colour                                     = Remove the colour ANSI escape codes from the output.\n\n                --precision \u003cDecimal Amount\u003e                    = Specify default decimal precision amount. Default is 5.\n\n\n                        CONVERSIONS\n\nUsage example 'twc --conversion-m-to-ozft2 \u003cValue\u003e'. Can use an SI prefix in the input when converting from meters.\n\n        --convert-m-to-ozft2    = From meters to oz per foot sq.\n        --convert-m-to-mil      = From meters to mil.\n        --convert-m2-to-in2     = From meters sq. to inches sq.\n        --convert-m2-to-mil2    = From meters sq. to mil sq.\n        --convert-mil-to-mm     = From mils to milimeters.\n        --convert-mil-to-ozft2  = From mils to ounce per foot sq.\n        --convert-mil2-to-cm2   = From mils sq. to centimeters sq.\n        --convert-mil2-to-mm2   = From mils sq. to milimeters sq.\n        --convert-ozft2-to-mil  = From ounce per foot sq. to mils.\n        --convert-ozft2-to-mm   = From ounce per foot sq. to milimeters.\n        --convert-ozft2-to-um   = From ounce per foot sq. to micrometers.\n        --convert-F-to-C        = From Fahrenheit to Celsius.\n        --convert-C-to-F        = From Celsius to Fahrenheit.\n        --convert-WmK-to-BTUhftF        = From Watts per mili Kelvin to BTU/h*ft*F.\n        --convert-BTUhftF-to-WmK        = From BTU/h*ft*F to Watts per mili Kelvin.\n```\n## Building\nClone the repository and got to this directory. Using `make` simply run in a command line,\n```\nmake\n```\nAnd `twc` should be build in a new `build/` directory.\n\n## Tests and Coverage\nRunning the tests or coverage can be done by running,\n```\nmake test\n```\n```\nmake coverage\n```\nTesting suite used is [Unity](https://github.com/ThrowTheSwitch/Unity) and LLVM-COV for coverage.\n\n## Sources\nSome sources for creating the tool are listed below, \n- Trace Width Calculators,\n\t- [Advanced PCB](https://www.advancedpcb.com/en-us/tools/trace-width-calculator/)\n\t- [Circuit Calculator](https://circuitcalculator.com/wordpress/2006/01/31/pcb-trace-width-calculator/)\n\t- [Omnicalculator](https://www.omnicalculator.com/other/pcb-trace-width#how-to-calculate-the-width-of-a-pcb-trace)\n\t- [SMP.us](https://www.smps.us/pcb-calculator.html)\n\t- [NinjaCalc - IPC2152](https://ninjacalc.mbedded.ninja/calculators/electronics/pcb-design/track-current-ipc2152)\n    - [NinjaCalc - IPC2221a](https://ninjacalc.mbedded.ninja/calculators/electronics/pcb-design/track-current-ipc2221a)\n    - [Sierra Circuits](https://twcalculator.app.protoexpress.com/)\n    - [Sierra Circuits (same as above?)](https://designertools.app.protoexpress.com/?appid=TWCCCAL)\n- Conversion calculators,\n\t- [Convert-me](https://www.convert-me.com/en/convert/area/?u=mm2\u0026v=0.0111) for area conversion\n\t- [UnitConverters](https://www.unitconverters.net/length/mil-to-millimeter.htm)\n\t- [Convert-measurement-units](https://www.convert-measurement-units.com/conversion-calculator-quick.php)\n\t- [Metric Conversions](https://www.metric-conversions.org/temperature/fahrenheit-to-celsius.htm) C to F conversion\n- Other Resources\n\t- [Resistivity/Temperature Coefficients](https://www.engineeringtoolbox.com/resistivity-conductivity-d_418.html)\n\t- [Standard PCB Thickness – An Important Role in PCB Function](https://www.nextpcb.com/blog/standard-pcb-thickness)\n\t- [What is the Thermal Conductivity of Different PCBs](https://www.pcbonline.com/blog/pcb-thermal-conductivity.html)\n\t- [How Thick is 1 oz Copper](https://pcbprime.com/pcb-tips/how-thick-is-1oz-copper/)\n\t- [PCB Universe](https://www.pcbuniverse.com/pcbu-tech-tips.php?a=4)\n\t- [Resistivity and Temp coefficient source](http://hyperphysics.phy-astr.gsu.edu/hbase/Tables/rstiv.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymich9963%2Ftwc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fymich9963%2Ftwc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymich9963%2Ftwc/lists"}