Custom Design Rule does not work

Hello,

I have some problems with custom design rules. Maybe somebody can help me…

Thats what I want:
→ The Net ‘AC_N’ and ‘/AC_PowerLine/AC_N_Fused’ can have a clearance of 1mm. To all other Nets 3mm
→ The Net AC_N’ and '/AC_PowerLine/AC_N_OUT can also have a clearance of 1mm. To all other Nets 3mm
→ All other Nets in Net-Class 230VAC should have minimum distanvce of 2.8mm

One Remark: The nets AC_N, /AC_PowerLine/AC_N_Fused and /AC_PowerLine/AC_N_OUT are all in the Net-Class 230VAC

Here is my code. Can you help me what I did wrong??

Thanks a lot,
Zugang

(version 1)

(rule DISTANCE_AC_OTHER
	(constraint clearance (min 2.8mm))
	(condition "A.NetClass == '230VAC'")
)


(rule DISTANCE_AC_N_zu_AC_N_Fused
	(constraint clearance (min 1mm))
	(condition "A.Net == 'AC_N' && A.Net == '/AC_PowerLine/AC_N_Fused'"  )

)


(rule DISTANCE_AC_N_zu_AC_N_OUT
	(constraint clearance (min 1mm))
	(condition "A.Net == 'AC_N' && A.Net == '/AC_PowerLine/AC_N_OUT'"  )
)

Inside one condition A is one and the same, so this can’t work. The name is arbitrary but there must be two different names, for example A and B.

This I also tried. But it didnt work:
Here is the second example:

(version 1)

(rule DISTANCE_AC_OTHER
	(constraint clearance (min 2.8mm))
	(condition "A.NetClass == '230VAC'")
)

(rule DISTANCE_AC_N_zu_AC_N_Fused
	(constraint clearance (min 1mm))
	(condition "A.Net == 'AC_N' && B.Net == '/AC_PowerLine/AC_N_Fused'"  )

)


(rule DISTANCE_AC_N_zu_AC_N_OUT
	(constraint clearance (min 1mm))
	(condition "A.Net == 'AC_N' && B.Net == '/AC_PowerLine/AC_N_OUT'"  )
)

Have you used Inspect → Clearance Resolution?

Yes. Ki-Cad is violating the rule and uses 2.8mm distance:

grafik

So the rule “DISTANCE_AC_OTHER” seems to work. But the more important rules which he should use for AC_N and AC_N_Fused do not work

whcih rules do have priority?
→ The rules of the “net classes” tab or the coded rules of “custom rules”?

1 Like

Your screenshot is from the DRC dialog, not from Inspect → Clearance Resolution. You have to select two items and open that dialog to see more information.

Naturally custom rules, otherwise it would be pretty meaningless to try to write custom rules, would it?

I found the solution!

I have to use “A.NetName” instead of “A.Net

(version 1)


(rule DISTANCE_AC_N_zu_AC_N_Fused
	(constraint clearance (min 1mm))
	(condition "A.NetName == 'AC_N' && B.NetName == '/AC_PowerLine/AC_N_Fused'"  )

)


(rule DISTANCE_AC_N_zu_AC_N_OUT
	(constraint clearance (min 1mm))
	(condition "A.NetName == 'AC_N' && B.NetName == '/AC_PowerLine/AC_N_OUT'"  )
)
1 Like

wait…there is someting wrong.

when I put again the Class 230VAC into the custom design rules, it is not working anymore:

(version 1)

(rule DISTANCE_AC_OTHER
	(constraint clearance (min 2.8mm))
	(condition "A.NetClass == '230VAC'")
)

(rule DISTANCE_AC_N_zu_AC_N_Fused
	(constraint clearance (min 1mm))
	(condition "A.Net == 'AC_N' && B.Net == '/AC_PowerLine/AC_N_Fused'"  )

)


(rule DISTANCE_AC_N_zu_AC_N_OUT
	(constraint clearance (min 1mm))
	(condition "A.Net == 'AC_N' && B.Net == '/AC_PowerLine/AC_N_OUT'"  )
)

Maybe DISTANCE_AC_OTHER takes precedence, as all 3 nets are 230VAC.
Maybe putting the DISTANCE_AC_OTHER rule last helps.
Not sure.

I also tried this. But didn’t work… :frowning:

So let’s shout out to @JeffYoung. He is the master of the DRC / Custom Design Rules universe.

In your example you went back to A.Net instead of A.NetName.

.Net gives you the auto-assigned netcode (a number), not the name of the net.

(So why does .Net exist if it’s not usually what you want? Because when testing for equality, ie: A.Net == B.Net the .Net test is much faster than the .NetName test.)

1 Like

As for “what wins”, the answer is always “the last rule that matches”.

Everything in the Netclasses tab (and the Constraints tab) is actually compiled in to rules behind the scenes. Then the author’s custom rules are added at the end (so they win over the auto-compiled rules).

But do try out Inspect > Clearance Resolution… (and Constraint Resolution…). They can be a real help (and will list all the auto-compiled rules as well).

yes, you’re right. But this was only copy&paste error. With this code (I used), it also does not work correctly

(version 1)
(rule DISTANCE_AC_OTHER
	(constraint clearance (min 2.8mm))
	(condition "A.NetClass == '230VAC'")
)


(rule DISTANCE_AC_N_zu_AC_N_Fused
	(constraint clearance (min 1mm))
	(condition "A.NetName == 'AC_N' && B.NetName == '/AC_PowerLine/AC_N_Fused'"  )

)


(rule DISTANCE_AC_N_zu_AC_N_OUT
	(constraint clearance (min 1mm))
	(condition "A.NetName == 'AC_N' && B.NetName == '/AC_PowerLine/AC_N_OUT'"  )
)

OK, select one of each net and do an Inspect > Clearance Resolution… and post a screen-shot…

sorry, I was in the wrong mode…now it worked.-

1 Like

Do anybody does have a tipp?
The screen-shot of clearance resolution shows, that the rule will be applied, but it does still not work…
Does anybody have an idea why?