pcblib-param test page

"Do you remember the good old days? When I was
young, I said footprint=CONNECTOR 2 13
in gschem and got a 2*13 pin connector in PCB."

 
 

Syntax

In pcb-rnd, automatic footprint generation on the fly is called "parametric footprints". It is a smaller and more generic infrastructure compared to the m4 footprints in pcb. The goal was to fix three problems.

  • 1. Languages: m4 should not be mandatory for footprint generators - the user should be free to choose any language
  • 2. Simplicity: references to m4 should not be hardwired in pcb, gsch2pcb and gsch2pcb.scm, but footprint generation should be generic, transparent and external
  • 3. Unambiguity: gsch2pcb should not be guessing whether to use file elements or call a generator. Instead of complex heuristics, there should be a simple, distinct syntax for parametric footprints.

The new syntax is that if a footprint attribute contains parenthesis, it is a parametric footprint, else it is a file footprint. Parametric footprints are sort of a function call. The actual syntax is similar to the one in openscad : parameters are separated by commas, and they are either positional (value) or named (name=value).

For example a simple pin-grid connector has the "prototype" of connector(nx, ny, spacing), where nx and ny are the number of pins needed in X and Y directions, spacing is the distance between pin centers, with a default of 100 mil. The following calls will output the same 2*3 pin, 100 mil footprint:

  • connector(2, 3)
  • connector(2, 3, 100)
  • connector(nx=2, ny=3, spacing=100)
  • connector(spacing=100, nx=2, ny=3)
  • connector(ny=3, spacing=100, nx=2)
   

Generators available

Try it online

source:

Result

connector(2,3)

     
Element["" "connector(2,3)" "CONN1" "2*3" 0 0 0 -10000 0 100 ""]
(
	Pin[0 0 8000 5000 8600 3937 "" "1" "square"]
	Pin[0 10000 8000 5000 8600 3937 "" "2" ""]
	Pin[0 20000 8000 5000 8600 3937 "" "3" ""]
	Pin[10000 0 8000 5000 8600 3937 "" "4" ""]
	Pin[10000 10000 8000 5000 8600 3937 "" "5" ""]
	Pin[10000 20000 8000 5000 8600 3937 "" "6" ""]
	ElementLine[-5000 -5000 -5000 25000 1000]
	ElementLine[-5000 -5000 15000 -5000 1000]
	ElementLine[15000 25000 -5000 25000 1000]
	ElementLine[15000 25000 15000 -5000 1000]
	ElementLine[-5000 5000 5000 5000 1000]
	ElementLine[5000 -5000 5000 5000 1000]
#dimension 0 10000 10000 10000 20000 spacing 
)

Downloads:
footprint file