You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.5 KiB
66 lines
1.5 KiB
3 years ago
|
{
|
||
|
"metadata": {
|
||
|
"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.9.7"
|
||
|
},
|
||
|
"orig_nbformat": 4,
|
||
|
"kernelspec": {
|
||
|
"name": "python3",
|
||
|
"display_name": "Python 3.9.7 64-bit"
|
||
|
},
|
||
|
"interpreter": {
|
||
|
"hash": "c7df07ecfb874d96581378ee2edfb0abd56d9de008e1391e0ed3612e4e80d4b7"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2,
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"source": [
|
||
|
"# Battery voltage comparator with histerezes\r\n",
|
||
|
"\r\n",
|
||
|
"\r\n",
|
||
|
"supply_voltage = 3.3\r\n",
|
||
|
"reference_voltage = 3\r\n",
|
||
|
"\r\n",
|
||
|
"R1 = 50000\r\n",
|
||
|
"R2 = 330000\r\n",
|
||
|
"\r\n",
|
||
|
"Vin_High = R1 * (reference_voltage / R2) + reference_voltage \r\n",
|
||
|
"\r\n",
|
||
|
"print(\"Voltage switch to high: {}V\".format(round(Vin_High,2)))\r\n",
|
||
|
"\r\n",
|
||
|
"Vin_Low = (reference_voltage*(R1+R2) - supply_voltage * R1) / R2\r\n",
|
||
|
"\r\n",
|
||
|
"print(\"Voltage switch to low: {}V\".format(round(Vin_Low,2)))\r\n",
|
||
|
"\r\n",
|
||
|
"Vin_delta = supply_voltage * (R1/R2)\r\n",
|
||
|
"\r\n",
|
||
|
"print(\"Voltage delta: {}V\".format(round(Vin_delta,2)))\r\n"
|
||
|
],
|
||
|
"outputs": [
|
||
|
{
|
||
|
"output_type": "stream",
|
||
|
"name": "stdout",
|
||
|
"text": [
|
||
|
"Voltage switch to high: 3.45V\n",
|
||
|
"Voltage switch to low: 2.95V\n",
|
||
|
"Voltage delta: 0.5V\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {}
|
||
|
}
|
||
|
]
|
||
|
}
|