Quantcast
Channel: Visio General Questions and Answers for IT Professionals forum
Viewing all articles
Browse latest Browse all 2333

time Vs current reading ploting error

$
0
0

Dear all.

I am trying to plot instantaneous graph time VS current. I am getting data properly . But i could not able to see the  time on x axis. Can some one suggest what need to configure to get x axis data.Which option need to enable . or any changes need to be made.

 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim rnd As New Random

        Static counter As Integer = 0
        Static average_sum As Double = 0
        Static Avg_count As Integer = 0
        Dim Power As Double
        Static Cc_count As Long = 0
        Static watt_hour As Double = 0
        Dim Counter_write As Integer = 60
        Static WH As Double = 0.0
        Try
            SerialPort1.Write("c")
            System.Threading.Thread.Sleep(250)
            Dim ACS_CS As Double = CDbl(SerialPort1.ReadLine())
            Dim voltage As Double = 24.0
            voltage_text.Text = CStr(voltage)
            ListBoxSensor.Text = CStr(ACS_CS)
            Power = (ACS_CS * voltage) / 3600
            Display.Text = CStr(Power)
            WH = WH + Power
            If WH > 1000 Then
                WH = 1.0 + WH
            End If
            WH_text.Text = CStr(WH)

            ' The code to plot instantenous curve.....................................................................

            Dim current_val As Double = ACS_CS
            Dim r As DataRow = dT.NewRow
            r("time") = Now
            r("current") = current_val
            'add the row
            dT.Rows.Add(r)


            ''remove any row older than 1 minute
            'Dim oldestTime As DateTime = Now.AddMinutes(-1)
            'Do While DirectCast(dT.Rows(0)("time"), DateTime) < oldestTime
            '    dT.Rows.RemoveAt(0)
            'Loop
            ''finally bind the chart....
            Chart1.DataBind()

            ' record data into excel sheet...............................................................................
            counter = counter + 1
            If counter = 2 Then
                Dim headerText = ""
                Dim csvFile As String = IO.Path.Combine(My.Application.Info.DirectoryPath, "Current.csv")
                If Not IO.File.Exists((csvFile)) Then
                    headerText = "Date,TIME ,Current,voltage, Watt-Hour, "
                End If
                Using outFile = My.Computer.FileSystem.OpenTextFileWriter(csvFile, True)
                    If headerText.Length > 0 Then
                        outFile.WriteLine(headerText)
                    End If
                    Dim date1 As String = "24-10-2014"
                    Dim time1 As String = CStr(TimeOfDay())
                    Dim current_1 As String = CStr(ACS_CS)
                    Dim voltage_1 As String = CStr(voltage)
                    Dim watt_hour1 As String = CStr(Power)
                    Dim x As String = date1 + "," + time1 + "," + current_1 + "," + voltage_1 + "," + watt_hour1 + "," + vbNewLine
                    outFile.Write(x)
                End Using
            End If

            If counter > 2 Then
                counter = 0
            End If
        Catch ex As Exception

            ' MsgBox("Error in Timer1_Tick: " & ex.Message)
        End Try


    End Sub


Viewing all articles
Browse latest Browse all 2333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>