PCB trace computations according IPC-2221 standard

Contributions to this software library are always welcome. Please ensure that you post program listings rather than .raw files. They give a reasonable idea of what your program does without having to load them into a DM42 and you can also include comments in your code. Check out the following link for a decoder/encoder: https://technical.swissmicros.com/decoders/dm42/

You can then copy/paste the listing and post it in "code" tags.
Kibabalu
Posts: 15
Joined: Sat Apr 03, 2021 2:36 pm

PCB trace computations according IPC-2221 standard

Post by Kibabalu »

Dear colleagues,

I'm designing PCB just occasionally, let say two or three times a year, and I am always struggling to choose the correct trace widths for different currents flowing in different parts of my circuit. Thus I've written a program for the computation of PCB traces according the IPC-2221 standard. The relevant variables are the maximum current for a trace, the trace height, trace width, trace length, and the allowed temperature rise for the trace, ambient temperature, and the trace resistance. The trace height is in most of my cases 35um, that's why this is the default value in the program.

The program is using the metric units A, K and m. If you want it in A, K and mil you have to convert or modify the code by removing the lines 27-28, 30-31, 58-59, 61-62.

Best regards,

Frank

Code: Select all

@ computation of PCB traces according IPC-2221 standard
@
@ internernal traces : I = 0.024 x dT^0.44 x A^0.725
@ externernal traces: I = 0.048 x dT^0.44 x A^0.725
@ Resistance = Resistivity*Length/Area*(1 + (Temp_Co*(Temp - 25))
@
@ The formulas are defined for the units A, K and mil. The programm
@ takes and gives the metric unit m instead of mil!
@
@ Default value for the trace height is 35um
@ Default value for the temperature rise is 10K
@
@ Frank Kirschbaum, frank.kirschbaumr@gmail.com
@
00 { 669-Byte Prgm }
01 LBL "Trace"

02 CLMENU
03 "extern"                @ main Menu: choice between internernal and externernal traces
04 KEY 1 XEQ "extern"
05 "intern"
06 KEY 2 XEQ "intern"
07 "resist"
08 KEY 3 XEQ "resist"
09 MENU
10 STOP

11 LBL "extern"            @ routine for externernal traces
12 MVAR "IMax"
13 MVAR "dT"
14 MVAR "width"
15 MVAR "height"
16 VARMENU "extern"

17 CF 21 @ continue program execution after a VIEW instruction
18 STOP
19 ASTO "CONTROL"       @ store the name of the unknown variable in CONTROL
20 PGMSLV ".extern"        @ specify solver routine
21 SOLVE IND "CONTROL"  @ Indirectly specify the variable to be solved
22 VIEW IND "CONTROL"   @ View the solution
23 GTO "extern"            @ return to start

24 LBL ".extern"           @ function to be solved for externernal traces
25 XEQ 00 @ call subroutine for default values
26 RCL "width"
27 39370.07874
28 ×
29 RCL× "height"
30 39370.07874
31 ×
32 0.725
33 Y↑X
34 RCL "dT"
35 0.44
36 Y↑X
37 ×
38 0.048
39 ×
40 RCL- "IMax"
41 RTN

42 LBL "intern"            @ routine for internernal traces
43 MVAR "IMax"
44 MVAR "dT"
45 MVAR "width"
46 MVAR "height"
47 VARMENU "intern"

48 CF 21 @ continue program execution after a VIEW instruction
49 STOP
50 ASTO "CONTROL"       @ store the name of the unknown variable in CONTROL
51 PGMSLV ".intern"        @ specify solver routine
52 SOLVE IND "CONTROL"  @ Indirectly specify the variable to be solved
53 VIEW IND "CONTROL"   @ View the solution
54 GTO "intern"            @ return to start

55 LBL ".intern"           @ function to be solved for internernal traces
56 XEQ 00 @ call subroutine for default values
57 RCL "width"
58 39370.07874
59 ×
60 RCL× "height"
61 39370.07874
62 ×
63 0.725
64 Y↑X
65 RCL "dT"
66 0.44
67 Y↑X
68 ×
69 0.024
70 ×
71 RCL- "IMax"
72 RTN

73 LBL "resist"            @ routine for resistance computation
74 MVAR "width"
75 MVAR "height"
76 MVAR "length"
77 MVAR "temp"
78 MVAR "Res"
79 VARMENU "resist"

80 CF 21 @ continue program execution after a VIEW instruction
81 STOP
82 ASTO "CONTROL"       @ store the name of the unknown variable in CONTROL
83 PGMSLV ".resist"        @ specify solver routine
84 SOLVE IND "CONTROL"  @ Indirectly specify the variable to be solved
85 VIEW IND "CONTROL"   @ View the solution
86 GTO "resist"            @ return to start

87 LBL ".resist"           @ function to be solved for internernal traces
88 XEQ 01 @ call subroutine for default values
89 RCL "temp"
90 25
91 -
92 3.9ᴇ-3
93 ×
94 1
95 +
96 RCL× "length"
97 RCL÷ "width"
98 RCL÷ "height"
99 1.7ᴇ-8
100 ×
101 RCL- "Res"
102 RTN

103 LBL 00 @ subroutine 00 for default values
104 RCL "height"
105 X≤0?
106 0.35ᴇ-6 @ default track height of 35um
107 STO "height"
108 RCL "dT"
109 X≤0?
110 10 @ default temperature rise
111 STO "dT"
112 RTN

113 LBL 01 @ subroutine 01 for default values
114 RCL "height"
115 X≤0?
116 0.35ᴇ-6 @ default track height of 35um
117 STO "height"
118 RCL "temp"
119 X≤0?
120 25 @ default temperature rise
121 STO "temp"
122 RTN

123 END
Last edited by Kibabalu on Fri Feb 11, 2022 6:44 am, edited 6 times in total.
MikeD
Posts: 12
Joined: Sun Jul 22, 2018 11:05 am

Re: PCB trace computations according IPC-2221 standard

Post by MikeD »

Frank,
converted and loaded. Seems to either give me a non-existent when I enter 3 and ask for the 4th or runs an endless loop?
-Mike.
Kibabalu
Posts: 15
Joined: Sat Apr 03, 2021 2:36 pm

Re: PCB trace computations according IPC-2221 standard

Post by Kibabalu »

Sorry, I don't really understand your post.

after starting you first have to choose between internal and external traces. Then you have to enter values for the variables except the one you want to solve for.

The behavior described by you occurs if dT is zero and IMax not. No temperature rise with a current greater than zero is physicaly impossible.
MikeD
Posts: 12
Joined: Sun Jul 22, 2018 11:05 am

Re: PCB trace computations according IPC-2221 standard

Post by MikeD »

I did, 1st select external, then the data I got back did not seem to come close to some of the online TW calculators with the same inputs and units. SO then I did the same for and internal trace and that is when I got the endless loop.
Kibabalu
Posts: 15
Joined: Sat Apr 03, 2021 2:36 pm

Re: PCB trace computations according IPC-2221 standard

Post by Kibabalu »

I cannot reproduce the error, except I give zero for dT and not zero for IMax. Anyway, I extended the code. Now there's a default value for dT of 10K, to prevent users accidentally trying to calculate the trace width for ´no temperature rise at all´. Because that would mean a trace width of infinity.

The results I get back from the program are ´exactly´ the same like I get from the one online calculator I used to test the algorithm (https://www.7pcb.com/trace-width-calculator.php).

You are aware of the units mil and m?
MikeD
Posts: 12
Joined: Sun Jul 22, 2018 11:05 am

Re: PCB trace computations according IPC-2221 standard

Post by MikeD »

Yes. I removed the lines you posted that leave it in Mils. Let me try the new code. Thank You!
MikeD
Posts: 12
Joined: Sun Jul 22, 2018 11:05 am

Re: PCB trace computations according IPC-2221 standard

Post by MikeD »

Also, I think you meant to say remove lines 28 and 29, not 28 and 20.
MikeD
Posts: 12
Joined: Sun Jul 22, 2018 11:05 am

Re: PCB trace computations according IPC-2221 standard

Post by MikeD »

Works perfect now! with Internal, external, different temp rise. The only suggestion is to change the height to oz of copper, as we always link of copper in the PCB layers as 1oz, 1/2oz, 2oz...

This is great! thank you for sharing!
MikeD
Posts: 12
Joined: Sun Jul 22, 2018 11:05 am

Re: PCB trace computations according IPC-2221 standard

Post by MikeD »

Frank,
MikeD wrote:
Thu Feb 10, 2022 8:20 pm
Re: "The only suggestion is to change the height to oz of copper, as we always link of copper in the PCB layers as 1oz, 1/2oz, 2oz...
Actually, I kinda like the thickness as is rather than oz, Seems the definition of an oz of copper is not really standard so it's best to get the copper thickness data right off the stackup drawing.

This is a super useful program Frank! Thanks for posting it? I will get a lot of use out of it for sure!

You probably want to update the directions to remove lines 27-28, 30-31, 58-59, 61-62 for MIL since you added a couple of lines to the code.
Kibabalu
Posts: 15
Joined: Sat Apr 03, 2021 2:36 pm

Re: PCB trace computations according IPC-2221 standard

Post by Kibabalu »

done!

When you are into electronics you'll find some more stuff in my repository

https://github.com/Kibabalu/free42
Post Reply