Data Acquisition with Excel 2003

G

Gene Augustin

Is there a way to read the data from a COM port directly into Excel?



I have a macro with the following, but it doesn't run:

Public Sub DAQ_Procedure()
' Data Acquisition Procedure

Dim message As String, temp As Single, n As Long

If DAQ_state = running Then

DAQ_counter = DAQ_counter + 1
' increment acquisiton sample counter
Worksheets(1).Range("B2") = DAQ_counter
' and display it inside spreadsheet in real time

Worksheets(1).MSComm1.Output = "adc 1" + vbLf
' ask µChameleon for voltage on its adc input pin 1

message = ""
Do
' wait for reply from µChameleon
DoEvents
message = message & Worksheets(1).MSComm1.Input
Loop Until InStr(message, vbLf)
words = Split(message)
' analyse answer - syntax should be : adc 1 <value>

Worksheets(1).Cells(DAQ_counter, 4) = Val(words(2))
' add measured value in column D, in successive rows

If DAQ_counter >= 60 Then DAQ_state = stopped
' do that for a minute
Application.OnTime Now + TimeValue("00:00:01"), "DAQ_Procedure"
' launch next acquisiton in one second

Else

Worksheets(1).MSComm1.Output = "led pattern 254" + vbCrLf
' set activity led back to its default pattern so we know it stopped
Worksheets(1).MSComm1.PortOpen = False
' and close communications port

End If

End Sub
 
C

CyberTaz

You've gotten misdirected into the Mac Excel group -- have a look here for
the Win Excel groups:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top