Results 1 to 2 of 2

Thread: Using serial port to connect to Sensor circuitry

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    9

    Using serial port to connect to Sensor circuitry

    Hello. I'm doing a project that require a sensor to be connect to my VB application. I've decided to use serial port as it intermediate. so how to write the programming for serial port and how to set it baud rate ? Thanx

  2. #2
    Lively Member StoneTheCrows's Avatar
    Join Date
    Dec 2004
    Location
    UK
    Posts
    71

    Re: Using serial port to connect to Sensor circuitry

    Start a Standard EXE Project.

    From the Projects Menu, Go to Components.

    Check the box for "Microsoft Comm Control 6.0"

    Apply and close the Dialog.

    You should now have a new Component on the tool palette shown as a phone.

    Put this on your form.

    You can set the Properties, including the baud rate, from the properties window. There is even a Custom Propeties Dialog for the control.

    If you need help on using the control, there is an example in the help files that looks like this:

    VB Code:
    1. Private Sub Form_Load ()
    2.    ' Buffer to hold input string
    3.    Dim Instring As String
    4.    ' Use COM1.
    5.    MSComm1.CommPort = 1
    6.    ' 9600 baud, no parity, 8 data, and 1 stop bit.
    7.    MSComm1.Settings = "9600,N,8,1"
    8.    ' Tell the control to read entire buffer when Input
    9.    ' is used.
    10.    MSComm1.InputLen = 0
    11.    ' Open the port.
    12.    MSComm1.PortOpen = True
    13.    ' Send the attention command to the modem.
    14.    MSComm1.Output = "ATV1Q0" & Chr$(13) ' Ensure that
    15.    ' the modem responds with "OK".
    16.    ' Wait for data to come back to the serial port.
    17.    Do
    18.       DoEvents
    19.    Buffer$ = Buffer$ & MSComm1.Input
    20.    Loop Until InStr(Buffer$, "OK" & vbCRLF)
    21.    ' Read the "OK" response data in the serial port.
    22.    ' Close the serial port.
    23.    MSComm1.PortOpen = False
    24. End Sub

    I hope this will get you started.

    StonetheCrows.

Posting Permissions

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



Click Here to Expand Forum to Full Width