How to create a custom rule Clearance: THT pad to SMD pad

Hello,

I am trying to create a rule to define the clearance between THT and SMD (on the soldering side of the THT). The reason is to prevent the SMD components from being washed away by the solder flow during the automated THT soldering process.

I tried this rule, but it doesn’t work:
(rule “Clearance: THT pad to SMD pad”
(condition “A.Type == ‘pad’ && B.Type == ‘pad’ && A.Pad_Type == ‘through_hole’ && B.Pad_Type == ‘smd’”)
(constraint clearance (min 6.0mm))
)

I use KiCAD 7.0.11

Thank you!

The auto completion suggests ‘Through-hole’ as pad type, not ‘through_hole’. Besides that many new features for the custom DRCs were only added in v8, so maybe your version does not support everything you want to do, yet.

Thanks.

I’m used to editing in Notepad. Before I wrote the question I was looking at what changes in the .pcb file when I change the Fooprint type attribute in the properties (E key). That’s how I came to through_hole.

Now it works a bit, but I have a lot of false positive errors because some footprints have plated through holes, but I don’t solder anything there (heat dissipation). I would also need to define it to check on the soldering side only.

You could maybe use an additional condition: !A.is_plated() which should be false for all plated holes.

Thanks, but this rule doesn’t work.

(rule "Clearance: THT footprint to SMD footprint"
    (condition "A.Type == 'Pad' && B.Type == 'Pad' && A.Pad_Type == 'Through-hole' && B.Pad_Type == 'SMD' && !A.isPlated()")
    (constraint clearance (min 6.0mm))
)

Holes in thru hole footprints are plated as well.

Ok, I’m not sure, that I understood you correctly. If not, please elaborate and I try to help further. But if you want a special clearance between all SMD pads and all non-plated holes this rule should work:

(version 1)
(rule "LaLa"
	(constraint hole_clearance(min 10mm))
	(condition "A.Type == 'Pad' && A.Pad_Type == 'SMD' && !B.isPlated()")
)

I need to maintain a distance between the SMD pads (or footprint in general) and the Thruhole components (their pads) due to soldering the Thruhole using a fountain of molten tin (there is a risk of the SMD component being washed away if it is too close).

Ideally I would like to set a rule like:
When A is a pad of Through hole footprint, B is a pad of SMD footprint then the distance is at least 6mm.

A hole may not automatically be a component pad.

Interesting challenge. On the other hand, sometimes I wonder if an easier and simpler solution would be to just adjust “clearances” while you position the footprints and route the tracks, using your eyes and hand. Or use a simpler rule, like courtyard_clearance for certain reference designators if there aren’t too many of those THT footprints.

Your chances would be better with v9 (now a pre-release “RC” version). You might be able to create a rule which you describe by attaching certain parts to Component Classes (see Schematic Editor | master | English | Documentation | KiCad) and using a combination of memberOfFootprint('x') where x is a component class (see PCB Editor | master | English | Documentation | KiCad). Then, your thruhole components would belong to the class Thruhole and you would test those pads against pads which aren’t part of footprint in that class. This needs to be physical_clearance because the net doesn’t matter, only the footprint class (normal clearance is for two different nets).

OK, I can confirm that in v9 something like this probably works as you would like:

(constraint physical_clearance(min 10mm))
(condition " A.Type == 'Pad' && A.memberOfFootprint('${Class:Tht}') && B.Pad_Type == 'SMD' && !B.memberOfFootprint('${Class:Tht}')")

This needs a field “Component Class” in symbols of THT footprints and field value Tht.

Thanks.
I’ll wait for v9, then I’ll try it.