pcb-rnd knowledge pool
Courtyard: ko.* layer groups
ko_id by Tibor 'Igor2' Palinkas on 2020-04-27 | Tags: howto, drc5, keepout, courtyard, drc |
Abstract: The "courtyard" (ko.courtyard) feature is fully working mechanical keepout/courtyard with DRC checks provided by the default drc_query config. This node describes how the feature works and provides a minimal example.
1. layer groups and layers
The features uses optional ko.courtyard layer groups as documented in the doc groups node .
2. in footprint
Such layers can appear in footprints (supported only with the lihata fromat). It works correctly with top/bottom, e.g. if you have an smd part (like sot23 in the attached example) placed on the top, using a top ko.courtyard layer group, if you move that subc to the bottom side and you have a bottom side ko.courtyard, the layer binding will use that.
3. objects
You can draw objects, preferrably polygons on the ko.courtyard layer, in subcircuits, or just on the board, as you like
4. drc: collision detection
If you run the drc with pcb-rnd version greater then 2.2.1, it will do the collision check: any two objects drawn on layer groups with the same "ko.*" purpose is listed in the drc. TIP: the ko.courtyard layer group is invisible after loading the board, turn it on before you run the drc! Running the drc: type {w d}
5. multiple ko.* layer groups
The rule doesn't really look for ko.courtyard but works with any layer group whose purpose string starts with "ko." - so you can create your own courtyard classes that won't interfere. Random example: you create a new layer group, doc layer, purpose ko.magnetic, then draw the expected magnetic field around transformers and coils in the corresponding subcircuits. We prefer keepout object be polygons, but that's only because we want them solid - in this case you can use a single very thick line so the size of the field can be set numerically, by the thickness property (using the propedit). Doing all this will make your DRC automatically throw violations if two magnetic fields overlap! No new code, no new script, no new drc rule needed, just the above data setup. (This check will work independenlty of the ko.courtyard checks, so you can still make sure your coils mechanically won't intersect with other parts.)
6. Dynamic violation text
As you see in point 5, the true meaning of an intersection depends on what you use your ko.* group for; so parts of the drc violation text is coming from your layer (not layer group this time!) attribute. You can check this in the attached example: right click on the "top-courtyard" layer, select "Layer properties..." and you will see a drc_desc attribute on the bottom. When this attribute is present, its value is attached to the violation so the violation long description can be meaningful and say it's a magnetic field conflict in point 5.
7. How to test the feature
- 0. use pcb-rnd version greater than 2.2.1
- 1. open the test file
- 2. make the top-courtyard layer visible
- 3. run the DRC, e.g. {w d}
- 4. click on the violation, look at the preview, read the description
8. Under the hood
Implementation details are also documented and can be used as an example for learning drc scripting.