In [278]:
import serial
import scipy
import scipy.stats
import numpy as np
import matplotlib.pyplot as plt
import time
import binascii
import struct
In [363]:
ser = serial.Serial('/dev/ttyACM1', 9600)
In [379]:
lin = []
t_pc = []
t_start = time.time()
for i in range(0, 250):
lin.append(ser.readline().decode())
t_pc.append(time.time() - t_start)
In [380]:
count = len(lin)
t_pc = np.array(t_pc)
t_pc = t_pc * 1e6
i_ard = np.zeros((count, 1))
t_ard = np.zeros((count, 1))
for i in range(0, count):
(a, b) = lin[i].split("m")
i_ard[i] = int(a[2:a.index("]")])
t_ard[i] = int(b[1:b.index("]")])
t_ard = t_ard - t_ard[0]
i_ard = i_ard - i_ard[0]
In [394]:
plt.plot(t_pc[200:], t_ard[200:], '.')
plt.ylabel("Arduino")
plt.xlabel("PC")
plt.show()
In [382]:
plt.plot(i_ard, t_ard, '.')
plt.ylabel("Arduino")
plt.xlabel("Ind")
plt.show()
In [393]:
scipy.stats.mstats.linregress(t_pc[200:], t_ard[200:])
Out[393]:
In [390]:
s[3:]
Out[390]:
In [296]:
lin[i]
Out[296]:
In [ ]: