Continue to Site

Welcome to EDAboard.com

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

Realtime graph serail port

Status
Not open for further replies.

kingf

Newbie level 1
Newbie level 1
Joined
Oct 6, 2016
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
7
Hello
I Need help which code can I Input in this code for REal time Graph


Thanks
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.IO.Ports;
using System.Management;


namespace Graphs
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Application.Exit();   //Programm schliessen
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string[] ports = SerialPort.GetPortNames();
            foreach (string port in ports)
            {
                comboBox1.Items.Add(port);
            }
        }

        string t;

        private void button2_Click(object sender, EventArgs e)
        {
            t = comboBox1.Text.ToString();

            sErial(t);

        }
        SerialPort sp;
        void sErial(string Port_name)
        {
            sp = new SerialPort(Port_name, 9600, Parity.None, 8, StopBits.One);

            sp.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
            sp.Open();


        }

        private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
        {

            SerialPort sp = (SerialPort)sender;

            string w = sp.ReadLine();

            //string msg = sp.ReadExisting();
            if (w != String.Empty)
            {
                Invoke(new Action(() => richTextBox1.AppendText(w)));
            }
        }

        

        


        }






    }
 

You had not mentioned anything about operational system, compiler, hardware platform, sample rate, etc... Anyway, as a general rule on “real time plot” based on preempive systems is by using interruptions to give an accurate tick time so that you can assure that all samples will be sent with high priority without being scheduled after tasks with lower priority. In the past I did something similar, but with external interrupts, where an external board sent requests at precise intervals and PC immediatelly responded with the next sample of database.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top