Syrostan-MCU-C/plot_adc.py

19 lines
442 B
Python
Raw Permalink 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);
2022-01-22 17:50:49 +08:00
# 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()