My program reads data coming in from a serial port, this data includes battery voltages, and a load cell reading. If the "logging" button has been activated, then it should place some of this data in the chart below the graph (the graph is update regardless). For some reason, once I added the battery voltages, I can not get the graph and chart to update at the same time. If I stop the logging, then the graph runs fine, if I start the logging it starts to slow down and the program barely runs?
Screenshot below
Code:
Care to help?
Thanks!
Ryan
Screenshot below
Code:
Code:
Private Sub GetData()
Try
If InvokeRequired Then
Me.Invoke(New MethodInvoker(AddressOf GetData))
Else
'get voltage data from loadcell, main batt, and ampbatt
inputstring = SerialPort1.ReadLine
loadcell = Val(inputstring.Substring(0, 4)) / 1024 * 10
inForce = (loadcell - zerovalue) * forcescale
Datachart.Series("DataSeries").Points.AddXY(Timer.Elapsed.TotalSeconds, inForce)
Datachart.ChartAreas(0).AxisX.Minimum = Datachart.ChartAreas(0).AxisX.Maximum - 5
SerialPort1.Write("1")
If logging = 1 Then
DataGrid.RowCount = DataGrid.RowCount + 1
row = DataGrid.RowCount - 1
DataGrid.Rows(row).Cells(1).Value = Math.Round(Timer.Elapsed.TotalSeconds, 4)
DataGrid.Rows(row).Cells(2).Value = Math.Round(loadcell, 4)
DataGrid.Rows(row).Cells(3).Value = Math.Round(inForce, 4)
If Not DataGrid.Rows(row).Displayed Then
DataGrid.FirstDisplayedScrollingRowIndex = row - 2
End If
End If
Try
mainbatt = Val(inputstring.Substring(4, 4)) / 1024 * 10
ampbatt = Val(inputstring.Substring(8, 4)) / 1024 * 10
Label_AmpBatt.Text = Math.Round(ampbatt, 3).ToString + "V"
Label_MainBatt.Text = Math.Round(mainbatt, 3).ToString + "V"
Catch ex As Exception
End Try
End If
Catch ex As Exception
End Try
End Sub
Thanks!
Ryan