Ahelion
Ahelion

Reputation: 1

Plot data from the serial port

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.

How do I plot the data in real time?

Upvotes: -1

Views: 1706

Answers (1)

Sanjay Mishra
Sanjay Mishra

Reputation: 11

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
  • 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
  • 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.

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.

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

Upvotes: 1

Related Questions