serial examples
Owen
Posts: 100
Does anybody have an example of serial communication between Visual basic and spin using fullduplexserial? Im looking for an example that will help me wrap my head around both the pc and the propeller side of the communication. i'm building a robotic device that uses three stepper motors and needs to comunicate the number of steps to turn and the direction for each motor to the propellar. I have been experimenting with Alberto Geraci's spin stepper driver but have not been able to get predictable results (problems on my side not the driver) my bigest problem is knowing how to send properly formatted data from Visual Basic to the Propellar, I know this should be easy but i'm having a hard time wraping my head around it and an example would be of great benefit to me.
Any example, pointers, links to resources would be of great great help to me.
thanks,
Owen
Any example, pointers, links to resources would be of great great help to me.
thanks,
Owen
Comments
Try the VB help, there is a perfect example of how to do it...
(Unless in the VB 6.0)
If I has some time in the·day, I'll send you one, now I'm just going out.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.
Alberto.
I found one before left. (Comments are in Spanish since my version is in that language).
Private Sub Form_Load () Dim Instring As String MSComm1.CommPort = 1 ' 9600 baudios, sin paridad, 8 bits de datos y 1 ' bit de parada. MSComm1.Settings = "9600,N,8,1" MSComm1.InputLen = 0 MSComm1.PortOpen = True MSComm1.Output = Chr$(pulx) + Chr$(puly) + Chr$(pulz)+ .............etc. ' Aseg
Imports System.IO.Ports
Public Class Form1
··· Dim string1 As Array
··· Dim string2 As Array
··· Dim string3 As Array
··· Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
······· Dim COM1port As SerialPort
······· Dim COM1Read As String
······· Dim datahex As String
······· COM1Read = ""
······· COM1port = New SerialPort("COM1", 115200, Parity.None, 8, StopBits.One)
······· ' // Open the port for communications
······· COM1port.Open()
·
······· COM1port.DtrEnable = True
······· COM1port.RtsEnable = True
······· ' // Write a set of bytes
······· '··· COM1port.Write(New Byte() {&HA, &HE2, &HFF}, 0, 3)
······· '··· COM1port.Write(New Byte() {&HA, &H10, &H13}, 0, 3)
······· '// Close the port
······· For count As Integer = 1 To 1
··········· ' This command sends 4 bytes ( Hex FF, 2, 2, and 3)
··········· '·· COM1port.Write(New Byte() {&HFF, &H2, &H2, &H3}, 0, 4)
······
··········· MsgBox(COM1port.BytesToRead)
··········· For too As Integer = 1 To 1000
··············· If COM1port.BytesToRead <> 0 Then
··················· For tuu As Integer = 1 To 1
······················· MsgBox("Bytes to Read· " & COM1port.BytesToRead)
······················· datahex = Hex(COM1port.ReadByte)
····················
······················· MsgBox("Data Returned is· " & datahex)
··················· Next tuu
··············· End If
··········· Next too
······· Next Count
··· End Sub
··· Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
······· MsgBox(string1)
······· MsgBox(string2)
······· MsgBox(string3)
··· End Sub
End Class
Post Edited (Joe "Bot" Red) : 1/10/2007 3:24:26 PM GMT