|
-
March 26th, 2012, 04:18 AM
#11
Re: Displaying data graphically (Ultrasonic radar)
dglienna: Thanks for your reply! I figured out what was wrong.
I have done some progress since my last post but now I have another problem.
The Visual Basic program is not fast enough to display the real-time data. My motor takes about 4.5 seconds to complete a full rotation (which is 250 steps) but in my Visual Basic display it takes about 10 seconds to complete the full rotation.
I have already changed the Baud rate from my microcontroller but it doesn't improve a lot.
I am planning to do the sweep and display the data at same time (is that possible?) Because I aiming to build a real-time data 'radar'.
And this is how I am receiving the data, splitting it into angle and distance, and plotting the angle (snapshots):
Code:
'from mySerialPort subroutine
inputData = mySerialPort.ReadChar
'from data handling subroutine
Dim data As String
data = Chr(inputData)
If data = " " Then
Temp = ""
Else
Temp &= data
End If
If Temp.Length = 6 Then
angle = Val(Mid(Temp, 1, 3))
radius = Val(Mid(Temp, 4, 3))
PictureBox1.Invalidate()
End If
'from PictureBox1_Paint subroutine
e.Graphics.RotateTransform(angle * 360 / 250, Drawing2D.MatrixOrder.Append)
***EDIT: I am using If data = " " Then Temp = "" and If Temp.Length = 6 because every string has 6 numbers (3: step angle + 3: distance of object detected) and the strings are separated by a " " (space) as I explained in my first post.
Last edited by Alex83UK; March 26th, 2012 at 04:23 AM.
Reason: Code explanations
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|