从串口绘制数据。

时间:2021-03-05 15:10:05

I got a serial port in .NET at 9600 baudrate. The incoming data is numeric, it's the time between 2 pulses of a motor encoder, it's the RPM of the motor actualy.

我在。net中获得了一个串行端口9600波特率。输入的数据是数值型的,它是电机编码器的两个脉冲之间的时间,它是马达实际的RPM。

How do I plot the data in real time?

如何实时绘制数据?

2 个解决方案

#1


1  

A simple plotter is fairly easy to do. You can spend hours looking for a just right library or program or just write your own in equivalent time.

一个简单的绘图仪是相当容易做到的。你可以花几个小时寻找合适的图书馆或程序,或者只是在相当的时间内编写自己的程序。

Here is how I have done it in the past

这是我过去的做法。

  • Allocate a circular buffer - about 2-4K data points should be sufficient
  • 分配一个循环缓冲区——大约2-4K数据点应该足够了。
  • take your serial data store it in the serial buffer
  • 将串行数据存储在串行缓冲区中。
  • get a drawable area
  • 得到一个可拉的区域
  • map the height of the drawable area to the maximum - minimum value you wish to display
  • 将可绘制区域的高度映射到您希望显示的最大最小值。
  • map the width of the drawable area to the number of points you wish to display
  • 将drawable区域的宽度映射到您希望显示的点的数量。
  • start a thread which takes in the serial data, parses it and puts it in the circular buffer,
  • 启动一个线程,它接收串行数据,解析它并将其放入循环缓冲区中,
  • start another thread which checks for new data in buffer periodically, plots the data in the circular buffer on a back buffer and then updates the drawable area displayed with the backbuffer.
  • 启动另一个线程,该线程定期检查缓冲区中的新数据,在缓冲区的循环缓冲区中绘制数据,然后更新带有backbuffer的drawable区域。

I had a similar issue some time back. I looked for a simple, light program that would do it do out of the box. I finally gave in and coded my own program using Win32 calls. A .NET implementation would be simpler.

我也有过类似的问题。我找了一个简单的,轻松的程序,它可以把它从盒子里拿出来。最后,我用Win32调用编写了自己的程序。net实现会更简单。

http://www.fast-product-development.com/real-time-serial-data-plot.html

http://www.fast-product-development.com/real-time-serial-data-plot.html

#2


0  

There is an example on the arduino playground that does that, you should check it.

在arduino的操场上有一个例子,你应该检查一下。

Or as a general purpose and more flexibility you could use Firmata, it gives you the ability control you arduino remotely from your computer (digital_write, digital_read, analog_write, analog_read...), plus there is FirmataVB, it's a .NET component class library that contains methods to send and receive messages using the Firmata V 2.0 protocol, so you don't need to get your hands dirty, just load firmata on your arduino , use the library, and you're done

或作为一般目的和更大的灵活性可以使用Firmata,它让你从你的电脑远程控制你arduino的能力(digital_write、digital_read analog_write,analog_read…),加上FirmataVB,这是一个。net组件类库包含发送和接收消息的方法使用Firmata V 2.0协议,所以你不需要得到你的手脏,只是加载Firmata arduino,使用图书馆,你就完成了

#1


1  

A simple plotter is fairly easy to do. You can spend hours looking for a just right library or program or just write your own in equivalent time.

一个简单的绘图仪是相当容易做到的。你可以花几个小时寻找合适的图书馆或程序,或者只是在相当的时间内编写自己的程序。

Here is how I have done it in the past

这是我过去的做法。

  • Allocate a circular buffer - about 2-4K data points should be sufficient
  • 分配一个循环缓冲区——大约2-4K数据点应该足够了。
  • take your serial data store it in the serial buffer
  • 将串行数据存储在串行缓冲区中。
  • get a drawable area
  • 得到一个可拉的区域
  • map the height of the drawable area to the maximum - minimum value you wish to display
  • 将可绘制区域的高度映射到您希望显示的最大最小值。
  • map the width of the drawable area to the number of points you wish to display
  • 将drawable区域的宽度映射到您希望显示的点的数量。
  • start a thread which takes in the serial data, parses it and puts it in the circular buffer,
  • 启动一个线程,它接收串行数据,解析它并将其放入循环缓冲区中,
  • start another thread which checks for new data in buffer periodically, plots the data in the circular buffer on a back buffer and then updates the drawable area displayed with the backbuffer.
  • 启动另一个线程,该线程定期检查缓冲区中的新数据,在缓冲区的循环缓冲区中绘制数据,然后更新带有backbuffer的drawable区域。

I had a similar issue some time back. I looked for a simple, light program that would do it do out of the box. I finally gave in and coded my own program using Win32 calls. A .NET implementation would be simpler.

我也有过类似的问题。我找了一个简单的,轻松的程序,它可以把它从盒子里拿出来。最后,我用Win32调用编写了自己的程序。net实现会更简单。

http://www.fast-product-development.com/real-time-serial-data-plot.html

http://www.fast-product-development.com/real-time-serial-data-plot.html

#2


0  

There is an example on the arduino playground that does that, you should check it.

在arduino的操场上有一个例子,你应该检查一下。

Or as a general purpose and more flexibility you could use Firmata, it gives you the ability control you arduino remotely from your computer (digital_write, digital_read, analog_write, analog_read...), plus there is FirmataVB, it's a .NET component class library that contains methods to send and receive messages using the Firmata V 2.0 protocol, so you don't need to get your hands dirty, just load firmata on your arduino , use the library, and you're done

或作为一般目的和更大的灵活性可以使用Firmata,它让你从你的电脑远程控制你arduino的能力(digital_write、digital_read analog_write,analog_read…),加上FirmataVB,这是一个。net组件类库包含发送和接收消息的方法使用Firmata V 2.0协议,所以你不需要得到你的手脏,只是加载Firmata arduino,使用图书馆,你就完成了