Assistance Required with VB.net


Closed Thread
Results 1 to 33 of 33

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest

    Default Assistance Required with VB.net

    Guys, I'm looking for someone who has good knowledge of VB.net (2008 Express version). I've downloaded VB Express 2008 edition from MS but haven't really got a clue how to get an application to read and write via the RS232 port.

    Designing a form was simples (the boxes are simple typed values on how I would like the end result to look)


    I've managed to send the values from the list of variables to a terminal app in MCS via the EasyPIC5 serial port, but can't get my head round any example from the web on serial communications.

    If anyone can point me to some easy to understand tutorials, or would be willing to work with me via e-mail on this part of my project please feel free to drop me a PM.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    This came up the other day and Darrel pointed to this
    http://www.rentron.com/VisualBasic.htm
    Maybe it works the same with VB Net?
    Dave
    Always wear safety glasses while programming.

  3. #3
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks Dave,

    I'll have a look at it in some detail in a moment, but on first glance it looks like VB6 rather than the (dot)net version. From my googling sessions it seems that earlier versions of VB had a serial comms module or connection to variables that is somewhat missing in the dotnet version !

  4. #4


    Did you find this post helpful? Yes | No

    Default can vb.net be discussed here ?

    nice interface you made.
    just for general discussion,
    I have made a vb.net form to rcv assorted stuff from pic, you may know more about microsoft .net than me, I have just read books and watched on-line learning vids.
    as a start, you use a serial port object, a stream object, I used a timer to check for rcvd chars 10 or 50 times/sec then looped through data for a key-value situation. then displayed to appropiate box. was able to use a blue-tooth module set up as virtual com port to rcv just like a direct connect.
    also, with serial port set up, it is easy to send stuff back to my PIC ckt as settings or commands. i have further ideas floating in my head (mabye sinking in my head) web stuff etc.
    not sure if the forum wants this subject matter here but my initial interest was and is PIC interfacing .
    don f
    [email protected]

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I moved this thread to the "Off Topic" area.
    As long as this discussion is about interfacing to a MCU I think it is "OK" to discuss VB here.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I moved this thread to the "Off Topic" area.
    As long as this discussion is about interfacing to a MCU I think it is "OK" to discuss VB here.
    Are there limits to the "off topic" topics?

  7. #7
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    I could understand if I was after help with writing a VB application to read a database or something equally obscure, but this is related to sending and receiving data to and from a PIC, or more importantly how to formulate VB code and PBP code so that the two work together.

    Don, what you have mentioned has given me some idea as to what I need. If you have any links to those tutorials it would be appreciated

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tenaja View Post
    Are there limits to the "off topic" topics?
    It has always been my understanding that the "Off Topic" area is for forum "things", electronics questions, and any other "thing" not specific to PB or PBP but in a round about way related to PB or PBP or the forum.
    Dave
    Always wear safety glasses while programming.

  9. #9
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default

    Hi;

    I think i can help, however you need to be more clear about your issue.
    I I'll put here some code,

    VB2008 Net Code;
    First you need to add the serilport class to your project.
    Code:
    Public Class Form1
        Dim WithEvents SerialPort1 As New IO.Ports.SerialPort
    Then, at Form Load, you need to configure and open your SerialPort;
    Code:
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
            SerialPort1.PortName = "COM1"
            SerialPort1.Parity = IO.Ports.Parity.None
            SerialPort1.BaudRate = 19200
            SerialPort1.DataBits = 8
            SerialPort1.StopBits = 1
            SerialPort1.Open()
            SerialPort1.Write(Chr(13) & "Hugo Oliveira" & Chr(13))
        End Sub
    This handles the recetion from the buffer of the com port, and then i have a If statment to do the actions that need to be perfomed acording with the received data.
    Code:
        Private Sub DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
            Dim recepcao As String
    
            recepcao = SerialPort1.ReadExisting
    
            If recepcao = "%TE" Then
                GetCursorPos(rect)
                SetCursorPos(rect.X - 1, rect.Y)
            ElseIf recepcao = "%TD" Then
                GetCursorPos(rect)
                SetCursorPos(rect.X + 1, rect.Y)
            ElseIf recepcao = "%TC" Then
                GetCursorPos(rect)
                SetCursorPos(rect.X, rect.Y - 1)
            ElseIf recepcao = "%TB" Then
                GetCursorPos(rect)
                SetCursorPos(rect.X, rect.Y + 1)
            ElseIf recepcao = "%TE1" Then
                GetCursorPos(rect)
                SetCursorPos(rect.X - 10, rect.Y)
            ElseIf recepcao = "%TD1" Then
                GetCursorPos(rect)
                SetCursorPos(rect.X + 10, rect.Y)
            ElseIf recepcao = "%TC1" Then
                GetCursorPos(rect)
                SetCursorPos(rect.X, rect.Y - 10)
            ElseIf recepcao = "%TB1" Then
                GetCursorPos(rect)
                SetCursorPos(rect.X, rect.Y + 10)
            ElseIf recepcao = "%TE2" Then
                GetCursorPos(rect)
                SetCursorPos(rect.X - 20, rect.Y)
            ElseIf recepcao = "%TD2" Then
                GetCursorPos(rect)
                SetCursorPos(rect.X + 20, rect.Y)
            ElseIf recepcao = "%TC2" Then
                GetCursorPos(rect)
                SetCursorPos(rect.X, rect.Y - 20)
            ElseIf recepcao = "%TB2" Then
                GetCursorPos(rect)
                SetCursorPos(rect.X, rect.Y + 20)
            End If
        End Sub

    With this piece of code in VB, you must with 100% sure, receive data from Com Port.

    Where is a part of code, from sendinf the data out of the pic, in PBP. I use the Debug command, but you can use Hserout, if you are using te Uart of the PIC, or Serout, Serout2 command.
    Code:
    Main:
    if JX>70 and JX<=100 then
       DEBUG "%TE"
       pause 20
      endif
      
       if JX>0 and JX<=70 then
       DEBUG "%TE1"
       pause 20 
      endif 
      
      if Jx>180 and Jx<210 then
       DEBUG "%TD"
       pause 20
      endif 
      
      if Jx>=210 then
       DEBUG "%TD1"
       pause 20
      endif
    '                             JoyStick Eixo Y
    ' ====================================================================  
      if JY>70 and JY<=100 then
       DEBUG "%TB"
       pause 20 
      endif
      
      if JY>0 and JY<=70 then
       DEBUG "%TB1"
       pause 20 
      endif  
      
      if Jy>180 and Jy<210 then
       DEBUG "%TC" 
       pause 20
      endif
      
      if Jy>=210 then
       DEBUG "%TC1" 
       pause 20
      endif    
    '                             Axis -  Eixo X
    ' ====================================================================
      if Ax<100 then
       DEBUG "%TE2"
       pause 20 
      endif
      
     if Ax>140 then
       DEBUG "%TD2" 
       pause 20
      endif
    '                             Axis -  Eixo Y
    ' ====================================================================  
      if Ay<110 then
       DEBUG "%TB2" 
       pause 20
      endif
      
      if Ay>140 then
       DEBUG "%TC2" 
       pause 20
      endif
    '                             Botões
    ' ====================================================================    
      IF BE = 0 then
       DEBUG "%RL1" 
       pause 80
      endif
    
      IF BD = 0 then
       DEBUG "%RD1" 
       pause 80
      endif    
    goto Main
    Hope it can hep.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts