Results 1 to 6 of 6

Thread: Serial port help

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Cool Serial port help

    Hi everyone

    I could use some pointer on serial port programming. I haven’t done any hardware type programming as of yet. I have a Heidenhain Length gauge. It uses photoelectric linear encoders. This instrument has a digital readout with a RS232 output line. I’m looking to get the Value off the digital readout and bring it into my program.

    I have put a mscomm32.ocx onto my application. I’ve been reading up on serial port stuff. I’m getting an error on the readout.

    Code
    Private Sub cmdHeidenhain_Click()

    Dim Buffer As Variant
    Dim Arr() As Byte

    ' Set and open port
    MSComm1.CommPort = 1
    MSComm1.PortOpen = True

    ' Set InputMode to read binary data
    MSComm1.InputMode = comInputModeBinary

    ' Wait until 10 bytes are in the input buffer
    Do Until MSComm1.InBufferCount < 10
    DoEvents
    Loop

    ' Store binary data in buffer
    Buffer = MSComm1.Input

    ' Assign to byte array for processing
    Arr = Buffer

    End Sub

    This is the code that I found in the help file.

    I’m not sure what to do with the Variable Arr ?? My plan is to input data and put it into a text box so my app. can use it in my equation.

    Thanks for any help

    Reston

  2. #2
    Lively Member dedub's Avatar
    Join Date
    Dec 2002
    Location
    NC
    Posts
    98
    text1.text = arr

    That should work. I have a working model of a GPS feed through the serial port. Included is a lenthy parse of the text but its commented well.

    good luck
    Attached Files Attached Files
    R.L.T.W. A+, NET+, CCNA

    Doin' my best

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Cool RE: Serial port help

    Hi

    I tried the code for putting the Arr into a text box but i'm not recieving anything from the Heidenhain rs232 that i can see in my app.?? Any thoughts on this

    reston

  4. #4
    Addicted Member
    Join Date
    Feb 2002
    Location
    United
    Posts
    202
    Have u set the communication parameters for your vb program and the gauge ?


    Code:
    MSComm1.CommPort = 1
    MSComm1.Settings = "9600,e,7,1" 'i think u might to set the communication parameters 
    MSComm1.InputLen = 0
    MSComm1.InBufferCount = 0
    MSComm1.OutBufferCount = 0
    If Not MSComm1.PortOpen Then
    MSComm1.PortOpen = True
    End If
    .

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Cool Re: Serial port help

    I did set the mscomm1 control properties at design time.
    9600,n,7,2 These are what the heidenhain rs232 is set to
    reston


  6. #6
    Lively Member dedub's Avatar
    Join Date
    Dec 2002
    Location
    NC
    Posts
    98
    tiguy, a technique I use when messing with the serial port is to use Hyper terminal. It allows you to connect your device and accually see what is coming in without messing with VB. Once you know your computer is interfacing with your device by seeing the feed in hyperterminal then you can move on to your project.

    Good luck
    R.L.T.W. A+, NET+, CCNA

    Doin' my best

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