Click here to Skip to main content
14,176,439 members
   

C#

 
GeneralRe: Collecting my replies Pin
OriginalGriff17-May-19 21:58
protectorOriginalGriff17-May-19 21:58 
GeneralRe: Collecting my replies Pin
jsc4218-May-19 0:12
professionaljsc4218-May-19 0:12 
GeneralRe: Collecting my replies Pin
Brian_TheLion17-May-19 14:42
memberBrian_TheLion17-May-19 14:42 
GeneralRe: Collecting my replies Pin
BillWoodruff17-May-19 16:50
mveBillWoodruff17-May-19 16:50 
GeneralRe: Collecting my replies Pin
Brian_TheLion17-May-19 19:15
memberBrian_TheLion17-May-19 19:15 
AnswerRe: Collecting my replies Pin
Gerry Schmitz17-May-19 15:28
mveGerry Schmitz17-May-19 15:28 
GeneralRe: Collecting my replies Pin
Brian_TheLion17-May-19 17:59
memberBrian_TheLion17-May-19 17:59 
QuestionI can't draw a graph from serialport Data using zedgraph Pin
IlYes Del_SaVior15-May-19 23:04
memberIlYes Del_SaVior15-May-19 23:04 
plz help me , i want to draw a real time graph that read data from an arduino, this is the 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.Ports;
using ZedGraph;


namespace WindowsFormsApplication5
{

    public partial class Form1 : Form
    {
        string DataFromCOM;
        double[] x = new double[100];
        double[] y = new double[100];
        int i;

        PointPairList listPointsOne = new PointPairList();
        LineItem myCurveOne;
        public Form1()
        {
            InitializeComponent();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnConnect_Click(object sender, EventArgs e)
        {
            serialPort1.PortName = txtComPort.Text;
            serialPort1.BaudRate = Convert.ToInt32(txtBaudrate.Text);
            if (serialPort1.IsOpen) return;
            serialPort1.Open();
            btnConnect.Enabled = false;
            btnDisconnect.Enabled = true;


        }
        private void btnDisconnect_Click(object sender, EventArgs e)
        {
            if (serialPort1.IsOpen==false) return;
            serialPort1.Close();
            btnConnect.Enabled = true;
            btnDisconnect.Enabled = false;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            updateports();
            Z1test();

        }
        private void Z1test()
        {
            GraphPane myPane = Z1.GraphPane;
            Z1.IsShowPointValues = true;
            myPane.Title.Text = "Test";
            myPane.XAxis.Title.Text = "RealTime";
            myPane.YAxis.Title.Text = "Value";

            i = 0;
         
        }
        private void updateports()
        {
            string[] ports = SerialPort.GetPortNames();
            foreach (string port in ports)
            {
                txtComPort.Items.Add(port);
            }
        }

        private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            try {
                while (serialPort1.BytesToRead > 0)
                {
                    DataFromCOM = serialPort1.ReadLine();
                    if (DataFromCOM.Trim() != "")
                    {

                        int iDAT = Convert.ToInt32(DataFromCOM);
                        i++;
                        //i = (i + 1) % 100;
                        x[i] = i;
                        y[i] = iDAT;

                        //listPointsOne.Add(i, iDAT);
                        //Z1.GraphPane.AddCurve(null, x, y, Color.Red, SymbolType.Square);
                        //Z1.GraphPane.AddCurve(null, listPointsOne, Color.Red);
                        //Z1.AxisChange();
                        //Z1.Invalidate();


                    }
                }
            }
            catch { }
            
            
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            txtKQ.Text =DataFromCOM;
            Z1.GraphPane.CurveList.Clear();
            Z1.GraphPane.AddCurve(null, x, y, Color.Red, SymbolType.Square);
            Z1.GraphPane.AddCurve(null, listPointsOne, Color.Red);
            Z1.AxisChange();
            Z1.Invalidate();
        }
       
    }
}

AnswerRe: I can't draw a graph from serialport Data using zedgraph Pin
Richard MacCutchan15-May-19 23:33
protectorRichard MacCutchan15-May-19 23:33 
GeneralRe: I can't draw a graph from serialport Data using zedgraph Pin
IlYes Del_SaVior15-May-19 23:35
memberIlYes Del_SaVior15-May-19 23:35 
AnswerRe: I can't draw a graph from serialport Data using zedgraph Pin
OriginalGriff16-May-19 1:18
protectorOriginalGriff16-May-19 1:18 
GeneralRe: I can't draw a graph from serialport Data using zedgraph Pin
Richard MacCutchan16-May-19 1:19
protectorRichard MacCutchan16-May-19 1:19 
AnswerRe: I can't draw a graph from serialport Data using zedgraph Pin
Gerry Schmitz16-May-19 4:04
mveGerry Schmitz16-May-19 4:04 
AnswerRe: I can't draw a graph from serialport Data using zedgraph Pin
Luc Pattyn16-May-19 4:25
professionalLuc Pattyn16-May-19 4:25 
GeneralRe: I can't draw a graph from serialport Data using zedgraph Pin
Jeff_T_123416-May-19 16:42
memberJeff_T_123416-May-19 16:42 
GeneralRe: I can't draw a graph from serialport Data using zedgraph Pin
Luc Pattyn16-May-19 16:45
professionalLuc Pattyn16-May-19 16:45 
GeneralRe: I can't draw a graph from serialport Data using zedgraph Pin
Jeff_T_123416-May-19 16:47
memberJeff_T_123416-May-19 16:47 
GeneralRe: I can't draw a graph from serialport Data using zedgraph Pin
Luc Pattyn16-May-19 16:49
professionalLuc Pattyn16-May-19 16:49 
AnswerRe: I can't draw a graph from serialport Data using zedgraph Pin
Jeff_T_123416-May-19 16:57
memberJeff_T_123416-May-19 16:57 
QuestionWhy is this necessary? Pin
Brian_TheLion15-May-19 19:48
memberBrian_TheLion15-May-19 19:48 
AnswerRe: Why is this necessary? Pin
OriginalGriff15-May-19 20:05
protectorOriginalGriff15-May-19 20:05 
GeneralRe: Why is this necessary? Pin
Brian_TheLion16-May-19 13:50
memberBrian_TheLion16-May-19 13:50 
GeneralRe: Why is this necessary? Pin
OriginalGriff16-May-19 20:14
protectorOriginalGriff16-May-19 20:14 
GeneralRe: Why is this necessary? Pin
Brian_TheLion17-May-19 15:35
memberBrian_TheLion17-May-19 15:35 
GeneralRe: Why is this necessary? Pin
OriginalGriff17-May-19 20:09
protectorOriginalGriff17-May-19 20:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Cookies | Terms of Service
Web05 | 2.8.190525.1 | Last Updated 25 May 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid