Here's my subroutine that has the problem:
This program reads a string "inputstring" that is coming from an Arduino board. It has loadcell and battery voltages coming in in an 8 digit string.
For some reason I am getting a random number for "loadcell", ie it goes from 0.6v to over 1,000v. I added a label to display the string coming in (input string) here is nothing wrong with the incoming data. Notice the last line "SerialPort1.Write("1")", when the arduino board receives this, it flashes an led to indicate the computer program is responding. This led does not flash when the erroneous voltages come in.
This sub runs when the SerialPort recieves data, it was working at 25/s. I tried 100/s but the anomalies began, so I tried, 50, 40, 30, and finally 25/s but I am still getting the bad voltages. Once again, the incoming data is fine...
Suggestions? Totally at a standstill here! :(
Thanks guys!
Ryan
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))
loadcell = ((loadcell / 1024) * 10 - zerovalue) * forcescale
ampbatt = Val(inputstring.Substring(4, 4))
ampbatt = (ampbatt / 1024) * 10
Datachart.Series("DataSeries").Points.AddY(loadcell)
Datachart.ChartAreas(0).AxisX.Minimum = Datachart.ChartAreas(0).AxisX.Maximum - 250
SerialPort1.Write("1")
End If
Catch ex As Exception
End Try
End Sub
For some reason I am getting a random number for "loadcell", ie it goes from 0.6v to over 1,000v. I added a label to display the string coming in (input string) here is nothing wrong with the incoming data. Notice the last line "SerialPort1.Write("1")", when the arduino board receives this, it flashes an led to indicate the computer program is responding. This led does not flash when the erroneous voltages come in.
This sub runs when the SerialPort recieves data, it was working at 25/s. I tried 100/s but the anomalies began, so I tried, 50, 40, 30, and finally 25/s but I am still getting the bad voltages. Once again, the incoming data is fine...
Suggestions? Totally at a standstill here! :(
Thanks guys!
Ryan