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.

  1. 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.
  2. 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.
  3. 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 into X PIN26 26 -750 600 300 R 50 50 1 1 I this is done for all lines in the file in.txt.

Simple script.

  1. #!/usr/bin/env python
  2. ''' simple script to manipulate KiCad component pins numbering'''
  3. import sys, re
  4. try:
  5. fin=open(sys.argv[1],'r')
  6. fout=open(sys.argv[2],'w')
  7. except:
  8. print "oh, wrong use of this app, try:", sys.argv[0], "in.txt out.txt"
  9. sys.exit()
  10. for ln in fin.readlines():
  11. obj=re.search("(X PIN)(\d*)(\s)(\d*)(\s.*)",ln)
  12. if obj:
  13. num = int(obj.group(2))+25
  14. ln=obj.group(1) + str(num) + obj.group(3) + str(num) + obj.group(5) +'\n'
  15. fout.write(ln)
  16. fin.close(); fout.close()
  17. #
  18. # for more info about regular expression syntax and KiCad component generation:
  19. # http://gskinner.com/RegExr/
  20. # http://kicad.rohrbacher.net/quicklib.php
  1. 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.

  1. EESchema-LIBRARY Version 2.3
  2. #encoding utf-8
  3. # COMP
  4. DEF COMP U 0 40 Y Y 1 F N
  5. F0 "U" -1800 -100 50 H V C CNN
  6. F1 "COMP" -1800 100 50 H V C CNN
  7. DRAW
  8. S -2250 -800 -1350 800 0 0 0 N
  9. S -450 -800 450 800 0 0 0 N
  10. X PIN1 1 -2550 600 300 R 50 50 1 1 I
  11. ...
  12. X PIN49 49 750 -500 300 L 50 50 1 1 I
  13. ENDDRAW
  14. ENDDEF
  15. #End Library

gsik_high_number_pins_png

  1. 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/.