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)

     
li:pcb-rnd-subcircuit-v6 {
 ha:subc.2{
  ha:attributes {
   footprint = {2*3}
   refdes = CONN1
  }
#dimension 0 100 100 100 200 spacing 
  ha:data {
   li:padstack_prototypes {
# Square plated through hole 0mil/0mil
    ha:ps_proto_v6.0 {
     hdia = 39.3701mil
     hplated = 1
     htop = 0
     hbottom = 0
     li:shape {
      ha:ps_shape_v4 {
       clearance = 0
       li:ps_poly {
        -40mil;-40mil;  40mil;-40mil;
        40mil;40mil;  -40mil;40mil;
       }
       ha:layer_mask {
        top = 1
        copper = 1
       }
       ha:combining {
       }
      }
      ha:ps_shape_v4 {
       clearance = 0
       li:ps_poly {
        -40mil;-40mil;  40mil;-40mil;
        40mil;40mil;  -40mil;40mil;
       }
       ha:layer_mask {
        intern = 1
        copper = 1
       }
       ha:combining {
       }
      }
      ha:ps_shape_v4 {
       clearance = 0
       li:ps_poly {
        -40mil;-40mil;  40mil;-40mil;
        40mil;40mil;  -40mil;40mil;
       }
       ha:layer_mask {
        bottom = 1
        copper = 1
       }
       ha:combining {
       }
      }
      ha:ps_shape_v4 {
       clearance = 0
       li:ps_poly {
        -43mil;-43mil;  43mil;-43mil;
        43mil;43mil;  -43mil;43mil;
       }
       ha:layer_mask {
        top = 1
        mask = 1
       }
       ha:combining {
        sub = 1
        auto = 1
       }
      }
      ha:ps_shape_v4 {
       clearance = 0
       li:ps_poly {
        -43mil;-43mil;  43mil;-43mil;
        43mil;43mil;  -43mil;43mil;
       }
       ha:layer_mask {
        bottom = 1
        mask = 1
       }
       ha:combining {
        sub = 1
        auto = 1
       }
      }
     }

    }
# Round plated through hole 0mil/0mil
    ha:ps_proto_v6.1 {
     hdia = 39.3701mil
     hplated = 1
     htop = 0
     hbottom = 0
     li:shape {
      ha:ps_shape_v4 {
       clearance = 0
       ha:ps_circ {
        x = 0mil
        y = 0mil
        dia = 80mil
       }
       ha:layer_mask {
        top = 1
        copper = 1
       }
       ha:combining {
       }
      }
      ha:ps_shape_v4 {
       clearance = 0
       ha:ps_circ {
        x = 0mil
        y = 0mil
        dia = 80mil
       }
       ha:layer_mask {
        intern = 1
        copper = 1
       }
       ha:combining {
       }
      }
      ha:ps_shape_v4 {
       clearance = 0
       ha:ps_circ {
        x = 0mil
        y = 0mil
        dia = 80mil
       }
       ha:layer_mask {
        bottom = 1
        copper = 1
       }
       ha:combining {
       }
      }
      ha:ps_shape_v4 {
       clearance = 0
       ha:ps_circ {
        x = 0mil
        y = 0mil
        dia = 86mil
       }
       ha:layer_mask {
        top = 1
        mask = 1
       }
       ha:combining {
        sub = 1
        auto = 1
       }
      }
      ha:ps_shape_v4 {
       clearance = 0
       ha:ps_circ {
        x = 0mil
        y = 0mil
        dia = 86mil
       }
       ha:layer_mask {
        bottom = 1
        mask = 1
       }
       ha:combining {
        sub = 1
        auto = 1
       }
      }
     }

    }
   }
   li:objects {

    ha:padstack_ref.7 {
     proto = 0
     x = 0mil
     y = 0mil
     rot = 0
     smirror = 0; xmirror = 0
     clearance = 25mil
     ha:attributes {
      term = 1
     }
     li:thermal { }
     ha:flags { clearline = 1; }
    }

    ha:padstack_ref.8 {
     proto = 1
     x = 0mil
     y = 100mil
     rot = 0
     smirror = 0; xmirror = 0
     clearance = 25mil
     ha:attributes {
      term = 2
     }
     li:thermal { }
     ha:flags { clearline = 1; }
    }

    ha:padstack_ref.9 {
     proto = 1
     x = 0mil
     y = 200mil
     rot = 0
     smirror = 0; xmirror = 0
     clearance = 25mil
     ha:attributes {
      term = 3
     }
     li:thermal { }
     ha:flags { clearline = 1; }
    }

    ha:padstack_ref.10 {
     proto = 1
     x = 100mil
     y = 0mil
     rot = 0
     smirror = 0; xmirror = 0
     clearance = 25mil
     ha:attributes {
      term = 4
     }
     li:thermal { }
     ha:flags { clearline = 1; }
    }

    ha:padstack_ref.11 {
     proto = 1
     x = 100mil
     y = 100mil
     rot = 0
     smirror = 0; xmirror = 0
     clearance = 25mil
     ha:attributes {
      term = 5
     }
     li:thermal { }
     ha:flags { clearline = 1; }
    }

    ha:padstack_ref.12 {
     proto = 1
     x = 100mil
     y = 200mil
     rot = 0
     smirror = 0; xmirror = 0
     clearance = 25mil
     ha:attributes {
      term = 6
     }
     li:thermal { }
     ha:flags { clearline = 1; }
    }

   }
   li:layers {
    ha:subc-aux {
     lid = 0
     ha:type {
      top = 1
      misc = 1
      virtual = 1
     }
     li:objects {

      ha:line.4 {
       x1 = 0mil
       y1 = 0mil
       x2 = 39.3701mil
       y2 = 0mil
       thickness = 3.93701mil
       clearance = 0mil
       ha:attributes {subc-role = x}
       ha:flags {}
      }

      ha:line.5 {
       x1 = 0mil
       y1 = 0mil
       x2 = 0mil
       y2 = 39.3701mil
       thickness = 3.93701mil
       clearance = 0mil
       ha:attributes {subc-role = y}
       ha:flags {}
      }

      ha:line.6 {
       x1 = 0mil
       y1 = 0mil
       x2 = 0mil
       y2 = 0mil
       thickness = 3.93701mil
       clearance = 0mil
       ha:attributes {subc-role = origin}
       ha:flags {}
      }

     }
     ha:combining {
     }
    }
    ha:top-silk {
     lid = 0
     ha:type {
      top = 1
      silk = 1
     }
     li:objects {

      ha:text.3{
       scale = 100
       x = 0mil
       y = -100mil
       rot = 0
       string = %a.parent.refdes%
       fid = 0
       ha:flags {dyntext = 1;floater=1;}
      }

      ha:line.13 {
       x1 = -50mil
       y1 = -50mil
       x2 = -50mil
       y2 = 250mil
       thickness = 10mil
       clearance = 0mil
       ha:flags {}
      }

      ha:line.14 {
       x1 = -50mil
       y1 = -50mil
       x2 = 150mil
       y2 = -50mil
       thickness = 10mil
       clearance = 0mil
       ha:flags {}
      }

      ha:line.15 {
       x1 = 150mil
       y1 = 250mil
       x2 = -50mil
       y2 = 250mil
       thickness = 10mil
       clearance = 0mil
       ha:flags {}
      }

      ha:line.16 {
       x1 = 150mil
       y1 = 250mil
       x2 = 150mil
       y2 = -50mil
       thickness = 10mil
       clearance = 0mil
       ha:flags {}
      }

      ha:line.17 {
       x1 = -50mil
       y1 = 50mil
       x2 = 50mil
       y2 = 50mil
       thickness = 10mil
       clearance = 0mil
       ha:flags {}
      }

      ha:line.18 {
       x1 = 50mil
       y1 = -50mil
       x2 = 50mil
       y2 = 50mil
       thickness = 10mil
       clearance = 0mil
       ha:flags {}
      }

     }
     ha:combining {
     }
    }
   }
  }
  uid = Prm/3TkY34Vrzi9ZOx1APAAA
 }
}

Downloads:
footprint file