Skip to content
Snippets Groups Projects
Commit 9bf6eafe authored by Jake Read's avatar Jake Read
Browse files

add histogram images from spipi

parent a98e766f
Branches
No related tags found
No related merge requests found
import spidev, time
# import numpy as np
# from plot_stamps import plot_stamps
import numpy as np
from plot_stamps import plot_stamps
bitrate = 10000000
bitrate = 11000000
print(f'rate {bitrate/1e6}MBit/s bit period should be {1000000000/bitrate}ns')
......@@ -13,7 +13,7 @@ spi.mode = 0b10
pck_len = 64
stamp_count = 10000
# stamps = np.zeros(stamp_count)
stamps = np.zeros(stamp_count)
test_pck = bytearray(pck_len)
for b in range(len(test_pck)):
......@@ -21,15 +21,14 @@ for b in range(len(test_pck)):
print(test_pck)
# TODO will be to finish making these plots,
# need to install pandas and numpy here w a venv
# for now I'm just going to turn the rate up until things go wrong
bonked = False
bonk_count = 0
for i in range(stamp_count):
if bonked:
break
# if bonked:
# break
ret = spi.xfer(test_pck)
# stamps[i] = time.perf_counter() * 1e6
stamps[i] = time.perf_counter() * 1e6
start = -1
for j in range(len(ret)):
if start == -1:
......@@ -38,14 +37,17 @@ for i in range(stamp_count):
continue
else:
if ret[j] != j - start:
print(f'BONK at {i} char {j} {start} {ret[j]}')
print(ret)
# print(f'BONK at {i} char {j} {start} {ret[j]}')
# print(ret)
bonk_count += 1
bonked = True
break
spi.close()
# plot_stamps(stamps, stamp_count, pck_len)
print(f"bonk {bonk_count} / {stamp_count}")
plot_stamps(stamps, stamp_count, pck_len, bonk_count / stamp_count)
# 1Mbit seems solid,
# 2.5Mbit and we have very occasional starvation
......
import pandas as pd
import matplotlib.pyplot as plt
def plot_stamps(stamps, stamp_count, pck_len):
def plot_stamps(stamps, stamp_count, pck_len, misses):
# make df from stamps
df = pd.DataFrame({'timestamps': stamps})
......@@ -17,7 +17,7 @@ def plot_stamps(stamps, stamp_count, pck_len):
# Plotting
fig, ax1 = plt.subplots(figsize=(11, 3))
ax1.set_xlim([50, 2000])
ax1.set_xlim([0, 1000])
# Primary x-axis (time deltas)
df['deltas'].plot(kind='hist', bins=50, ax=ax1)
......@@ -26,6 +26,7 @@ def plot_stamps(stamps, stamp_count, pck_len):
# get axis ticks to calculate equivalent bandwidths
x_ticks = ax1.get_xticks()
x_ticks = [100, 200, 300, 400, 500, 600, 700, 800, 900]
ax1.set_xticks(x_ticks)
bandwidths = [((pck_len * 8) * (1e6 / x)) / 1e6 for x in x_ticks]
ticks = []
......@@ -36,7 +37,7 @@ def plot_stamps(stamps, stamp_count, pck_len):
ax1.set_xticklabels(ticks)
plt.title(f'Single-Source COBS Data Sink Deltas, pck_len={pck_len}')
plt.title(f'Single-Source COBS Data Sink Deltas, pck_len={pck_len}, miss={misses}')
plt.tight_layout()
......
rpi_spi/images/2024-01-04_spi-histo-10Mb.png

31.2 KiB

rpi_spi/images/2024-01-04_spi-histo-11Mb.png

31.2 KiB

rpi_spi/images/2024-01-04_spi-histo-15Mb.png

30.7 KiB

rpi_spi/images/2024-01-04_spi-histo-1Mb.png

32.9 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment