diff --git a/test/fft.py b/test/fft.py deleted file mode 100755 index e38a21c..0000000 --- a/test/fft.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/env python3 - -import numpy as np -import matplotlib.pyplot as plt - -data = [] - -with open("test", "rb") as f: - data = np.fromfile(f, dtype=np.int16) - -plt.psd(data, Fs=1e6) -plt.show() diff --git a/test/sync/correlation.png b/test/sync/correlation.png new file mode 100644 index 0000000..34d1dc1 Binary files /dev/null and b/test/sync/correlation.png differ diff --git a/test/sync/difference-of-channels-1.png b/test/sync/difference-of-channels-1.png new file mode 100644 index 0000000..0b27a5d Binary files /dev/null and b/test/sync/difference-of-channels-1.png differ diff --git a/test/sync/difference-of-channels-2.png b/test/sync/difference-of-channels-2.png new file mode 100644 index 0000000..2d4521b Binary files /dev/null and b/test/sync/difference-of-channels-2.png differ diff --git a/test/sync/sync.py b/test/sync/sync.py new file mode 100644 index 0000000..e6f35d5 --- /dev/null +++ b/test/sync/sync.py @@ -0,0 +1,32 @@ +# this script helps to verify if the 2 channels of +# the picoscope are sampled synchronously (as stated in the datasheet) + +import numpy as np +import matplotlib.pyplot as plt + +# the input is the same square wave on both channels +# stored as an array of pairs of float32-s +data = np.fromfile("sync_test.bin", dtype=np.float32) + +# if the i and q channels are perfectly indetical and in sync +# their difference should be const 0 +diff = data[0::2] - data[1::2] +plt.plot(diff[:10000], label="I - Q") +plt.title("Difference of channels") +plt.legend() +plt.show() +# this is not exactly the case, channel b seems to be +# a higher value at the changes in the signal +# maybe the two channels are sampled synchronously +# but with a small delay (less than a sample length) + +# if the signals are sampled with +plt.figure() +corr = np.correlate(data[0::2][:10000], data[1::2][:10000], mode="full") +print(f"Index of maximum (starting from 0, to 10000):", np.argmax(corr)) +# 9999 -> index of last element in the array -> complete overlap without offset +plt.plot(corr) +plt.title("Correlation") +plt.show() +# the maximum of the correlation is when the two signals perfectly overlap without +# and offset, this means that they are sampled at the same time \ No newline at end of file diff --git a/test/view.py b/test/view.py deleted file mode 100755 index 4726c1b..0000000 --- a/test/view.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/env python3 - -import numpy as np -import matplotlib.pyplot as plt - -data = [] - -with open("test", "rb") as f: - data = np.fromfile(f, dtype=np.int16) - -plt.plot(data[:10000]) -plt.show() \ No newline at end of file