6.4. Make a high pin count schematic component
6.4. Make a high pin count schematic component
In the section titled Make Schematic Components in quicklib we saw how to make a schematic component using the quicklib web-based tool. However, you will occasionally find that you need to create a schematic component with a high number of pins (some hundreds of pins). In KiCad, this is not a very complicated task.
- Suppose that you want to create a schematic component for a device with 50 pins. It is common practise to draw it using multiple low pin-count drawings, for example two drawings with 25 pins each. This component representation allows for easy pin connection.
- The best way to create our component is to use quicklib to generate two 25-pin components separately, re-number their pins using a Python script and finally merge the two by using copy and paste to make them into one single DEF and ENDDEF component.
- You will find an example of a simple Python script below that can be used in conjunction with an in.txt file and an out.txt file to re-number the line:
X PIN1 1 -750 600 300 R 50 50 1 1 I
intoX PIN26 26 -750 600 300 R 50 50 1 1 I
this is done for all lines in the file in.txt.
Simple script.
#!/usr/bin/env python
''' simple script to manipulate KiCad component pins numbering'''
import sys, re
try:
fin=open(sys.argv[1],'r')
fout=open(sys.argv[2],'w')
except:
print "oh, wrong use of this app, try:", sys.argv[0], "in.txt out.txt"
sys.exit()
for ln in fin.readlines():
obj=re.search("(X PIN)(\d*)(\s)(\d*)(\s.*)",ln)
if obj:
num = int(obj.group(2))+25
ln=obj.group(1) + str(num) + obj.group(3) + str(num) + obj.group(5) +'\n'
fout.write(ln)
fin.close(); fout.close()
#
# for more info about regular expression syntax and KiCad component generation:
# http://gskinner.com/RegExr/
# http://kicad.rohrbacher.net/quicklib.php
- While merging the two components into one, it is necessary to use the Library Editor from Eeschema to move the first component so that the second does not end up on top of it. Below you will find the final .lib file and its representation in Eeschema.
Contents of a *.lib file.
EESchema-LIBRARY Version 2.3
#encoding utf-8
# COMP
DEF COMP U 0 40 Y Y 1 F N
F0 "U" -1800 -100 50 H V C CNN
F1 "COMP" -1800 100 50 H V C CNN
DRAW
S -2250 -800 -1350 800 0 0 0 N
S -450 -800 450 800 0 0 0 N
X PIN1 1 -2550 600 300 R 50 50 1 1 I
...
X PIN49 49 750 -500 300 L 50 50 1 1 I
ENDDRAW
ENDDEF
#End Library
- The Python script presented here is a very powerful tool for manipulating both pin numbers and pin labels. Mind, however, that all its power comes for the arcane and yet amazingly useful Regular Expression syntax: http://gskinner.com/RegExr/.