KiCad 6.0 custom design rules for HV clearances

One of the features I have been looking forward to the most in KiCad 6.0 is the ability to specify design rules that apply only under certain circumstances or between certain net classes.

My simplified use case is half bridge circuit consisting of 2 HV rails, HV+ and HV-, a phase output that could be at HV+, HV- or floating potential depending on the MOSFET states. The low voltage control system is totally isolated from the HV system via an isolation barrier within the gate driver ICs and the isolated power supplies. See the circuit in the diagram.

What I was hoping to do was come up with a set of design rules that would enable me to route this circuit so that there is minimal clearance between traces at close potentials but full clearance between different HV and LV net classes.

My initial approach has been to define 4 main net classes: HV+, HV-, HV phase and LV where each net class contains all the nets at a similar potential as per the diagram.

(version 1)

(rule "LoW cLeArAnce BeTWeen neTS of THe SAme HV potential"
	(constraint clearance (min 0.2mm))
	(condition " A.NetClass == B.NetClass && A.NetClass == 'HV*' " ))

(rule "HIgH cLeArAnce BeTWeen neTS of dIfferenT HV potentials"
	(constraint clearance (min 5.0mm))
	(condition " A.NetClass != B.NetClass && A.NetClass == 'HV*'  && A.NetClass == 'HV*' " ))

(rule "HIgH cLeArAnce BeTWeen LV And HV neTS"
	(constraint clearance (min 5.0mm))
	(condition " A.NetClass == 'HV*' && B.NetClass != 'HV*'" ))

(rule "Reduced cLeArAnce for HV PoTenTIALS cLoSe To comPonenTS"
	(constraint clearance (min 1mm))
	(condition " A.insideCourtyard('*') && A.NetClass == 'HV*' "))

(Note the semi random changing of rule name cases is seemingly unavoidable in the editor at least on Mac, which I presume is a bug)

These rules have sort of worked but I need to be able to reduce the clearance close to certain components, most notably the MOSFETs as they are designed with a lower clearance than I want to use elsewhere. My final design rule was an attempt to solve this but it does not appear to have worked. as I cannot route the source pins of the MOSFET even though they are more than 1 mm from the drain pins.

Am I approaching this the right way? Corrections, suggestions and comments welcomed. I know I am doing something wrong!

One thing I am not certain of is how the design rules interact with each other. My guess would be they are effectively ORed together and the most lenient set of constraints is followed, or is this wrong and they are applied sequentially?

1 Like

I also do power, but I have not attempted to dig into design rules to the extent that you are. So far as I know, design rules WRT spacing do not seem to allow for small voltage differentials when they are all at some high voltage (relative to ground for example). So you could have a current sense resistor connected in series with a 500VDC rail, but the maximum voltage between the ends of that resistor might be 100 mV. Or maybe there is an MSOP IC with all of its pins at voltages in the range of +490 to +500 VDC and the pin centers are 0.5 mm. That situation is a bit closer to your half bridge. I would be interested in learning of any solutions to this. I do not use design rules much.

The capitalization out of Apple seems wacko; for some reason it reminds me of a ransom note assembled from newspaper clippings.

What you are hitting looks like the issue I was hitting and I believe the long term solution (v7?) is such that multiple nets can be associated with different net classes so these rules start being manageable.
Having a minimum of 10 different “zones” for a 2level converter (I havn’t even attempted a 3level yet…) start causing issues if you want certain tracking rules for the gatedrive section as well as the switch section.
I looked at modifying an inverter I had and I settled on a few additional zones

  1. LV
  2. HV+
  3. HV-
  4. HV_Ph
  5. GD_Upper
  6. GD_Lower

GD_Upper → HV_Ph is small distance
GD_Lower → HV- is small distance
the other combinations are larger distances

A 1mm Source-Drain? that can only be for a 100-200V MOSFET

So far as I know, design rules WRT spacing do not seem to allow for small voltage differentials when they are all at some high voltage (relative to ground for example).

That aspect of the design rules now works and the rules I posted achieve just that. Feel free to try them out!

1 Like

I am not too worried about the number of net classes as it is easy enough to keep. on top of them for now but I agree a v7 solution that makes KiCad deal with net ties etc. properly would probably make this much easier.

A 1mm Source-Drain? that can only be for a 100-200V MOSFET

The 1mm spacing is mostly a placeholder for whatever the spacing actually is within the packages.

Is the approach I am taking regarding courtyards to reduce clearance valid? I am not sure I have the syntax or logic quite right.

So I wanted to follow up to this post for anyone who might come upon this post trying to figure out how the custom DRC rules actually work and for some pointers for getting started with HV clearances.

Take the following example:
(version 1)

(rule "HIgH cLeArAnce BeTWeen neTS of dIfferenT HV potentials"
	(constraint clearance (min 5.0mm))
	(condition " A.NetClass != B.NetClass && A.NetClass == 'HV*'  && A.NetClass == 'HV*' " ))

(rule "HIgH cLeArAnce BeTWeen LV And HV neTS"
	(constraint clearance (min 5.0mm))
	(condition " A.NetClass == 'HV*' && B.NetClass != 'HV*'" ))

(rule "Reduced cLeArAnce for HV PoTenTIALS cLoSe To comPonenTS"
	(constraint clearance (min 1mm))
	(condition " A.insideCourtyard('*') && A.NetClass == 'HV*' "))

(rule "LoW cLeArAnce BeTWeen neTS of THe SAme HV potential"
	(constraint clearance (min 0.2mm))
	(condition " A.NetClass == B.NetClass && A.NetClass == 'HV*' " ))

(rule "0.1 cLeArAnce BeTWeen HV and floating pins"
	(constraint clearance (min 0.2mm))
	(condition " A.NetClass == 'HV*' && B.NetCl

This example assumes the same circuit shown in the first post of this thread.

  • There are 5 net classes:
  • HV+
  • HV Phase
  • HV-
  • LV
  • Unconnected

Every net is assigned to the net class its potential is closest to. For instance the high side MOSFET gates are part of HV Phase as it is at a potential close to HV Phase but isn’t exactly HV phase.
LV is any net that needs to be totally isolated from all HV, regardless of potential.
Unconnected is specially for unconnected pins of connectors that will be left floating to give adequate clearance on small connectors so that the metal can be ignored for clearance purposes (note that this must be done with extreme care as anything plugged into these connector pins should be considered as potentially HV).

The order of the design rules IS important. They are applied sequentially and I have found, at least for clearances you need to work from most restrictive (large clearance) to most permissive (least clearance) with the conditions becoming more stringent with each rule.

In the case of this set of rules, there are four major clearances: between HV nets of different potentials and LV, between HV nets of different potentials but within components footprints (to allow components with a smaller pitch to be used), between HV nets in the SAME netclass, and between HV nets and Unconnected pins.

If you reorder the rules, for instance, so that the following rules

(rule "LoW cLeArAnce BeTWeen neTS of THe SAme HV potential"
	(constraint clearance (min 0.2mm))
	(condition " A.NetClass == B.NetClass && A.NetClass == 'HV*' " ))

is the first one in the list, it will be ignored as the following less specific rule, will then set the clearance to be higher, overriding the original

(rule "HIgH cLeArAnce BeTWeen neTS of dIfferenT HV potentials"
	(constraint clearance (min 5.0mm))
	(condition " A.NetClass != B.NetClass && A.NetClass == 'HV*'  && A.NetClass == 'HV*' " ))

Applying this logic, I can envision there being cases with overlapping sets where the constraints will sometimes be overridden based on the order they are written. I guess you just have to take great care when designing the logic for these rules too avoid that situation.

I hope this is helpful to some people! Do reply if you find it helpful or have discovered something else interesting regarding the custom constraints.

8 Likes

I once posted an idea for a “clearance line” on gitlab.
The idea was to draw a graphical line, and give it a clearance with (For example 8mm for in between the mains related section and secondary side of a power supply.

The idea was rejected for two reasons. It was deemed not flexible enough and would occupy more board space then needed.

The other reason was that it could already be implemented with the rules system.

All fair reasons, but I still like the simplicity of such a clearance line.

When it comes to clearance for HV sections, there are usually different rules for creepage and “air distance” and somtimes slots are routed in a PCB to increase the creepage distance. As far as I know KiCad has no method for implementing this.

1 Like

It would be nice if KiCad added a way to enforce creepage distances in version 7.0.

1 Like

Thanks, very nice and detailed structure.

1 Like

Thank you, this is golden.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.