added BKA30D footprint and symbol

This commit is contained in:
2021-04-07 10:18:07 +02:00
parent 6a1e13359f
commit f600b08e83
32 changed files with 1608 additions and 0 deletions

BIN
BOM scripts/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,44 @@
# KiCad JLCPCB BOM Plugin
Export a JLCPCB Compatible BOM directly from your KiCad schematic!
## Installation
This script requires **Python 3**. If you need a Python 2 version, please get
[kicad-jlcpcb-bom-plugin version 1.0.0](https://github.com/wokwi/kicad-jlcpcb-bom-plugin/releases/tag/1.0.0) instead.
The script has been tested with KiCad 5.1.4.
1. Copy `bom_csv_jlcpcb.py` to your KiCad installation folder under the `bin/scripting/plugins` directory
2. In Eschema (the Schematics editor) go to "Tools" -> "Generate Bill of Materials", press the "+" button
at the bottom of the screen, and choose the plugin file you have just copied. When asked for a nickname,
go with the default, "bom_csv_jlcpcb".
## Usage
Instructions for exporting JLCPCB BOM from KiCad's Eschema:
1. Go to "Tools" -> "Generate Bill of Materials"
2. Choose "bom_csv_jlcpcb" from the "BOM plugins" list on the left
3. Make sure the command line ends with "%O.csv" (otherwise, change "%O" into "%O.csv")
4. Click on "Generate". The BOM file should be created inside your project's directory, as a CSV file.
## Custom Fields
You can customize the script's output by adding the following fields to your components:
1. "LCSC Part" - Add this field to include an LCSC Part number in the generated BOM. e.g.: C2286 for a red LED.
2. "JLCPCB BOM" - Set this field to 0 (or "False") to omit the component from the generated BOM.
## Generating a JLCPCB CPL File
You can use the `kicad_pos_to_cpl.py` script to convert a KiCad Footprint Position (.pos) file into a CPL file
compatible with JLCPCB SMT Assembly service. The `.pos` file can be generated from Pcbnew, by going into
"File" -> "Fabrication Outputs" -> "Footprint Position (.pos) File..." and choosing the following options:
* Format: CSV
* Units: Millimeters
* Files: Separate files for front and back
Also, make sure to uncheck "Include footprints with SMD pads even if not marked Surface Mount".

View File

@@ -0,0 +1,51 @@
#
# Example python script to generate a BOM from a KiCad generic netlist
#
# Example: Sorted and Grouped CSV BOM
#
"""
@package
Generate a CSV BOM for use with JLCSMT service.
Components are sorted by ref and grouped by value with same footprint
Fields are (if exist).
LCSC Part numbers are copied from the "LCSC Part" field, if exists.
It is possible to hide components from the BOM by setting the
"JLCPCB BOM" field to "0" or "false".
Output fields:
'Comment', 'Designator', 'Footprint', 'LCSC Part #'
Command line:
python "pathToFile/bom_csv_jlcsmt.py" "%I" "%O.csv"
"""
import kicad_netlist_reader
import csv
import sys
net = kicad_netlist_reader.netlist(sys.argv[1])
with open(sys.argv[2], 'w', newline='') as f:
out = csv.writer(f)
out.writerow(['Comment', 'Designator', 'Footprint', 'LCSC Part #'])
for group in net.groupComponents():
refs = []
lcsc_pn = ""
for component in group:
if component.getField('JLCPCB BOM') in ['0', 'false', 'False', 'FALSE']:
continue
refs.append(component.getRef())
lcsc_pn = component.getField("LCSC Part") or lcsc_pn
c = component
if len(refs) == 0:
continue
# Fill in the component groups common data
out.writerow([c.getValue() + " " + c.getDescription(), ",".join(refs), c.getFootprint().split(':')[1],
lcsc_pn])
f.close()

View File

@@ -0,0 +1,41 @@
#!/usr/bin/env python3
# coding=utf8
# Converts a KiCad Footprint Position (.pos) File into JLCPCB compatible CPL file
# Copyright (C) 2019, Uri Shaked. Released under the MIT license.
#
# Usage: kicad_pos_to_cpl.py <input.csv> <output.csv> [overrides.json]
#
# The overrides file is a JSON file that contains a single object. The key of that object
# is the reference of the part of override, and the value is the amount of degrees to
# add to the part's rotation. For instance, to rotate U1 by 90 degrees, and Q1 by 180
# degrees, put the following value in the overrides.json file:
# { "U1": 90, "Q1": 180 }
import sys
import csv
import json
from collections import OrderedDict
overrides = {}
if len(sys.argv) == 4:
with open(sys.argv[3], 'r') as overrides_file:
overrides = json.load(overrides_file)
with open(sys.argv[1], 'r') as in_file, open(sys.argv[2], 'w', newline='') as out_file:
reader = csv.DictReader(in_file)
ordered_fieldnames = OrderedDict([('Designator',None),('Mid X',None),('Mid Y',None),('Layer',None),('Rotation',None)])
writer = csv.DictWriter(out_file, fieldnames=ordered_fieldnames)
writer.writeheader()
for row in reader:
angle_adjustment = overrides.get(row['Ref'], 0)
writer.writerow({
'Designator': row['Ref'],
'Mid X': row['PosX'] + 'mm',
'Mid Y': row['PosY'] + 'mm',
'Layer': row['Side'].capitalize(),
'Rotation': (360 + int(float(row['Rot']) + angle_adjustment)) % 360
})

View File

@@ -0,0 +1,4 @@
Kicad plugins
=============
These are some plugins for the kicad pcb design tool. So far just `bom2csv.xsl`, which is an adaptation of Stefan Helmert's original XSLT code. Instructions are in the file header.

View File

@@ -0,0 +1,109 @@
<!--XSL style sheet to convert EESCHEMA XML Partlist Format to CSV BOM Format
Copyright (C) 2013, Stefan Helmert
with later changes by Andrew Baxter 2016
GPL v2.
Functionality:
Generation of csv table with table head of all existing field names
and correct assigned cell entries
How to use this is explained in eeschema.pdf chapter 14. You enter a command line into the
netlist exporter using a new (custom) tab in the netlist export dialog. The command is
similar to
on Windows:
xsltproc -o "%O.csv" "C:\Program Files (x86)\KiCad\bin\plugins\bom2csv.xsl" "%I"
on Linux:
xsltproc -o "%O.csv" /usr/local/lib/kicad/plugins/bom2csv.xsl "%I"
Instead of "%O.csv" you can alternatively use "%O" if you will supply your own file extension when
prompted in the UI. The double quotes are there to account for the possibility of space(s)
in the filename.
-->
<!--
@package
Generate a Tab delimited list (csv file type).
Components are grouped by a set of unique fields, and sorted usefully.
Component references in the same group are aggregated, and a quantity field is added.
This assumes that you have fields 'Tolerance', 'Package', and 'Product code' as well as the standard fields. If you want to group on other custom fields, you'll need to edit this file accordingly.
-->
<!DOCTYPE xsl:stylesheet [
<!ENTITY nl "&#xd;&#xa;"> <!--new line CR, LF, or LF, your choice -->
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<!-- for table head and empty table fields-->
<xsl:key name="headentr" match="field" use="@name"/>
<xsl:key name="groupon" match="components/comp" use="concat(translate(@ref,'0123456789', ''), '|', value, '|', fields[@name = 'Tolerance'], '|', fields[@name = 'Package'], '|', fields[@name = 'Product code'])"/>
<!-- main part -->
<xsl:template match="/export">
<xsl:text>Reference Type, Quantity, Reference, Value, Footprint, Datasheet</xsl:text>
<!-- find all existing table head entries and list each one once -->
<xsl:for-each select="components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
<xsl:text>, </xsl:text>
<xsl:value-of select="@name"/>
</xsl:for-each>
<xsl:text>&nl;</xsl:text>
<!-- all table entries -->
<xsl:apply-templates select="components/comp[generate-id(.) = generate-id(key('groupon', concat(translate(@ref,'0123456789', ''), '|', value, '|', fields[@name = 'Tolerance'], '|', fields[@name = 'Package'], '|', fields[@name = 'Product code'])))]">
<xsl:sort select="translate(@ref,'0123456789','')"/>
<xsl:sort select="translate(value,'0123456789.','')"/>
<xsl:sort select="translate(value,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_','')" data-type="number"/>
<xsl:sort select="fields/field[@name='Product code']"/>
</xsl:apply-templates>
</xsl:template>
<!-- the table entries -->
<xsl:template match="components/comp">
<xsl:text>"</xsl:text>
<xsl:value-of select="translate(@ref,'0123456789','')"/><xsl:text>","</xsl:text>
<xsl:value-of select="count(key('groupon', concat(translate(@ref,'0123456789', ''), '|', value, '|', fields[@name = 'Tolerance'], '|', fields[@name = 'Package'], '|', fields[@name = 'Product code'])))"/><xsl:text>","</xsl:text>
<xsl:for-each select="key('groupon', concat(translate(@ref,'0123456789', ''), '|', value, '|', fields[@name = 'Tolerance'], '|', fields[@name = 'Package'], '|', fields[@name = 'Product code']))">
<xsl:value-of select="@ref"/><xsl:text>,</xsl:text>
</xsl:for-each>
<xsl:text>","</xsl:text>
<xsl:value-of select="value"/><xsl:text>","</xsl:text>
<xsl:value-of select="footprint"/><xsl:text>","</xsl:text>
<xsl:value-of select="datasheet"/>
<xsl:text>"</xsl:text>
<xsl:apply-templates select="fields"/>
<xsl:text>&nl;</xsl:text>
</xsl:template>
<!-- table entries with dynamic table head -->
<xsl:template match="fields">
<!-- remember current fields section -->
<xsl:variable name="fieldvar" select="field"/>
<!-- for all existing head entries -->
<xsl:for-each select="/export/components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
<xsl:variable name="allnames" select="@name"/>
<xsl:text>,"</xsl:text>
<!-- for all field entries in the remembered fields section -->
<xsl:for-each select="$fieldvar">
<!-- only if this field entry exists in this fields section -->
<xsl:if test="@name=$allnames">
<!-- content of the field -->
<xsl:value-of select="."/>
</xsl:if>
<!--
If it does not exist, use an empty cell in output for this row.
Every non-blank entry is assigned to its proper column.
-->
</xsl:for-each>
<xsl:text>"</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>