Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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

Status
Not open for further replies.

stelikas

Newbie level 4
Joined
Nov 20, 2008
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,324
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.

Ioannis
 

horace1

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,071
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
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
 

zorx

Member level 2
Joined
Feb 15, 2010
Messages
45
Helped
8
Reputation
16
Reaction score
3
Trophy points
1,288
Location
Spain
Activity points
1,635
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: Samples Environment for Microsoft Chart Controls - Home
I guess that calculating FFT for the block of data under C# is not a problem (just google a little bit)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top