FOSS Trace Width Calculator in C using both IPC2221 and IPC2152 - Page 1
Forum section: electronics / general

author: ymich
author_rank: Newbie
timestamp: April 30, 2025, 09:39:08 am
content: Hi everyone. This is my first post here, and it seems like a really nice community! In the past year I've been making this project because I was very interested in how trace widths are calculated, I found it kind of silly that at my work we (for some reason) trust online websites for trace width calculations. Here is the link to the project repository.https://github.com/ymich9963/twcIn the repo I talk about the features, motivation, and example usage of the project. To install for Windows it's a simple copy-paste command in a PowerShell terminal with Admin rights. Please let me know your thoughts, improvements, or any issues! Thanks.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: May 02, 2025, 07:04:53 am
content: I quite like the track width calculator in KiCad's "calculator tools". It also runs on my linux box.

author: ymich
author_rank: Newbie
timestamp: May 03, 2025, 11:40:45 am
content: Quote from: Doctorandus_P on May 02, 2025, 07:04:53 amYeah builds for different OSs is something I didn't really want to do at the very start. If you've got Make installed you could always just build it from source.The KiCAD calculator is IPC-2221 and not the new IPC-2152, which as I point out in the repo, all the different calculators for it I could find online have a different implementation. One of the reasons why I made this project is so that the community can have a discussion around the IPC-2152 because not much info about it exists online.

author: eugene
author_rank: Frequent Contributor
timestamp: May 03, 2025, 03:57:57 pm
content: I don't have any Windows machines, but I was able to compile it on my Linux box after modifying the Makefile so that it uses gcc instead of clang and adding -lm to the end of CFLAGS.At this point I cannot comment much other than to say that it seems to work.

author: ymich
author_rank: Newbie
timestamp: May 06, 2025, 02:17:56 pm
content: Quote from: eugene on May 03, 2025, 03:57:57 pmThat's definitely a good sign!

author: ymich
author_rank: Newbie
timestamp: June 01, 2025, 03:03:24 pm
content: I heavily updated the outputs in the new v1.2. I attached a screenshot in case people want to see what it looks like!

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 01, 2025, 03:30:31 pm
content: Just curious, would you be interested with helping to integrate your code into KiCad's trace width calculator?I've tinkered a bit with uC's, but I'm not very good with (PC) software. If you're interested, you can start with:https://dev-docs.kicad.org/en/getting-started/index.htmlBut it's probably to concentrate on further finishing your code first. I also saw the GPL license on your github repository, so that allows integration into KiCad too. Just mentioning that your code is available on gitlab (where KiCad development happens) may be enough for someone else to pick up the thread and do the integration.KiCad uses wxWidgets for the GUI stuff. There are more capable cross platform GUI's (such as Qt). KiCad is stretching the extend of what wxWidgets can do, but wxWidgets is perfectly fine for smaller projects, pretty much anything a single person can develop.

author: ymich
author_rank: Newbie
timestamp: June 01, 2025, 09:17:26 pm
content: Crazy you mentioned this but the next planned step for the project is to create a KiCAD plugin for it with a GUI that would be accessed through the PCB Layout Editor. I haven't looked too much into the implementation of it but I want it to be very integrated into KiCAD. Something that I want it to do would be to allow the user to create a net class with the desired trace width through the tool. The KiCAD calculator is kind of it's own software with the IPC2221 already implemented for trace widths. Therefore, if I implement it in the KiCAD calculator, it won't be as integrated as I would like.Even though there probably won't be any problems with implementing the three IPC2152 methods on it, I would want a more fully understood implementation of the standard and not just three methods that other people implemented and that I have improved. I think the KiCAD devs also would prefer something like that because at least to me the IPC2152 implementation doesn't feel good enough to be in KiCAD officially yet.Also just to say that the code is 'finished' in the sense that it does what I want it to do currently. After v1 all updates were just improvements I realised the tool needed after using it in some more realistic scenarios.