**这是本文档旧的修订版!**
第38节:创建一个库中没有的元器件封装
After creating a new schematic symbol, you may need to create a matching footprint. In this recipe, you will learn how to do this manually. For some types of footprints, KiCad has introduced a wizard that can accelerate the process. There is a separate recipe that covers that option. As with creating a new symbol, to create a new custom footprint you will need some mechanical information from the real-world component’s datasheet. If you don’t have a datasheet, you can use a calliper to take measurements. I usually use both datasheet and calliper together. The datasheet gives me the mechanical values I need for the drawing of the component (width and height of the package, pins and their positions, pin attributes etc.), and then I use the calliper to confirm the dimension and distance values. In recipe 'Creating a new component (symbol)' you created a custom symbol for the 555 integrated circuit. In this recipe, you will create a footprint for that symbol. Creating footprints is a slightly more involved process than creating a symbol because we have to consider the physical characteristics of the device, and the manufacturing requirements. We have to think about how to place information about the footprint in the various physical and design layers that KiCad uses for this purpose. For example, information about the boundary of the footprint is placed in the courtyard layer, pads are placed in the copper layers (front and back), the outline of the footprint goes in the fabrication layer, and any artwork (text and graphics) goes to the silkscreen. In Figure 37.1 you can see the elements that make up a typical KiCad footprint, and the layers where those elements are placed. The footprint in Figure 37.1 is what you will work towards creating in this recipe, even though it already exists in a library that you can import.
To create the footprint in Figure 37.1, you will work through a process in which you place the elements in one layer. The real component for which you will design this footprint is shown in Figure 37.2. Figure 37.2: You will create a footprint for this component, the NE555N timer integrated circuit. The component in Figure 37.2 has a standard DIP package with 4 pins on each side. The data sheet is available from its manufacturer. From the datasheet, you will need the mechanical data illustration towards the end of the document. For your convenience, I have included this illustration in Figure 37.2.
You will create this footprint by following this process: 1. In the front fabrication layer ('F.Fab') you will draw the outline of the footprint. The fabrication layers (front and back) are used by the manufacturer. Their elements do not appear in the end result. 2. In the top and bottom copper layers, you will draw the pads. 3. In the front courtyard layer ('F.CrtYd'), you will draw the external outline of the footprint. No other footprint will be allowed within this outline. 4. In the front silkscreen layer ('F.SilkS'), you will add text and graphics, such as the corners of the DIP package and the side where pin 1 is facing. Let’s begin. From the main KiCad window, click on the Footprint Library Editor button (Figure 37.3).
The Footprint Editor window will appear. From the File menu, select 'New Footprint' (Figure 37.4). Figure 37.4: Create a new Footprint. The Editor will prompt for a name for the new footprint. Since we are creating a footprint for a DIP component with 8 pins and 7.62 mm width (including the pins), type in this name: 'DIP-8W7.62mmPD'. I added my initials, to differentiate from other DIP-8 footprints that might be available in other libraries. Of course, use your own initials. Click on Ok to dismiss the dialog. The Editor will show an almost blank sheet. Its only content is two text blocks, one in the front fabrication area (the name of the footprint), and one in the front silkscreen area ('REF**'). Front Fabrication layer ('F.Fab') - Outline Continue with the front fabrication layer. Select 'F.Fab' from the layers manager, and use the polygon tool to draw a rectangle in the dimensions of the DIP package. Those dimensions appear in the documentation. Working in millimetres, you should draw a rectangle that is 6.60 mm in width and 10.16 mm in length. You will need to adjust the grid to make it easier to achieve those dimensions, or at least as close to them as you can get. I set my grid to 0.1270 mm and I was able to create a rectangle with the exact 6.60 mm x 10.16 mm dimensions. Also, change the cursor shape so that the crosshairs extend to the edges of the sheet, and use the dx and dy values in the status line to know the length of each segment of the rectangle as you draw it. In Figure 37.5, the arrows point to the tools that you use and functions you should enable to draw the outline of the footprint. The exact point where you start drawing is not important.
Draw the first horizontal line of the outline to a length of 6.60 mm. In Figure 37.6 notice that the dx value is 6.60 mm. Click at that point, and continue with the first vertical line. Figure 37.6: The first line, at 6.60 mm, is complete. Extend the vertical line to 10.16 mm. Use the crosshairs to help you create a perfect 90-degree angle between the two lines (Figure 37.7).
Complete the rectangle so that in the end you have something like the example in Figure 37.8. Figure 37.8:The completed outline in the F.Fab layer. Pads Continue with the placement of the pads. As per the data sheet’s mechanical specifications, the pad centres must be 2.54 mm apart. The pin diameter is 0.25 mm, so the pad drill must be slightly larger than that. The specification doesn’t give us the exact offset of the pins from the body of the device, so we will have to use our judgement or a calliper. I used my calliper to find that the offset is around 1 mm. With this information, let's go ahead and place the pads. Keep the grid size to 0.127 mm since this works well with the 2.54 pad pitch we are working with. That is because 2.54 is a multiple of 0.127. From the right toolbar, click on the pad tool ( ). Follow these steps: 1. Move the pad to the top left of the outline. 2. Align the crosshair centre exactly on the vertical line, around 1 mm from the corner.
- Press the space bar to zero the dx, dy and dist values of the status
- Move the pointer slightly to the left, to separate the pad from the outline. At dx at 0.63 mm, I think this distance is good. It is smaller than the 1 mm that I measured with my calliper, but since the device pins are flexible, I opt to a narrower rather than a wider footprint.
- Ensure that dx is still at 0.63 mm and click to commit the pad in place. After clicking your mouse, do not move it until you press the space bar again to reset dx and dy. This will allow you to measure the distance between this pad and the next. Don’t worry about the negative sign in the dx value, we are only interested in absolute values when we measure distances for the purposes of creating this new footprint. The result is similar to what you can see in Figure 37.9. Figure 37.9: The first pad is in place. The pad tool is still enabled, and the second pad is attached to the cursor, waiting to be placed. Hopefully, you reset dx and dy as soon as you clicked to commit pad 1. If you didn’t, move the cursor over pad 1, and press the spacebar to reset the counters. Then, follow this process:
- Move the mouse downwards making sure that dx is always zero.
- Look at the dy counter, and stop moving the mouse when it reads '2.54 mm'.
- When dy becomes 2.54 mm, click your mouse to place pad 2 in position.
- Press the space bar to reset dy to zero.
- Repeat this process until you have all four pads on the left of the footprint’s outline. 390 When you place pad 4 in position, you must move the mouse across to the other side of the outline. To ensure that pad 5 is exactly horizontal from pad 4, place your mouse pointer exactly over pad 4, and press the spacebar. Then move the mouse to the right, making sure that dy is always zero. Place pad 5 in position so that it is exactly 0.63 mm from the right vertical line and click to commit it in place. Your footprint should look like the example in Figure 37.10. Continue to place pads 6, 7 and 8 in the same way. Eventually, your footprint will look like the example in Figure 37.11. Figure 37.11: All footprints in place. Before you continue work in the other layers, you should check that the footprint drills are appropriate for the pin size of the physical device. You should also change the pad type of pad 1 to rectangular instead of circular. This is due to a convention that holds that the first pin of an integrated circuit should be square to make it possible to identify the correct orientation of the chip during assembly. We will do this now, but we will also add graphics in the silkscreen to reduce the risk of error in assembly. To configure a pad, use the pad’s Properties window. Place your mouse cursor over the first pad, and type 'E'. This will bring up the pad’s Properties window. As you can see in Figure 37.12, you should change the Pad shape to rectangular. You can also confirm that the hole size is 0.762 mm, which is sufficiently larger than the pin diameter, so there is no need to change this. You can also confirm that for this pad, copper will be poured in all copper layers. If you have a good reason for doing so (perhaps you are designing a single layer board that you want to etch at home?), then you can change this setting to a bottom copper layer. If you were creating an SMD pad, you could specify the top or bottom copper layer. You can leave the rest of the pads as they are, no changes are needed. Your footprint should look like the example in Figure 37.12. Figure 37.12: The footprint, with fabrication layer and pads completed. Front Courtyard layer ('F.CrtYd') Let’s continue with the front courtyard layer ('F.CrtYd') where you will create the outline of the boundary for the footprint. From the Layer Manager, 392 select 'F.CrtYd'. Your objective is to draw a rectangle around the footprint that encloses the pads and the footprint outline. Allow sufficient space around the pads to ensure that they cannot overlap with other footprints. Select the polygon drawing tool and start drawing from the top right corner of the footprint (Figure 37.13).
Draw the rectangle around the footprint until the polygon is fully enclosed. In the end, your footprint should look like the example in Figure 37.14. The rectangle around the footprint is the boundary as defined in the front courtyard layer. Figure 37.14: The line around the footprint is the front courtyard outline. Front Silkscreen While your footprint is now functionally ready, you should spend a few more minutes to add informational text and graphics in the front silkscreen ('F.SilkS') layer. Since you are working on the footprint of an integrated circuit, at the very least you should mark the location of pin 1. Let’s do that now. Select 'F.SilkS' from the Layer Manager. Select the polygon tool. Draw four lines to mark the outline of the IC on the board, like in the example of Figure 37.15. Figure 37.15:In the F.SilkS layer, mark the edges of the footprint. Also draw a circle that indicates the position of pin 1, using the circle tool. The end result is in Figure 37.16. Figure 37.16: A circle in the F.SilkS layer indicates the position of pin 1. Tidy up You are almost finished with this design. Time to tidy up before saving the new footprint. Use the 'M' hotkey to move the text blocks over and below the footprint. Select the complete footprint, including the text block, and move it over the center of the axes. The final footprint is in Figure 37.17.
Save the footprint The last thing you must do before you can use your custom footprint is to save it. If you already have a folder for your custom footprints with the '.pretty' extension, you can use that to store the new footprint. If not, create this folder now. Then, click on the 'Export' button from the top toolbar (Figure 37.18). Figure 37.18: Use the Export button to save the new footprint. This will bring up the Export Footprint window. Navigate to your .pretty folder, give your new footprint a name (or accept the default, as I do), and click on Save (Figure 37.19). Figure 37.19: Save the new footprint. Test the footprint Let’s go back to Pcbnew to test your new footprint by adding it to the sheet. If the .pretty folder that contains your new footprint is not in the libraries table, add it now (Figure 37.20). You can learn how to do this in the relevant recipe. Once that is done, use the 'O' hotkey to add a new footprint. Use the browser to navigate the list of libraries. Find your custom library, and in it, you will find your new footprint (Figure 37.21). Figure 37.21: Select your new footprint from the library browser. Double click on the footprint, and Pcbnew will place it on the sheet (Figure 37.22). Well done, this was a long process. You now have a custom footprint that you can use in your layouts as you do with any other footprint.