Syrostan-MCU-C/plot_adc.py
2022-01-22 17:50:49 +08:00

19 lines
442 B
Python

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)]
x = 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()