Click here to Skip to main content
14,878,932 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to understand how to take the data that was received from the serial port
and plot it on a graph

What I have tried:

In my project I have a chart and a thread that does this:

Private Sub AddDataThreadLoop()
   While True 
      Chart1.Invoke (AddDataDel) 'AddDataDel is a Delegate.
   End While
End Sub

The received Serial data needs to go here:


which is inside this sub that updates the graph:

Public Sub AddData()
    Dim timeStamp As DateTime = DateTime.Now

    Dim ptSeries As Series
    For Each ptSeries In Chart1.Series
        AddNewPoint(timeStamp, ptSeries)
    Next ptSeries
End Sub

I am using SerialPort1.ReadExisting() with the SerialPort1.DataReceived Handle.
The program is running but nothing is plotted to the graph.
Updated 27-Feb-18 4:11am
OriginalGriff 27-Feb-18 8:58am
"It doesn't work" is probably the most useless problem report we get - and we get it a lot. It tells us nothing about what is happening, or when it happens.
So tell us what it is doing that you didn't expect, or not doing that you did.
Tell us what you did to get it to happen.
Tell us any error messages.
Use the "Improve question" widget to edit your question and provide better information.
Member 13308214 27-Feb-18 9:56am
Question "Improved".
If there were any error I would've said that.
Sorry for the lack of vocabulary.
OriginalGriff 27-Feb-18 10:13am
It's not vocabulary, it's context - as in we don't have any! We can't see your screen, access your HDD or read your mind - so we have no idea what "it doesn't work" means: it could you app freezes up and does nothing, it throws an exception, crashes, or sets fire to your computer! :laugh:
We have absolutely no information that you don't explicitly give us: so when you don't tell us anything, we can't help you.
And we can't see your delegate, we have no idea where that code you do show is running, and on what thread; we literally have no ideas what you are doing to get a problem.
Richard MacCutchan 27-Feb-18 10:50am
"The program is running but nothing is plotted to the graph."
You need to do some debugging to find out why. There is no way we can guess what data is being received on your serial port, or what happens to it after it has been received.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900