Skip to content
Snippets Groups Projects
calculate-parts.ipynb 10.3 KiB
Newer Older
  • Learn to ignore specific revisions
  • {
      "cells": [
        {
          "cell_type": "code",
          "source": [
            "# Change these values to calculate the needed values\n",
    
            "INPUTS  = 8\n",
            "OUTPUTS = 8\n",
    
            "# Should output normalization be used? (Needs more opamps, ...)\n",
            "NORMALIZATION = True\n",
            "\n",
            "# Do you want to build an envelope as well?\n",
            "ENVELOPES = False\n",
    
            "\n",
            "\n",
            "# Do not edit below this Point unless you know what you are doing\n",
    
            "requirements = {\"inputs\": INPUTS, \"outputs\": OUTPUTS}\n",
            "\n",
    
            "data = {\n",
            "    \"mami-input\": {\n",
            "        \"input-channels\": 2,\n",
            "        \"parts\": [\n",
            "            {\"MPN\": \"PJ301M-12\", \"n\": 2},\n",
            "            {\"MPN\": \"Subminiature On-Off-(On) Toggle switch\", \"n\": 2},\n",
            "        ]\n",
            "    },\n",
            "    \"mami-output\": {\n",
            "        \"output-channels\": 2,\n",
            "        \"parts\": [\n",
            "            {\"MPN\": \"LME49720\", \"n\": 2},\n",
    
    David Huss's avatar
    David Huss committed
            "            {\"MPN\": \"100nF 0603 25V\", \"n\": 4},\n",
    
            "            {\"MPN\": \"100k 0805\", \"n\": 6},\n",
            "            {\"MPN\": \"100R 0805\", \"n\": 2},\n",
    
            "            {\"MPN\": \"PJ301M-12\", \"n\": 2}\n",
            "        ]\n",
            "    },\n",
            "    \"mami-quad\": {\n",
            "        \"input-channels\":2, \"output-channels\":2,\n",
            "        \"parts\": [\n",
            "            {\"MPN\": \"P0915N-FC15BR100K\", \"n\": 4},\n",
            "            {\"MPN\": \"Knob\", \"n\": 4},\n",
            "            {\"MPN\": \"100k 0805\", \"n\": 4}\n",
            "        ]\n",
    
    David Huss's avatar
    David Huss committed
            "    },\n",
            "    \"mami-env\": {\n",
            "        \"output-channels\":2,\n",
            "        \"parts\": [\n",
            "            {\"MPN\": \"100nF 0603 25V\", \"n\": 4},\n",
            "            {\"MPN\": \"PJ301M-12\", \"n\": 2},\n",
            "            {\"MPN\": \"TL074CD\", \"n\": 2},\n",
            "            {\"MPN\": \"100k 0805\", \"n\": 8},\n",
            "            {\"MPN\": \"200k 0805\", \"n\": 6},\n",
            "            {\"MPN\": \"20k 0805\", \"n\": 2},\n",
            "            {\"MPN\": \"1k 0805\", \"n\": 2},\n",
            "            {\"MPN\": \"470R 0805\", \"n\": 2},\n",
            "            {\"MPN\": \"1M 0805\", \"n\": 2},\n",
            "            {\"MPN\": \"1nF 0603\", \"n\": 2},\n",
            "            {\"MPN\": \"1uF 5mm lead spacing (e.g. MKS2C041001F00J)\", \"n\": 2},\n",
            "            {\"MPN\": \"LED 3mm\", \"n\": 2},\n",
            "            {\"MPN\": \"BAV199\", \"n\": 4}\n",
            "        ]\n",
    
            "# If normalization is desired use this list of parts instead\n",
            "if NORMALIZATION:\n",
            "  data[\"mami-output\"] = {\n",
            "    \"output-channels\": 2,\n",
            "    \"parts\": [\n",
            "        {\"MPN\": \"LME49720\", \"n\": 3},\n",
            "        {\"MPN\": \"100nF 0603 25V\", \"n\": 6},\n",
            "        {\"MPN\": \"100k 0805\", \"n\": 12},\n",
            "        {\"MPN\": \"100R 0805\", \"n\": 2},\n",
            "        {\"MPN\": \"PJ301M-12\", \"n\": 2}\n",
            "    ]\n",
            "  }\n",
            "\n",
    
            "# Calculate how many PCBs are needed\n",
            "n_input_modules = int(requirements[\"inputs\"] / data[\"mami-input\"][\"input-channels\"])\n",
            "n_output_modules = int(requirements[\"outputs\"] / data[\"mami-output\"][\"output-channels\"])\n",
    
    David Huss's avatar
    David Huss committed
            "n_env_modules = n_output_modules\n",
    
            "n_quad_modules = int((requirements[\"inputs\"] * requirements[\"outputs\"]) / (data[\"mami-output\"][\"output-channels\"] * data[\"mami-input\"][\"input-channels\"]))\n",
            "\n",
    
            "# Print the PCB\n",
            "print(\"Needed for a {}x{} Matrix Mixer without envelopes\".format(requirements[\"inputs\"], requirements[\"outputs\"]))\n",
            "print(\"{}\".format(\"=\"*50))\n",
            "print(\"{0:>5}x MAMI-INPUT-Module\".format(n_input_modules))\n",
            "print(\"{0:>5}x MAMI-OUTPUT-Module\".format(n_output_modules))\n",
            "print(\"{0:>5}x MAMI-QUAD-Module\".format(n_quad_modules))\n",
    
            "if ENVELOPES:\n",
    
            "  print(\"{0:>5}x MAMI-ENV-Module\".format(n_env_modules))\n",
            "print()\n",
            "\n",
            "# Collect all the parts\n",
            "bom = {}\n",
    
            "def get_parts(data, n_input_modules, n_quad_modules, n_output_modules, n_env_modules):\n",
            "  parts = []\n",
            "  for part in data[\"mami-input\"][\"parts\"]*n_input_modules:\n",
            "    parts.append(part)\n",
            "  for part in data[\"mami-quad\"][\"parts\"]*n_quad_modules:\n",
            "    parts.append(part)\n",
            "  for part in data[\"mami-output\"][\"parts\"]*n_output_modules:\n",
            "    parts.append(part)\n",
    
            "  if ENVELOPES:\n",
    
            "    for part in data[\"mami-env\"][\"parts\"]*n_env_modules:\n",
            "      parts.append(part)\n",
            "  return parts\n",
            "  \n",
            "\n",
            "for part in get_parts(data, n_input_modules, n_quad_modules, n_output_modules, n_env_modules):\n",
            "    if part[\"MPN\"] in bom:\n",
            "        bom[part[\"MPN\"]] += part[\"n\"]\n",
            "    else:\n",
            "        bom[part[\"MPN\"]] = part[\"n\"]\n",
            "\n",
            "# Print the BOM\n",
            "print(\"Parts\\n{}\".format(\"=\"*50))\n",
            "for key, value in bom.items():\n",
            "    print(\"{:>5}x {}\".format(value, key))\n",
            "    \n",
            "# Print second variant\n",
            "print()\n",
            "print(\"=\"*80)\n",
            "print()\n",
            "envelopes = True\n",
    
    David Huss's avatar
    David Huss committed
            "# Print the PCB\n",
    
            "print(\"Needed for a {}x{} Matrix Mixer with envelopes\".format(requirements[\"inputs\"], requirements[\"outputs\"]))\n",
    
            "print(\"{}\".format(\"=\"*50))\n",
            "print(\"{0:>5}x MAMI-INPUT-Module\".format(n_input_modules))\n",
            "print(\"{0:>5}x MAMI-OUTPUT-Module\".format(n_output_modules))\n",
    
    David Huss's avatar
    David Huss committed
            "print(\"{0:>5}x MAMI-QUAD-Module\".format(n_quad_modules))\n",
            "if envelopes:\n",
            "  print(\"{0:>5}x MAMI-ENV-Module\".format(n_env_modules))\n",
            "print()\n",
    
            "\n",
            "# Collect all the parts\n",
            "bom = {}\n",
            "\n",
    
    David Huss's avatar
    David Huss committed
            "def get_parts(data, n_input_modules, n_quad_modules, n_output_modules, n_env_modules):\n",
            "  parts = []\n",
            "  for part in data[\"mami-input\"][\"parts\"]*n_input_modules:\n",
            "    parts.append(part)\n",
            "  for part in data[\"mami-quad\"][\"parts\"]*n_quad_modules:\n",
            "    parts.append(part)\n",
            "  for part in data[\"mami-output\"][\"parts\"]*n_output_modules:\n",
            "    parts.append(part)\n",
            "  if envelopes:\n",
            "    for part in data[\"mami-env\"][\"parts\"]*n_env_modules:\n",
            "      parts.append(part)\n",
            "  return parts\n",
            "  \n",
            "\n",
            "for part in get_parts(data, n_input_modules, n_quad_modules, n_output_modules, n_env_modules):\n",
    
            "    if part[\"MPN\"] in bom:\n",
            "        bom[part[\"MPN\"]] += part[\"n\"]\n",
            "    else:\n",
            "        bom[part[\"MPN\"]] = part[\"n\"]\n",
            "\n",
            "# Print the BOM\n",
            "print(\"Parts\\n{}\".format(\"=\"*50))\n",
            "for key, value in bom.items():\n",
            "    print(\"{:>5}x {}\".format(value, key))"
          ],
          "outputs": [
            {
              "output_type": "stream",
              "name": "stdout",
              "text": [
    
                "Needed for a 8x8 Matrix Mixer with envelopes\n",
    
                "==================================================\n",
                "    4x MAMI-INPUT-Module\n",
                "    4x MAMI-OUTPUT-Module\n",
                "   16x MAMI-QUAD-Module\n",
    
    David Huss's avatar
    David Huss committed
                "    4x MAMI-ENV-Module\n",
    
                "\n",
                "Parts\n",
                "==================================================\n",
    
    David Huss's avatar
    David Huss committed
                "   24x PJ301M-12\n",
    
                "    8x Subminiature On-Off-(On) Toggle switch\n",
                "   64x P0915N-FC15BR100K\n",
                "   64x Knob\n",
    
    David Huss's avatar
    David Huss committed
                "  120x 100k 0805\n",
    
                "    8x LME49720\n",
    
    David Huss's avatar
    David Huss committed
                "   32x 100nF 0603 25V\n",
                "    8x 100R 0805\n",
                "    8x TL074CD\n",
                "   24x 200k 0805\n",
                "    8x 20k 0805\n",
                "    8x 1k 0805\n",
                "    8x 470R 0805\n",
                "    8x 1M 0805\n",
                "    8x 1nF 0603\n",
                "    8x 1uF 5mm lead spacing (e.g. MKS2C041001F00J)\n",
                "    8x LED 3mm\n",
    
                "   16x BAV199\n",
                "\n",
                "================================================================================\n",
                "\n",
                "Needed for a 8x8 Matrix Mixer without envelopes\n",
                "==================================================\n",
                "    4x MAMI-INPUT-Module\n",
                "    4x MAMI-OUTPUT-Module\n",
                "   16x MAMI-QUAD-Module\n",
                "\n",
                "Parts\n",
                "==================================================\n",
                "   16x PJ301M-12\n",
                "    8x Subminiature On-Off-(On) Toggle switch\n",
                "   64x P0915N-FC15BR100K\n",
                "   64x Knob\n",
                "   88x 100k 0805\n",
                "    8x LME49720\n",
                "   16x 100nF 0603 25V\n",
                "    8x 100R 0805\n"
    
          "execution_count": 2,
    
          "metadata": {
            "collapsed": false,
            "outputHidden": false,
    
    David Huss's avatar
    David Huss committed
            "inputHidden": false,
            "execution": {
    
              "shell.execute_reply": "2020-07-30T09:44:44.456Z",
              "iopub.status.busy": "2020-07-30T09:44:44.446Z",
              "iopub.execute_input": "2020-07-30T09:44:44.448Z",
              "iopub.status.idle": "2020-07-30T09:44:44.453Z"
    
    David Huss's avatar
    David Huss committed
            }
    
          }
        }
      ],
      "metadata": {
        "kernel_info": {
          "name": "python3"
        },
        "language_info": {
          "name": "python",
    
          "version": "3.8.2",
    
          "mimetype": "text/x-python",
          "codemirror_mode": {
            "name": "ipython",
            "version": 3
          },
          "pygments_lexer": "ipython3",
          "nbconvert_exporter": "python",
          "file_extension": ".py"
        },
        "kernelspec": {
          "name": "python3",
          "language": "python",
          "display_name": "Python 3"
        },
        "nteract": {
    
          "version": "0.27.0"
    
        }
      },
      "nbformat": 4,
      "nbformat_minor": 0
    
    David Huss's avatar
    David Huss committed
    }