{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e07a8d07-f74b-4527-862b-3776574817c4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Compiling library: SLiCAP.lib.\n",
      "Compiling library: SLiCAPmodels.lib.\n"
     ]
    }
   ],
   "source": [
    "from SLiCAP import initProject, specItem, specs2csv, specs2html\n",
    "initProject('Specifications', notebook=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "906bbd5b-c7fd-4cf0-ba12-dd455851dc0b",
   "metadata": {
    "jupyter": {
     "source_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "tau_i           = 16E-6    # A1 integration time constant\n",
    "f_min           = 600      # Low 3dB cut off frequency\n",
    "f_max           = 6000     # High 3dB cut-off frequency\n",
    "f_ref           = 1000     # Reference frequency for receive coil sensitivity\n",
    "f_fp            = 5000     # Max. full-power frequency\n",
    "Vi_ADC          = 0.9      # Peak-peak input voltage ADC\n",
    "SPLref          = 20E-6    # 0dB SPL level in Pa\n",
    "mic_dB_Pa       = -35.5    # microphone sensitivity in dBV/Pa\n",
    "SPL_noise       = 30       # Allowed SPL noise level\n",
    "SPL_max         = 110      # Max sound pressure level\n",
    "SPL_ref         = 90       # dB/(A/m) inductive loop reference\n",
    "SPL_sens        = -60.2    # dBV/(A/m) receive coil sensitivity at f_ref with termination\n",
    "V_noise         = 20E-6 * 10**((mic_dB_Pa + SPL_noise)/20)\n",
    "Rs              = 875      # Source reistance\n",
    "Ls              = 0.12     # Source inductance\n",
    "F_crest         = 3        # Signal crest factor\n",
    "Vi_pp           = 2 * F_crest * 10**((SPL_sens + SPL_max - SPL_ref)/20)*f_fp/f_ref\n",
    "P_max           = 1e-3     # Maximum power dissipation at maximum supply voltage \n",
    "V_DD            = 1.3      # Maximum supply voltage   \n",
    "specs = []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "b70f6a8b-c187-4ed4-aa07-1d70124458fb",
   "metadata": {
    "jupyter": {
     "source_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "# source electrical specification\n",
    "\n",
    "specs.append(\n",
    "    specItem(\n",
    "        \"L_s\",\n",
    "        description = \"Source inductance\",\n",
    "        value       = Ls,\n",
    "        units       = \"H\",\n",
    "        specType    = \"performance\",\n",
    "    )\n",
    ")\n",
    "specs.append(\n",
    "    specItem(\n",
    "        \"R_s\",\n",
    "        description = \"Source resistance\",\n",
    "        value       = Rs,\n",
    "        units       = \"Omega\",\n",
    "        specType    = \"performance\",\n",
    "    )\n",
    ")\n",
    "\n",
    "specs.append(\n",
    "    specItem(\n",
    "        \"R_t\",\n",
    "        description = \"Termination resistance\",\n",
    "        value       = 10e3,\n",
    "        units       = \"Omega\",\n",
    "        specType    = \"performance\",\n",
    "    )\n",
    ")\n",
    "\n",
    "# source signal specification\n",
    "\n",
    "specs.append(\n",
    "    specItem(\n",
    "        \"Vi_pp\",\n",
    "        description = \"Maximum peak-peak input voltage\",\n",
    "        value       = Vi_pp,\n",
    "        units       = \"\",\n",
    "        specType    = \"performance\",\n",
    "    )\n",
    ")\n",
    "\n",
    "specs.append(\n",
    "    specItem(\n",
    "        \"f_fp\",\n",
    "        description = \"Maximum full-power frequency\",\n",
    "        value       = f_fp,\n",
    "        units       = \"Hz\",\n",
    "        specType    = \"performance\",\n",
    "    )\n",
    ")\n",
    "\n",
    "# Performance requirements (Range, Bandwidth, Resolution)\n",
    "\n",
    "specs.append(\n",
    "    specItem(\n",
    "        \"tau_i\",\n",
    "        description = \"Integration time constant\",\n",
    "        value       = tau_i,\n",
    "        units       = \"s\",\n",
    "        specType    = \"performance\",\n",
    "    )\n",
    ")\n",
    "\n",
    "specs.append(\n",
    "    specItem(\n",
    "        \"f_min\",\n",
    "        description = \"-3dB high-pass cut-off frequency\",\n",
    "        value       = f_min,\n",
    "        units       = \"Hz\",\n",
    "        specType    = \"performance\",\n",
    "    )\n",
    ")\n",
    "\n",
    "specs.append(\n",
    "    specItem(\n",
    "        \"f_max\",\n",
    "        description = \"-3dB low-pass cut-off frequency\",\n",
    "        value       = f_max,\n",
    "        units       = \"Hz\",\n",
    "        specType    = \"performance\",\n",
    "    )\n",
    ")\n",
    "\n",
    "specs.append(\n",
    "    specItem(\n",
    "        \"V_onoise\",\n",
    "        description = \"DIN A weighted output voltage noise\",\n",
    "        value       = V_noise,\n",
    "        units       = \"V\",\n",
    "        specType    = \"performance\",\n",
    "    )\n",
    ")\n",
    "\n",
    "specs.append(\n",
    "    specItem(\n",
    "        \"Vi_ADC\",\n",
    "        description = \"Peak-peak input voltage ADC\",\n",
    "        value       = Vi_ADC,\n",
    "        units       = \"V\",\n",
    "        specType    = \"performance\",\n",
    "    )\n",
    ")\n",
    "\n",
    "specs.append(\n",
    "    specItem(\n",
    "        \"P_max\",\n",
    "        description = \"Maximum power dissipation at maximum supply voltage\",\n",
    "        value       = P_max,\n",
    "        units       = \"W\",\n",
    "        specType    = \"performance\",\n",
    "    )\n",
    ")\n",
    "\n",
    "specs.append(\n",
    "    specItem(\n",
    "        \"V_DD\",\n",
    "        description = \"Maximum supply voltage\",\n",
    "        value       = V_DD,\n",
    "        units       = \"V\",\n",
    "        specType    = \"performance\",\n",
    "    )\n",
    ")\n",
    "\n",
    "specs2csv(specs, 'A1specs.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4f93a776-5007-41ff-a3bb-2bf5736fc111",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<h3>performance specification</h3>\n",
       "<table><a id=\"table_performance\"></a><caption>Table performance specification </caption><tr><th class=\"left\">symbol</th><th class=\"left\">description</th><th class=\"left\">value</th><th class=\"left\">units</th></tr>\n",
       "<td class=\"left\">$L_{s}$</td><td class=\"left\">Source inductance</td><td class=\"left\">$0.12$</td><td class=\"left\">$\\mathrm{H}$</td></tr>\n",
       "<td class=\"left\">$P_{max}$</td><td class=\"left\">Maximum power dissipation at maximum supply voltage</td><td class=\"left\">$0.001$</td><td class=\"left\">$\\mathrm{W}$</td></tr>\n",
       "<td class=\"left\">$R_{s}$</td><td class=\"left\">Source resistance</td><td class=\"left\">$875$</td><td class=\"left\">$\\mathrm{\\Omega}$</td></tr>\n",
       "<td class=\"left\">$R_{t}$</td><td class=\"left\">Termination resistance</td><td class=\"left\">$1.0 \\cdot 10^{4}$</td><td class=\"left\">$\\mathrm{\\Omega}$</td></tr>\n",
       "<td class=\"left\">$V_{DD}$</td><td class=\"left\">Maximum supply voltage</td><td class=\"left\">$1.3$</td><td class=\"left\">$\\mathrm{V}$</td></tr>\n",
       "<td class=\"left\">$V_{onoise}$</td><td class=\"left\">DIN A weighted output voltage noise</td><td class=\"left\">$1.062 \\cdot 10^{-5}$</td><td class=\"left\">$\\mathrm{V}$</td></tr>\n",
       "<td class=\"left\">$Vi_{ADC}$</td><td class=\"left\">Peak-peak input voltage ADC</td><td class=\"left\">$0.9$</td><td class=\"left\">$\\mathrm{V}$</td></tr>\n",
       "<td class=\"left\">$Vi_{pp}$</td><td class=\"left\">Maximum peak-peak input voltage</td><td class=\"left\">$0.2932$</td><td></td></tr>\n",
       "<td class=\"left\">$f_{fp}$</td><td class=\"left\">Maximum full-power frequency</td><td class=\"left\">$5000$</td><td class=\"left\">$\\mathrm{Hz}$</td></tr>\n",
       "<td class=\"left\">$f_{max}$</td><td class=\"left\">-3dB low-pass cut-off frequency</td><td class=\"left\">$6000$</td><td class=\"left\">$\\mathrm{Hz}$</td></tr>\n",
       "<td class=\"left\">$f_{min}$</td><td class=\"left\">-3dB high-pass cut-off frequency</td><td class=\"left\">$600$</td><td class=\"left\">$\\mathrm{Hz}$</td></tr>\n",
       "<td class=\"left\">$\\tau_{i}$</td><td class=\"left\">Integration time constant</td><td class=\"left\">$1.6 \\cdot 10^{-5}$</td><td class=\"left\">$\\mathrm{s}$</td></tr>\n",
       "</table>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "specs2html(specs)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
