Microprocessor to RS-232 realtime plot using PySerial/Matplotlib?

守給你的承諾、 提交于 2019-12-03 20:32:29

This is some good reading on using matplotlib for animation with the various GUI backends. Not quite what you are asking but it should give you a rough idea of matplotlib's capabilities for fast plotting/updating graphs.

To handle the complicated binary data format you could maybe use structured arrays in numpy (see also here for a nice introduction). After defining the structure of the data it should be very easy to read it in. Then you could use numpy's functionality to cook down the data to what you need.

There's a good realtime plotting example here. It's a good example in that it runs with self generated data, so it's easy to test, but it's also obvious where to modify the code for plotting real data, and the code is easy to follow.

The basic idea is to make a plot window and then update that data as it comes in using

set_xdata(np.arange(len(self.data)))
set_ydata(np.array(self.data))

(Though in the current versions of matplotlib you may want to use set_data(xdata, ydata) instead.)

As for parsing the serial port data, it's probably better to ask that as a separate question.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!