none
how can i get a real time high frecuency chart with a winform RRS feed

  • Question

  • i'm making a project where i'm trying to get an EEG monitor, with the data comming from the arduino, EEG measures frecuencys from 10-30 Hz, wich means i would need to measure at least 60 samples per second (60 Hz) to get a valid representation of the signal... 

    the code i'm using right now is this one:

    private void serialDataReceivedEventHandler(object sender, SerialDataReceivedEventArgs e)
            {
                try // en caso de que ya este proceso haya iniciado y se precione el boton de cerrar el puerto, produce un error
                {
                    SerialPort sData = sender as SerialPort;
                    string recvData = sData.ReadLine();

                    //LOG.BeginInvoke((MethodInvoker)delegate { LOG.AppendText("Received: " + recvData); });

                    // initialization of chart update
                    double data;
                    bool result = Double.TryParse(recvData, out data);
                    if (result)
                    {
                        medicion m = new medicion(recvData, tag, data);
                        if (tag == null)
                        {
                            m = new medicion(recvData, " ", data);
                        }
                        else
                        {
                            m = new medicion(recvData, tag, data);
                            tag = null;
                        }
                        //datarecorded.Add(recvData);
                        this.Invoke((MethodInvoker)delegate { updatechart(m); });

                    }
                }
                catch
                {
                    //MessageBox.Show("failed");//do nothing ... test msg
                }
            }

    this trigers whenever the serial port gets a msg, now the program is working too slow, so the chart falls behind with the real time data, it represents the graph good, but too slow.

    could anyone has a clue how could i make the graph update at a faster rate?

    the ideal scenario would be to keep using the chart since i need the graph to be "infinite" and scrollable.

    thanks in advance.


    Tuesday, January 7, 2020 2:52 AM

All replies

  • Hi David,

    Thank you for posting here.

    Based on my search, SerialPort seems to have some flaws in the design. Moreover, a large number of Invoke operations will also affect the performance of the program to a certain extent.

    Because your question involves arduino and EEG, I am afraid we cannot reproduce your question.

    I found some links and hope it can help you.

    If you *must* use .NET System.IO.Ports.SerialPort

    C# real time chart desktop application too slow

    c# Serial DataReceived very slow

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 7, 2020 6:17 AM
  • It is likely a problem with the serial port input and output. Serial I/O is not easy. If you are developing the Serial I/O yourself without the benefit of a library then expect to spend a couple of months, at least a month, learning about Serial I/O.


    Sam Hobbs
    SimpleSamples.Info

    Tuesday, January 7, 2020 8:02 AM