## KiCad6中定位孔的使用 [[kicad]] 像绘制板边一样,我们也可以用同样的方式去绘制我们的螺丝孔定位孔,穿线孔或者设计者要求的其他用途的孔, 当在板子内部用Edge.Cuts层去绘制图形时,加工厂在加工时就会将图像内部进行掏空,如果有的加工厂不支持的话我们可以换一个加工厂,一般加工厂都是支持的, 在确定定位孔之前,我们要知道我们要用多大的螺丝,正常市面上常用的螺丝有M3,M2.5等,就是指螺丝的直径是3mm, 螺丝直径是3mm的,但是我们留的定位孔一定要大于3mm,一般3mm的螺丝我们留的定位孔就是3.2mm,这样做的原因就是可以保证螺丝能过穿过定位孔, 一般将情况下,会在板子的四个角各放置一个定位孔,或者根据需求放置也可以, 除了Edge.cuts边去绘制定位孔外,还可以通过添加封装的放置进行放置定位孔, 首先要再原理图中添加四个过孔符号-MountingHole,然后给这些符号分配好封装,选择对应大小的封装, 对于M3螺丝来讲,我们就选择M3的封装就可以了,但是此时我们可以看到M3的这个封装实际的直径就是3.2mm已经帮我们预留好了位置,所以直接选择M3即可, 更新原理图到PCB我们就可以看到四个定位孔了,把他们放置到相应位置即可 下面先给大家演示一下如何通过Edge.Cuts层去绘制定位孔,这边我先绘制了一个50x50mm的板子,接下来我们就给这个板子添加定位孔吧, 首先,我们在层的选项中选择Edge.Cuts层,然后点击绘制圆,如图所以{{ :hole0.png |}} 选择板边层 选择绘制圆工具,点击即可确定圆心位置拖动鼠标可以确定圆的半径,并会显示半径的大小,大家还可以右击这个圆然后找到属性,或者直接按快捷键E,此时会出现属性栏,里面包含圆的位置,半径大小,以及线的粗细,大家可以根据需求直接修改就可以了,非常方便,因为我们的螺丝是3mm的,所以我们的定位孔就设置为3.2mm的,所以这边的半径我们就选择1.6,其余我们就默认即可,将圆的圆心挪动到板子的一角,同理绘制其余三个圆,并放置到其他的角上如图,{{ ::hole1.png |}} 半径的确认{{ ::hole3.png |}} 定位孔的放置 这样做的目的就是方便后面定位孔的精准放置,我们根据需求将定位孔放置到板子上,以右上角的定位孔为例,右击这个圆,找到特殊工具-精确移动,或者快捷键Shift+M,点击之后弹出移动对话框,按照我的需求,要向左向下各移动3mm,可以看到我X设为-3,Y设为3,也就是说横向的移动向右为正 ,向左为负,纵向的移动向下为正,向上为负,同理根据这个规则我们,可以完场其余三个定位孔的放置如图{{ ::hole4.png |}} 定位孔的精确移动{{ ::hole5.png |}} 定位孔的精确移动 放置完成后我们看一下3D效果图,点击视图-3D查看器,或者快捷键Alt+3,如图所示,我们已经完成定位孔的绘制了。{{ ::hole6.png |}} 板子的3D查看器 下面通过另外一种方式给大家演示一下定位孔的绘制, 首先在原理图中添加四个定位孔符号-MountingHole,给符号进行标注从H1一直到H4,{{ ::hole1-0.png |}} 添加定位孔符号 给这个符号关联封装,直接选择MountingHole-3.2mm-M3的封装,点击应用即可,如图所示{{ ::hole1-2.png |}} 关联封装 回到原理图界面后,选择工具-从原理图更新到PCB,此时转到PCB界面,点击更新PCB,此时已添加了定位孔的封装如图:{{ ::hole1-3.png |}} 更新PCB封装 此时我们发现自己添加的封装和我们自己绘制的封装大小上有很大区别,但是当我们使用3D查看器查看时就会发现这个封装的定位孔和我们自己绘制的定位孔大小是一样的,最外层红色的是Courtyard,就是给我们预留了螺丝帽的位置,防止我们将器件放置的太靠近定位孔导致螺丝安装的时候固定不到底,所以建议大家在绘制定位孔时选择这种方式, 同样的我们把封装放置到板子的四个角,然后再通过精确移动放置到板子上如图: {{ ::hole1-4.png |}} 定位孔的放置 {{ ::hole1-5.png |}} 定位孔的精确移动 {{ ::hole1-6.png |}} 定位孔的精确移动 最后点击视图-3D查看器,可以看到第一中用Edge.Cuts的方式是一样的,但是用封装方式绘制的定位孔会显示H1-H4的丝印,根据个人需求选择是否显示。 {{ ::hole1-7.png |}} 3D查看器 The easiest way to create openings for requirements such as a screw or mounting holes, passing wires, or other component requirements, is to design them in the Edge.Cuts layer in the exact same way that you go about designing the board outline. Essentially, when you create a board internal outline, the manufacturer will treat it as a void, and carve material out of it. If your manufacturer does not support this method, you can either choose to switch to a manufacturer that does or use pads or other footprints that have the shape you want. You can also create your own footprints for this purpose. In this recipe, you will learn how to use the Edge.Cuts and pads methods. The instructions that follow build a board similar to the one I describe in the 'How to create a rounded corner' recipe. You can see our starting point in Figure 34.9. The only difference is that the one in this recipe is larger (144 mm x 76 mm) so that there is enough space in it for the openings. To create mounting holes for the screws, start by measuring the size of the screws you wish to use. This is done easily with a calliper if you have one (Figure 34.1). The screw I measured in Figure 34.1 has a width of 2.88 mm, so it will require an opening that is slightly larger than 2.88 mm. I would like to place four screw holes on the board, along with its outer corners. To make it easier to achieve opening diameters of around 2.95 mm or 3.0 mm, I will change the grid size to 0.508 mm. Let’s start with the first screw hole at the top left corner of the board. Click on the Circle tool to select it ( ). Place your mouse cursor across the top left rounded corner, inside the board outline, to a location that will allow you to draw a circle with at least a 3 mm diameter. This translates to 1.5 mm in radius. We will use the radius value because the KiCad status bars provide this as we draw the circle. The example in Figure 34.2 shows the process. Click to set the circle centre, and then drag the mouse and click again to define the circle radius. KiCad’s status bar displays the current radius as you draw the circle. Because of the grid size, I have selected, the closest value I can get to 1.5 mm for the radius is 1.524 mm. That is close enough, so I will click there to complete the drawing. Using my calliper, I have measured that the head of the screw is 5.39 mm, so that gives me a lot of tolerance to work with as I design the holes. You can look at the 3D rendering of the hole, in Figure 34.3. Repeat the same process to define the other three holes. Alternatively, because you want to create additional holes of the same size, you can duplicate the first hole by clicking on the hole outline to select it and typing Ctr-D. In Figure 34.4 you can see the board with all the screw holes in place. Figure 34.4: Five identical screw holes placed along the edges of the board. You can verify that your board is as expected by using the 3D Viewer. An alternative way to create mounting holes is to use a pad footprint, or even simpler, the via tool. Let’s try that next to place a sixth hole adjacent to the inner corner. Click on the via tool to select it ( ). Place your mouse over the location where you’d like to via to go and click. Next, you must define its size so that the screw can fit through it. Place your mouse over the via and type 'E' to bring up its properties. You can see the properties window in Figure 34.6, with the values that match the screw I plan to use. Take care to check the 'Locked' checkbox to prevent the via/screw hole from being moved later when you work on the components and traces. I defined the drill size diameter to 3.1 mm to accommodate the size of the screw. The via diameter must be larger than the drill, otherwise, KiCad will display an error message. I set the diameter to 3.3 mm (Figure 34.6). Figure 34.6: The via properties, appropriate for repurposing it as a screw hole. Click Ok to commit these values. You can see the end result in Figure 34.7. As with all vias, the one you just created is plated internally. A small amount of tin is also present on the surface, just around the hole. In the 3D representation of Figure 34.7 you may be able to see a very thin light-coloured line. This is not a problem for the new role of this via as a screw hole. Let’s do one more alternation of this board as part of this recipe. You can make intents and opening on the board to facilitate the routing of wires, or as provisions for mechanical characteristics of components. Let’s create a simple rectangular opening in the board. Working in the Edge.Cuts layer, use the line tool to create a rectangular opening ( ). Draw this rectangle on the right side of the board, as you can see in Figure 34.8. If your manufacturer is unable to work with internal cutouts in the Edge.cuts layer, you can still create them as custom footprints. Learn how to create footprints in the 'Creating a new footprint' recipe.