Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] C# GUI for serial port data ploting

Not open for further replies.


Newbie level 4
Nov 20, 2008
Reaction score
Trophy points
Activity points
Hi to all,

I have a project in which i have to sample a signal with a microcontroller and to plot it in a PC in C# (visual studio).
The microcontroller is programmed allready and i can extract with a terminal the data that the microcontroller send.
My big problem is that i can't plot the data in my PC.
Can someone help me with this. I have to plot the serial data in time and frequency domain (FFT). Until now i can just adjust the parameters of the serial port and just see the data like a terminal.
I don't know how to do the rest. In the end it will look like an oscilloscope with a spectrum analyzer.

Thank you very much.


I have done similar plotting of serial or TCP data in Visual Studio C++ so C# should be similar
1. acquire serial data from a SerialPort component and store in an array
2. using the Form paint() method use a graphics object to plot the array data on the screen
e.g. some sample C++ code
// repaint screen on invalidate
	private: System::Void Form1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
		Graphics^ g = e->Graphics;								// get graphics context
		g->Clear(Color::White);									// clear the background
		Color aColor = Color::Green;							// draw green rectangle
		SolidBrush^ aBrush = gcnew SolidBrush(aColor);
		e->Graphics->FillRectangle(aBrush, 10, 10, 20, 30);
		// draw lines showing potentiometer values
		Pen^ blackPen = gcnew Pen( Color::Black,2.0f );			// draw a black line
		e->Graphics->DrawLine( blackPen, 50, 50, 50 + analogue_pot()/2, 50);
when the plotting reaches the edge of the screen you can scroll the data

Well, since Visual Studio 2008 and now in 2010 there is a MS Chart control that gives you a huge possibilities for drawing a certain type of chart. More about this on: **broken link removed**
I guess that calculating FFT for the block of data under C# is not a problem (just google a little bit)

Not open for further replies.

Part and Inventory Search

Welcome to