Skip to content
Snippets Groups Projects
Commit ab93a744 authored by Joris Nonnast's avatar Joris Nonnast
Browse files

added abv2 aufgaben

parent 72fe41a7
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id:3c564ffb tags:
``` python
import numpy as np
import sympy as sp
import matplotlib.pyplot as plt
```
%% Cell type:code id:d805580c tags:
``` python
# Aufgabe 1 - Telezentriefehler
s = 290e-3 # m - Arbeitsabstand
te_s = 10e-3 # m - Telezentriebereich
te_y = 1e-6 # m - Bildgrößenänderung auf dem Sensor
te_u = np.arctan(te_y/(s + te_s))
print(f"Der Telezentriefehler beträgt {1e6*np.rad2deg(te_u):.2f} murad")
```
%% Output
Der Telezentriefehler beträgt 190.99 murad
%% Cell type:code id:695fb9fd tags:
``` python
%matplotlib inline
# Aufgabe 2 - Verzeichnung 1
vmax = 0.15e-2 # Verzeichnung am Rand
w = 96e-3 # m - Messfeld Breite
h = 72e-3 # m - Messfeld Höhe
r = np.sqrt(w**2 + h**2) # m - Messfeld Radius
d_r = vmax * r # m - Abweichung unverzeichneter - verzeichneter Radius
alpha = np.arctan(h/w) # rad - Winkel des Radius
d_x = np.cos(alpha)*d_r # m - Abweichung x unverzeichnet - verzeichnet
x_u = 96e-3 # m - x position unverzeichnet
x_v = x_u - d_x # m - x position verzeichnet
r_v = r - d_r # m - radius verzeichnet
k = ((x_v / x_u) - 1) / (r_v**2) # 1/m^2 - Radialverzeichnungskoeffizient
print(f"xu über k = {x_v / (1 + k*r_v**2)}, x_u = {x_u}")
print(f"k = {k:.3f} 1/m^2")
# Visualisiere Verzeichung
x = np.linspace(-.5, .5, 20)
y = x.copy()
xx, yy = np.meshgrid(x, y)
fig, ax = plt.subplots()
ax.plot(xx.reshape(-1, 1), yy.reshape(-1, 1), '.')
x_v = (2*xx) / (1 + np.sqrt(1 - 4*k*(xx**2 + yy**2)))
y_v = (2*yy) / (1 + np.sqrt(1 - 4*k*(xx**2 + yy**2)))
ax.plot(x_v.reshape(-1, 1), y_v.reshape(-1, 1), '.')
rect = plt.Rectangle((0 - w/2, 0 -h/2), w, h)
ax.add_patch(rect)
plt.show()
```
%% Output
xu über k = 0.096, x_u = 0.096
k = -0.104 1/m^2
%% Cell type:code id:8c437419 tags:
``` python
# Aufgabe 3 - Verzeichnnung 2
vmax = 1e-2 # Verzeichnung am Rand
beta = 0.004 # Abbildungsmaßstab
w_px, h_px = 1600, 1200 # Bildhöhe und Breite in px
w, h = 8.8e-3, 6.6e-3 # Sensorbreite und Höhe
d1 = 50e-3 # Breite gemnessenes Objekt 1
d2 = 200e-3 # Breite gemessenes Objekt 2
w, h = w/beta, h/beta
r = np.sqrt(w**2 + h**2) # m - Messfeld Radius
d_r = vmax * r # m - Abweichung unverzeichneter - verzeichneter Radius
alpha = np.arctan(h/w) # rad - Winkel des Radius
d_x = np.cos(alpha)*d_r # m - Abweichung x unverzeichnet - verzeichnet
x_u = 96e-3 # m - x position unverzeichnet
x_v = x_u - d_x # m - x position verzeichnet
r_v = r - d_r # m - radius verzeichnet
k = ((x_v / x_u) - 1) / (r_v**2) # 1/m^2 - Radialverzeichnungskoeffizient
x_lu1 = 0 - d1/2 # unverzeichnete Kantenposition linke Kante
x_ru1 = 0 + d1/2 # unverzeichnete Kantenposition rechte Kante
x_lv1 = (2*x_lu1) / (1 + np.sqrt(1 - 4*k*(x_lu1**2 + 0**2)))
x_rv1 = (2*x_ru1) / (1 + np.sqrt(1 - 4*k*(x_lu1**2 + 0**2)))
d_d1 = d1 - (x_rv1 - x_lv1)
x_lu2 = 0 - d2/2 # unverzeichnete Kantenposition linke Kante
x_ru2 = 0 + d2/2 # unverzeichnete Kantenposition rechte Kante
x_lv2 = (2*x_lu2) / (1 + np.sqrt(1 - 4*k*(x_lu2**2 + 0**2)))
x_rv2 = (2*x_ru2) / (1 + np.sqrt(1 - 4*k*(x_lu2**2 + 0**2)))
d_d2 = d2 - (x_rv2 - x_lv2)
print(f"Fehler bei 50 mm: {1e3*d_d1:.3f} mm")
print(f"Fehler bei 200 mm: {1e3*d_d2:.3f} mm")
```
%% Output
Fehler bei 50 mm: 0.001 mm
Fehler bei 200 mm: 0.062 mm
%% Cell type:code id:5362a504 tags:
``` python
# Aufgabe 4 - Timing
"""
Timing
Ihre Firma entwirft ein BV-System zur Pfandflaschenkontrolle. Die Flaschen stehen auf einem
Fließband, das sich mit 14,5 m/s bewegt. Die Flaschen haben einen typischen Durchmesser von
12 cm. Das Sichtfeld der Kamera ist 24x32 cm groß (hochkant). Die Bildaufnahme wird mit einer
Lichtschranke getriggert, die 17 cm vor der Kante des Sichtfelds steht. Ihr Kollege möchte diese
Aufgabe mit seiner Lieblingskamera lösen, Sie sollen das überprüfen.
Die Monochrom-Kamera hat 1536 x 2048 Pixel. Nach dem Triggerimpuls gibt es eine Kamera-interne
Totzeit von 𝑡𝑤𝑎𝑖𝑡 = 140 𝜇𝑠, danach folgt eine extern einstellbare Verzögerungszeit 𝑡𝑑𝑒𝑙𝑎𝑦 und dann
die Integrationszeit 𝑡𝑖𝑛𝑡. Die Dauer zum Auslesen eines Bildes aus dem Sensor und Übertragen
beträgt 𝑡𝑟𝑒𝑎𝑑 = 126 𝑚𝑠.
a) Wie muss 𝑡𝑑𝑒𝑙𝑎𝑦 gewählt werden, damit sich die
Flasche bei Bildaufnahme in der Mitte des
Bildfelds befindet?
b) Wie lang darf die Integrationszeit 𝑡𝑖𝑛𝑡 höchstens
sein, damit die Bewegungsunschärfe
max. 1 Pixel beträgt?
c) Wie groß muss der Mindestabstand zwischen
2 Flaschen sein?
d) Welche Datenrate (in MB/s) geht über die Schnittstelle?
e) Was würden Sie anders machen?
""""
v = 14.5 # m/s - Fließbandgeschwindigkeit
d = 12e-2 # m - Typischer Flaschendurchmesser
fov_w = 24e-2 # m - FOV Breite
fov_h = 32e-2 # m - FOV Höhe
pos_trig = 17e-2 # m - Position der Lichtschranke
px_w = 1536 # px - Auflösung Breite
px_h = 2048 # px - Auflösung Höhe
t_wait = 140e-6 # s - Totzeit
t_delay = None # s - Einstellbarer Delay
t_int = None # Integrationszeit
t_read = 126e-3 # s - Readoutzeit
# a)
# v = s/t
# t = s/v
t_trig_middle = (d/2)/v
t_fov_middle = (pos_trig + (fov_w/2))/v
t_delay = t_trig_middle + t_fov_middle - t_wait
print(f"Der delay beträgt {1e3*t_delay:2.2f} ms")
```
%% Output
Der delay beträgt 24.00 ms
%% Cell type:code id:b1542d9f tags:
``` python
# b)
w_px = fov_w/px_w
t_int = w_px / v
print(f"Die Integrationszeit darf maximal {1e6*t_int:.2f} mus betragen")
```
%% Output
Die Integrationszeit darf maximal 10.78 mus betragen
%% Cell type:code id:4a8f3cd8 tags:
``` python
# c)
# Von Flaschenende zu Flaschenanfang
# Wenn Kamera den Trigger buffert:
d_flasche_min = (t_wait + t_delay + t_read) * v
print(f"Die Flaschen benbötigen einen Mindestabstand von {d_flasche_min:.2f} m")
```
%% Output
Die Flaschen benbötigen einen Mindestabstand von 2.18 m
%% Cell type:code id:ecc2a0ec tags:
``` python
# d)
data_rate8 = (((px_w * px_h))/t_read)*1e-6
print(f"Bei 8bit Pixeln beträgt die Datenrate {data_rate8:.2f} MB/s")
```
%% Output
Bei 8bit Pixeln beträgt die Datenrate 24.97 MB/s
%% Cell type:code id:2b3412f4 tags:
``` python
#e)
# Eine Kamera mit höherer Datenrate wählen
# 126ms readout entspricht gerade einmal 8 FPS
```
%% Output
7.936507936507937
%% Cell type:code id:dd2f8277 tags:
``` python
# Aufgabe 5 - Digitale Datenübertragung
# 1)
jitter = 15e-9 # s
print(f"Der zeitliche Jitter beträgt {1e9*jitter:.2f} ns")
# 2)
c = 3e8 # m/s - Lichtgeschwindigkeit
s = 15 # m - Kabellänge
t = 15 / c
print(f"Ein Puls benötigt ca. {1e9*t} ns um durch {s} m Kabel zu laufen")
```
%% Output
Der zeitliche Jitter beträgt 15.00 ns
Ein Puls benötigt ca. 50.0 ns um durch 15 m Kabel zu laufen'
%% Cell type:code id:4be6abc4 tags:
``` python
```
This diff is collapsed.
This diff is collapsed.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "egyptian-freedom",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "therapeutic-reading",
"metadata": {},
"outputs": [],
"source": [
"tau1 = np.cos(np.deg2rad(-15))**2\n",
"tau2 = np.cos(np.deg2rad(30))**2\n",
"tau_ges = tau1 * tau2"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "immune-doubt",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.37500000000000006\n"
]
}
],
"source": [
"print(tau2*0.5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "electronic-example",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "egyptian-freedom",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "therapeutic-reading",
"metadata": {},
"outputs": [],
"source": [
"tau1 = np.cos(np.deg2rad(-15))**2\n",
"tau2 = np.cos(np.deg2rad(30))**2\n",
"tau_ges = tau1 * tau2"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "immune-doubt",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.37500000000000006\n"
]
}
],
"source": [
"print(tau2*0.5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "electronic-example",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
# obv_experimente
# obv_experimente
This diff is collapsed.
{
"cells": [
{
"cell_type": "code",
"execution_count": 12,
"id": "necessary-twenty",
"metadata": {},
"outputs": [],
"source": [
"import sympy as sp\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "political-johnson",
"metadata": {},
"outputs": [],
"source": [
"m1, m2, t1, t2, x = sp.symbols(\"m1, m2, t1, t2, x\")\n",
"# a1, b1, c1, y1, a2, b2, c2, y2 = sp.symbols(\"a1, b1, c1, y1, a2, b2, c2, y2\")"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "naval-daniel",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle - \\frac{t_{1} - t_{2}}{m_{1} - m_{2}}$"
],
"text/plain": [
"-(t1 - t2)/(m1 - m2)"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/latex": [
"$\\displaystyle - \\frac{m_{1} \\left(t_{1} - t_{2}\\right)}{m_{1} - m_{2}} + t_{1}$"
],
"text/plain": [
"-m1*(t1 - t2)/(m1 - m2) + t1"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"y1 = m1 *x + t1\n",
"y2 = m2 *x + t2\n",
"x_solve = sp.solveset(sp.Eq(y1, y2), x).args[0]\n",
"y_solve = m1 * x_solve + t1\n",
"display(x_solve)\n",
"display(y_solve)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "solar-mercury",
"metadata": {},
"outputs": [],
"source": [
"def find_intersect()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 12,
"id": "necessary-twenty",
"metadata": {},
"outputs": [],
"source": [
"import sympy as sp\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "political-johnson",
"metadata": {},
"outputs": [],
"source": [
"m1, m2, t1, t2, x = sp.symbols(\"m1, m2, t1, t2, x\")\n",
"# a1, b1, c1, y1, a2, b2, c2, y2 = sp.symbols(\"a1, b1, c1, y1, a2, b2, c2, y2\")"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "naval-daniel",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle - \\frac{t_{1} - t_{2}}{m_{1} - m_{2}}$"
],
"text/plain": [
"-(t1 - t2)/(m1 - m2)"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/latex": [
"$\\displaystyle - \\frac{m_{1} \\left(t_{1} - t_{2}\\right)}{m_{1} - m_{2}} + t_{1}$"
],
"text/plain": [
"-m1*(t1 - t2)/(m1 - m2) + t1"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"y1 = m1 *x + t1\n",
"y2 = m2 *x + t2\n",
"x_solve = sp.solveset(sp.Eq(y1, y2), x).args[0]\n",
"y_solve = m1 * x_solve + t1\n",
"display(x_solve)\n",
"display(y_solve)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "solar-mercury",
"metadata": {},
"outputs": [],
"source": [
"def find_intersect()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "manufactured-longitude",
"metadata": {},
"outputs": [],
"source": [
"from uncertainties import ufloat\n",
"from IPython.display import Markdown as md"
]
},
{
"cell_type": "code",
"execution_count": 86,
"id": "nominated-graduate",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.059+/-0.005\n"
]
}
],
"source": [
"f = ufloat(14e-3, 1e-3)\n",
"s = ufloat(250e-3, 3e-3)\n",
"beta = f / (s-f)\n",
"print(beta)\n",
"ly = ufloat(5e-6, 1e-7)\n",
"m = (1/beta)*ly\n",
"p1 = ufloat(0, 0.2)\n",
"p2 = ufloat(100, 0.2)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "pending-stand",
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"$(-1.210+/-0.043)e-02$"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"f = ufloat(30e-3, 1e-3)\n",
"s = ufloat(650e-3, 5e-3)\n",
"y = ufloat(250e-3, 0)\n",
"beta = f/(s-f)\n",
"y_s = y*beta\n",
"display(md(f\"${-y_s:.2ue}$\"))"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "heard-brain",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.0484+/-0.0017\n"
]
}
],
"source": [
"print(beta)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "soviet-preview",
"metadata": {},
"outputs": [],
"source": [
"import sympy as sp"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "otherwise-nylon",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle - \\frac{y}{f \\left(1 + \\frac{s}{f}\\right)^{2}}$"
],
"text/plain": [
"-y/(f*(1 + s/f)**2)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"s, f, y = sp.symbols(\"s, f, y\")\n",
"y_s = y / (1 + (s/f))\n",
"display(sp.diff(y_s, s))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "heavy-hebrew",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "manufactured-longitude",
"metadata": {},
"outputs": [],
"source": [
"from uncertainties import ufloat\n",
"from IPython.display import Markdown as md"
]
},
{
"cell_type": "code",
"execution_count": 86,
"id": "nominated-graduate",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.059+/-0.005\n"
]
}
],
"source": [
"f = ufloat(14e-3, 1e-3)\n",
"s = ufloat(250e-3, 3e-3)\n",
"beta = f / (s-f)\n",
"print(beta)\n",
"ly = ufloat(5e-6, 1e-7)\n",
"m = (1/beta)*ly\n",
"p1 = ufloat(0, 0.2)\n",
"p2 = ufloat(100, 0.2)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "pending-stand",
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"$(-1.210+/-0.043)e-02$"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"f = ufloat(30e-3, 1e-3)\n",
"s = ufloat(650e-3, 5e-3)\n",
"y = ufloat(250e-3, 0)\n",
"beta = f/(s-f)\n",
"y_s = y*beta\n",
"display(md(f\"${-y_s:.2ue}$\"))"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "heard-brain",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.0484+/-0.0017\n"
]
}
],
"source": [
"print(beta)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "soviet-preview",
"metadata": {},
"outputs": [],
"source": [
"import sympy as sp"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "otherwise-nylon",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle - \\frac{y}{f \\left(1 + \\frac{s}{f}\\right)^{2}}$"
],
"text/plain": [
"-y/(f*(1 + s/f)**2)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"s, f, y = sp.symbols(\"s, f, y\")\n",
"y_s = y / (1 + (s/f))\n",
"display(sp.diff(y_s, s))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "heavy-hebrew",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment