×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Serial Comms

Serial Comms

Serial Comms

(OP)
Hi,

I am looking at using access (using VBA) to recieve a text file from a data logger though the serial port.

In the past I have created a program using MSCOMM to recieve data from a bar code scanner, but the amount of data was small and im unsure how it would cope with a large amount of data.

I basically used a timer that checked the buffer, if it wasn't empty then it recieved the data into a function that used the data. But how big is the buffer etc?

The code is used was:-

If mscomm1.InBufferCount >= 1 Then
wait
found (mscomm1.Input)
End If

Anybody got any ideas?

Thanks

Ben

RE: Serial Comms

Lucky,

Try something like these examples. You must trigger for individual sources. First see if you can get data to write to a file your ocx creates.
You will have to customize with your own variables in place of "DATA". These may not be functional as is and need to be massaged for your application. As far as the buffer size I'm not sure, maybe in hardware properties. It will help to keep data organized if you identify and write individual files created for each source. I'm no expert here but these examples have helped me in the past. Good Luck
Private Sub Timer1_Timer()

If MSComm1.PortOpen = False Then
    MSComm1.PortOpen = True
End If

If ReadData1 Then

    If MSComm1.InBufferCount >= 1 Then
        temp_data1 = MSComm1.Input
        lastword1 = temp_data1   Returns "Data"
        
        Open "c:\Data1" For Output As #1
        Print #1, "Data,Data1"
        Print #1, "Data1," + lastword1
        Close #1
    End If
        MSComm3.InputLen = 0
   
End If
End Sub

OR....

Private Sub Timer1_Timer()

If SAVEDATA Then    

Dim Fso As New FileSystemObject

    JULIANDATE = Format(Date, "Y")
    JULIANDATE3 = Format(JULIANDATE, "000")
    
        If Not Fso.FolderExists("c:\data") Then
            Fso.CreateFolder "c:\data\"
        End If
        If Not Fso.FolderExists("c:\data\" & DATA & "\") Then
            Fso.CreateFolder "c:\data\" & DATA & "\"
        End If
        FileName = "c:\data\"  & Date & ".csv"
        If Not Fso.FileExists(FileName) Then
            Open FileName For Append As #1
            Print #1, "Time, DATA,"
            Close #1
        End If
        Open FileName For Append As #1
        Print #1, JULIANDATE & "," & JULISNDATE3 & "," & Time & "," & DATA
        Close #1

Set Fso = Nothing
    
End If

End Sub

RE: Serial Comms

bmoynihan,

What you did with a Timer is called hardware-polling.  Another approach is to use interrupts.  In VB it is done using "events".  Investigate about "OnComm" event in MSComm control.  There are examples in MSDN.

Yeasir Rahul
www.voltsmith.com

Yeasir Rahul
http://www.voltsmith.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources