From 13f3e2dc3f3593779f9d0805b366b4b767820e56 Mon Sep 17 00:00:00 2001 From: Stephen John Cholvat Date: Tue, 22 Aug 2017 21:38:26 -0700 Subject: [PATCH 1/3] Created initial script- needs more testing --- bom/generate_warg_bom.py | 47 ++++++++++++++++++++++++++++++++++++++++ component_library.csv | 4 ++-- 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 bom/generate_warg_bom.py diff --git a/bom/generate_warg_bom.py b/bom/generate_warg_bom.py new file mode 100644 index 0000000..64543be --- /dev/null +++ b/bom/generate_warg_bom.py @@ -0,0 +1,47 @@ +import sys, os +import xml.etree.ElementTree as ET +import csv + +def main(): + if(len(sys.argv) != 3): + print "Make sure there are only 2 arguments!" #The user passes 2 arguments and the 1st argument is always the script filepath + filepath, input_filename, output_filename = sys.argv + output_filename += ".csv" + + #get filename for component library + component_lib_filename = os.path.join(os.path.dirname(filepath), os.pardir, 'component_library.csv') + + #output_dict stores the data to be written to csv + #found_parts is used to quickly find what index a component is at in the output_dict + output_dict = [] + found_parts = [] + + #parse xml netlist + tree = ET.parse(input_filename) + root = tree.getroot() + + #find all part numbers + for field in root.findall(".//*[@name='part_num']"): + if field.text not in found_parts: + found_parts.append(field.text) + output_dict.append({"part_num":field.text, + "quantity":1}) + else: + output_dict[found_parts.index(field.text)]["quantity"] +=1 + + reader = csv.DictReader(open(component_lib_filename, 'rb')) + component_library = [] + for line in reader: + if line["part_num"] in found_parts: + #add the extra information from the component library + output_dict[found_parts.index(line["part_num"])].update(line) + + #write the csv + with open(output_filename, 'wb') as output_file: + dict_writer = csv.DictWriter(output_file, output_dict[0].keys()) + dict_writer.writeheader() + dict_writer.writerows(output_dict) + print "wrote to {} file.".format(output_filename) + +if __name__ == "__main__": + main() diff --git a/component_library.csv b/component_library.csv index aac2fae..cdf8b5d 100644 --- a/component_library.csv +++ b/component_library.csv @@ -1,4 +1,4 @@ -WARG-part-#,Distrubuter,Distributer #,description,Manufacturer Part #,Inventory,Inventory Date,Alternative distributer #s,cost (qty. 1 CAD),Value,Footprint,link +part_num,Distrubuter,Distributer #,description,Manufacturer Part #,Inventory,Inventory Date,Alternative distributer #s,cost (qty. 1 CAD),Value,Footprint,link CAPP-001,Digi-Key,1276-1119-1-ND ,CAP CER 10UF 6.3V X5R 0603,,31,6/18/17,445-7492-1-ND / 490-3896-1-ND / 445-4112-1-ND,,,, CAPP-002,Digi-Key,1276-1104-1-ND,CAP CER 0.022UF 50V 10% X7R 0603,,100,6/18/17,,,,, CAPP-003,Digi-Key,1276-6504-1-ND,CAP CER 22UF 10V X5R 0603,,0,6/18/17,,,,, @@ -62,4 +62,4 @@ CAPP-008,,587-2909-1-ND,CAP CER 2.2UF 25V 10% X5R 0603,,99,6/18/17,,,,, CAPP-004,,587-1262-1-ND,CAP CER 1.0UF 16V Y5V 0603,,90,6/18/17,,,,, CAPP-005,,490-3285-1-ND,CAP CER .1UF 100V X7R 0603,,1,6/18/17,,,,, CAPP-004,,399-5090-1-ND,CAP CERAMIC 1.00UF 16V X5R 0603,,83,6/18/17,,,,, -RESS-003,,311-100KGRCT-ND,RES SMD 100K OHM 5% 1/10W 0603,,100,6/18/17,,,,, \ No newline at end of file +RESS-003,,311-100KGRCT-ND,RES SMD 100K OHM 5% 1/10W 0603,,100,6/18/17,,,,, From 016e85223b6e52ab86e27a5d0ce4374e243942c1 Mon Sep 17 00:00:00 2001 From: Stephen John Cholvat Date: Wed, 23 Aug 2017 12:01:11 -0700 Subject: [PATCH 2/3] Cleaned up component library --- bom/generate_warg_bom.py | 4 +++- component_library.csv | 42 ++++++++++++++++++++-------------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/bom/generate_warg_bom.py b/bom/generate_warg_bom.py index 64543be..9b052e5 100644 --- a/bom/generate_warg_bom.py +++ b/bom/generate_warg_bom.py @@ -32,7 +32,9 @@ def main(): reader = csv.DictReader(open(component_lib_filename, 'rb')) component_library = [] for line in reader: - if line["part_num"] in found_parts: + if "part_num" not in line: + print "line doesn't have part number!" , line + elif line["part_num"] in found_parts: #add the extra information from the component library output_dict[found_parts.index(line["part_num"])].update(line) diff --git a/component_library.csv b/component_library.csv index cdf8b5d..74735d3 100644 --- a/component_library.csv +++ b/component_library.csv @@ -11,7 +11,7 @@ CAPP-009,Digi-Key,732-7773-1-ND,CAP CER 6.8PF 25V C0G/NP0 0603,,0,6/18/17,,,,, CAPP-010,Digi-Key,490-1512-1-ND,CAP CER 10000PF 50V X7R 0603,,0,6/18/17,,,,, CHIP-001,Digi-Key,497-16632-ND,IC MCU 32BIT 1MB FLASH 144LQFP,STM32F765ZGT6,0,6/17/17,,21.52,,,https://www.digikey.ca/short/3dcvbt CHIP-002,Digi-Key,NC7SZ125P5XCT-ND,IC BUFF TRI-ST UHS N-INV SC70-5,,0,6/17/17,,0.55,,,https://www.digikey.ca/products/en?keywords=NC7SZ125P5XCT-ND -CHIP-003,Digi-Key,497-14045-ND,IC MCU 32BIT 64KB FLASH 64LQFP,,0,6/17/17,,3.3,,,https://www.digikey.ca/product-detail/en/stmicroelectronics/STM32F030R8T6/497-14045-ND/4357253 +CHIP-003,Mouser,511-STM32F030RCT6,"ARM Microcontrollers - MCU Entry-level ARM Cortex-M0 Value line MCU with up to 256 Kbytes Flash, 48 MHz CPU",,0,6/17/17,,3.3,,,https://www.digikey.ca/product-detail/en/stmicroelectronics/STM32F030R8T6/497-14045-ND/4357253 CHIP-004,Digi-Key,NLAS4599DFT2GOSCT-ND,IC SWITCH SPDT SC88,NLAS4599DFT2G,0,6/17/17,,0.64,,,https://www.digikey.ca/products/en?keywords=NLAS4599DFT2GOSCT-ND CONN-001,Digi-Key,WM18886-ND,SPOX-2 Male,,24,6/17/17,,0.71,,,https://www.digikey.ca/products/en?keywords=WM18886-ND CONN-002,Digi-Key,WM18887-ND,SPOX-3 Male,,13,6/17/17,,0.73,,,https://www.digikey.ca/product-detail/en/molex-llc/22-03-5035/WM18887-ND/403302 @@ -23,14 +23,14 @@ CONN-007,,See CONN-009,3 pin male header,See CONN-009,Fuck Ton,6/17/17,,0,,, CONN-008,,See CONN-009,4 pin male header,See CONN-009,Fuck Ton,6/17/17,,0,,, CONN-009,,,male headers,,Fuck Ton,6/17/17,,,,,https://www.digikey.ca/product-detail/en/on-semiconductor/NLAS4599DFT2G/NLAS4599DFT2GOSCT-ND/964598 CONN-010,,See CONN-009,2x5 male header,See CONN-009,0,6/17/17,,,,, -DIOD-001,Digi-Key,MMSZ4691T1GOSCT-ND,DIODE ZENER 6.2V 500MW SOD123,,0,6/18/17,,,,, +DIOD-001,Digi-Key,MMSZ5234BT1GOSCT-ND,DIODE ZENER 6.2V 500MW SOD123,,0,6/18/17,,,,, DIOD-002,Digi-Key,160-1446-1-ND,LED GREEN CLEAR 0603 SMD,,0,6/18/17,,,,, DIOD-003,Digi-Key,160-1447-1-ND,LED RED CLEAR 0603 SMD,,0,6/18/17,,,,, DIOD-004,Digi-Key,1N4448HLPDIDKR-ND,DIODE GEN PURP 80V 125MA 2DFN,,0,6/18/17,,,,, FUSE-001,Digi-Key,P15118CT-ND,FUSE BOARD MOUNT 3A 32VDC 0603,,0,6/18/17,,,,, INDU-001,Digi-Key,SRN6045TA-4R7MCT-ND,FIXED IND 4.7UH 4.5A 26 MOHM SMD,,0,6/18/17,,,,, MEMM-001,Digi-Key,497-8649-1-ND,IC EEPROM 64KBIT 400KHZ 8TSSOP,,0,6/18/17,,,,, -MEMM-002,Digi-Key,WM24066CT-ND,CONN MICRO SD CARD PUSH-PUSH R/A,,0,6/18/17,,,,, +MEMM-002,Mouser,538-502774-0891,CONN MICRO SD CARD PUSH-PUSH R/A,,0,6/18/17,,,,, REGU-001,Digi-Key,TS30013-M050QFNRCT-ND,IC REG BUCK 5V 3A SYNC 16QFN,,0,6/17/17,,1.86,,,https://www.digikey.ca/product-detail/en/semtech-corporation/TS30013-M050QFNR/TS30013-M050QFNRCT-ND/5415614 REGU-002,Digi-Key,MCP1826S-3302E/DB-ND,IC REG LDO 3.3V 1A SOT223-3,,16,6/17/17,,1.1,,,https://www.digikey.ca/products/en?keywords=MCP1826S-3302E%2FDB-ND RESS-001,Digi-Key,RC0603JR-070RL ,RES SMD 0.0OHM JUMPER 1/10W 0603,,4,6/18/17,RMCF0603ZT0R00CT-ND,,,, @@ -39,27 +39,27 @@ RESS-003,Digi-Key,311-100KHRCT-ND,RES SMD 100K OHM 1% 1/10W 0603,,0,6/18/17,,,,, RESS-004,Digi-Key,311-11.0KHRCT-ND,RES SMD 11K OHM 1% 1/10W 0603,,0,6/18/17,,,,, RESS-005,Digi-Key,P10KGCT-ND ,RES SMD 10K OHM 5% 1/10W 0603,,267,6/18/17,311-10KGRCT-ND,,,, RESS-006,Digi-Key,311-100GRCT-ND,RES SMD 100 OHM 5% 1/10W 0603,,100,6/18/17,,,,, -RESS-007,,,,,,,,,,, +RESS-007,Digi-Key,311-150KHRCT-ND,RES SMD 150K OHM 1% 1/10W 0603,,,,,,,, RESS-008,Digi-Key,311-100KGRCT-ND,RES SMD 100K OHM 5% 1/10W 0603,,100,6/18/17,,,,, TRAN-001,Digi-Key,IRF5806TRPBFCT-ND,MOSFET P-CH 20V 4A 6-TSOP,,0,6/18/17,,,,, TRAN-002,Digi-Key,1727-4692-1-ND,MOSFET N-CH 60V 0.36A SOT-23,,0,,,,,, XTAL-001,Digi-Key,XC1617CT-ND,CRYSTAL 32.7680KHZ 12.5PF SMD,,0,6/18/17,,,,, -XTAL-002,Digi-Key,535-10630-1-ND,CRYSTAL 8.0000MHZ 18PF SMD,,3,6/18/17,,,,, +XTAL-002,Mouser,815-ABM3-8-D2Y-T,CRYSTAL 8.0000MHZ 18PF SMD,,3,6/18/17,,,,, BUZZ-001,Digi-Key,668-1339-ND,AUDIO MAGNETIC INDICATOR 3-7V TH,,0,,,,,, ,,,,,,,,,,, -Almost Components,,,,,,,,,,, -RESS-002,,RMCF0603JT22K0CT-ND,RES SMD 22K OHM 5% 1/10W 0603,,350,6/18/17,,,,, -REGU-002,,296-21283-1-ND,IC REG LDO 3.3V 0.4A SOT23-5,,1,6/18/17,,,,, -TRAN-001,,SI2323CDS-T1-GE3CT-ND,MOSFET P-CH 20V 6A SOT-23,,6,6/18/17,,,,, -CAPP-001,,490-7202-1-ND,CAP CER 10UF 25V X5R 0603,,30,6/18/17,,,,, -CAPP-004,,587-2400-1-ND,CAP CER 1UF 50V 10% X5R 0603,,78,6/18/17,,,,, -CAPP-005,,311-1344-1-ND,CAP CER 0.1UF 50V 10% X7R 0603,,44,6/18/17,,,,, -CAPP-002,,1276-1104-1-ND,CAP CER 0.022UF 50V 10% X7R 0603,,100,6/18/17,,,,, -CAPP-004,,490-1543-1-ND,CAP CER 1.0UF 10V 10% X5R 0603,,114,6/18/17,,,,, -CAPP-002,,399-1280-1-ND,CAP .022UF 50V CERAMIC X7R 0603,,8,6/18/17,,,,, -CAPP-010,,490-4781-1-ND,CAP CER .01UF 100V X7R 0603,,97,6/18/17,,,,, -CAPP-008,,587-2909-1-ND,CAP CER 2.2UF 25V 10% X5R 0603,,99,6/18/17,,,,, -CAPP-004,,587-1262-1-ND,CAP CER 1.0UF 16V Y5V 0603,,90,6/18/17,,,,, -CAPP-005,,490-3285-1-ND,CAP CER .1UF 100V X7R 0603,,1,6/18/17,,,,, -CAPP-004,,399-5090-1-ND,CAP CERAMIC 1.00UF 16V X5R 0603,,83,6/18/17,,,,, -RESS-003,,311-100KGRCT-ND,RES SMD 100K OHM 5% 1/10W 0603,,100,6/18/17,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, +,,,,,,,,,,, \ No newline at end of file From 803ca1417aa850fcb8567a64f1f1f85b8d91127f Mon Sep 17 00:00:00 2001 From: Stephen John Cholvat Date: Fri, 25 Aug 2017 09:35:35 -0700 Subject: [PATCH 3/3] updated README --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 422259b..85653f9 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,21 @@ There are 2 steps to add a component. This process is to make it easy to find pa 2) Update the WARG.lib file with the new kicad symbol and store the WARG part number in the "Datasheet" field. ### Installing into a new project -To add the kiCad library to a new project, add it as a git submodule in your project folder. To do this, use "git submodule add " command in the directory you want it added. Also be sure to pull the submodule repo using "git submodule update --init --recursive". +To add the kiCad library to a new project, add it as a git submodule in your project folder. To do this, use ```git submodule add ``` command in the directory you want it added. Also be sure to pull the submodule repo using ```git submodule update --init --recursive```. Once the submmodule is added, point to your submodule folder using a relative path, and add the WARG.lib to your project libraries. + +### Generating BOM +To generate a Bill of Materials (BOM), use the generate_warg_bom.py script. + +1. In KiCad Eeschema (schematic editor), go to Tools ->Generate Bill of Materials or click on the BOM icon in the toolbar. +2. Click "Add Plugin" and navigate to the generate_warg_bom.py script. Click on it. The "Command Line" text field should be auto-completed with something like this: + ```python "[Your local directory]\WARG\ZeroPilot-HW\WARG-kicad\bom\generate_warg_bom.py" "%I" "%O" ``` +3. Make sure the correct plugin is selected and click "Generate". It will print out the file path of the BOM in csv format +4. Love, cherish, and adore your new bill of materials. + + ### Component Library Prefixes: CONN: connector