Syrostan-MCU-C/plot_adc.py

18 lines
422 B
Python
Raw Normal View History

length = 16384
ADC_PERIOD = 12.5 # ns
import serial
import numpy as np
import matplotlib.pyplot as plt
ser = serial.Serial('/dev/ttyUSB0', 115200, timeout=None)
# print(ser.name) # check which port was really used
buffer = ser.read(length);
x = [float(x)*ADC_PERIOD for x in range(length)]
# print(x)
y = []
for i in range(length):
y.append(np.int8(buffer[i]))
# print(y)
plt.plot(x, y)
plt.show()
ser.close()