{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "191cdc91-de49-41a5-87f3-3283d939d150",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from matplotlib import pyplot as plt\n",
    "from scipy import signal as sig\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "c0ea3fcc-aaae-4dbf-a637-f3f1e122d12b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LED optical power: 24.000 mW\n",
      "LED power density at photodiode surface: 0.007 mW/cm^2\n",
      "Photodiode reverse current: 14.106 nA\n",
      "Photodiode background reverse current: 2.000 µA\n",
      "voltage bit depth: 7.148 bit\n"
     ]
    }
   ],
   "source": [
    "light_current_efficiency = 2 # worst case, µA @ 1mW/cm^2, @950 nm, @V_R = 5V\n",
    "light_current_efficiency *= 1e-6 * 1e3 / (100**2) # normalize units -> A * m^2 / W\n",
    "\n",
    "led_voltage = 1.2 # infrared LED\n",
    "led_current = 0.05 # ampere\n",
    "led_power = led_voltage * led_current\n",
    "led_efficiency = 0.4 # guess\n",
    "led_optical_power = led_power * led_efficiency\n",
    "print(f'LED optical power: {led_optical_power*1e3:.3f} mW')\n",
    "\n",
    "led_distance = 0.03 # meter\n",
    "led_angle = 160 # degree, full angle\n",
    "led_irradiated_area = led_distance * np.tan(np.radians(led_angle/2)) * 2\n",
    "led_power_density = led_optical_power / led_irradiated_area # led power at receiver photodiode plane, W/m^2\n",
    "print(f'LED power density at photodiode surface: {led_power_density * 1e3 / 1e4:.3f} mW/cm^2')\n",
    "\n",
    "pd_current = led_power_density * light_current_efficiency\n",
    "print(f'Photodiode reverse current: {pd_current*1e9:.3f} nA')\n",
    "\n",
    "indoor_light = 10 # W / m^2\n",
    "pd_background_current = indoor_light * light_current_efficiency\n",
    "print(f'Photodiode background reverse current: {pd_background_current*1e6:.3f} µA')\n",
    "\n",
    "print(f'Equivalent voltage bit depth: {np.log2(pd_background_current/pd_current):.3f} bit')"
   ]
  }
 ],
 "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.13.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
