|
-
March 7th, 2010, 07:43 PM
#1
Using a DAQ + VB6.0
Hey everyone,
I'm very new to VB and I'm doing a school project very similar to the "Dance Dance Revolution" game with a dance pad along with a USB-1024LS data acquisition board (DAQ) and then programing the actually game/GUI using VB6.0. (Just a quick background on the dance if people don't know about it, the user has to step on a dance square whenever the an arrow is displayed on a GUI. At the end the game will show the user's score... higher the score the more correct dance steps were taken.) I actually tested my board and I received the voltages from my homemade dance pad I made.
Now the problem is that I'm using the MSComm control to read the outputs of the voltages but I'm having a hard time figuring this out... I looked at the microsoft website and they have a sample code using MSComm with a microcontroller but I get errors for the settings code at the top of the code saying "object required." I placed just a textbox and the MSComm control because I want the program to read the output voltages (in ASCII?) in the textbox.
Code was found from the microsoft website:
Private Sub Form_Load()
Form1.Caption = "App2"
With MsComm2
.CommPort = 2
.Handshaking = 2 - comRTS
.RThreshold = 1
.RTSEnable = True
.Settings = "9600,n,8,1"
.SThreshold = 1
.PortOpen = True
' Leave all other settings as default values.
End With
Text1.Text = ""
End Sub
Private Sub Form_Unload(Cancel As Integer)
MsComm2.PortOpen = False
End Sub
Private Sub MSComm1_OnComm()
Dim InBuff As String
Select Case MSComm1.CommEvent
' Handle each event or error by placing
' code below each case statement.
.
' Errors
Case comEventBreak ' A Break was received.
Case comEventCDTO ' CD (RLSD) Timeout.
Case comEventCTSTO ' CTS Timeout.
Case comEventDSRTO ' DSR Timeout.
Case comEventFrame ' Framing Error.
Case comEventOverrun ' Data Lost.
Case comEventRxOver ' Receive buffer overflow.
Case comEventRxParity ' Parity Error.
Case comEventTxFull ' Transmit buffer full.
Case comEventDCB ' Unexpected error retrieving DCB]
' Events
Case comEvCD ' Change in the CD line.
Case comEvCTS ' Change in the CTS line.
Case comEvDSR ' Change in the DSR line.
Case comEvRing ' Change in the Ring Indicator.
Case comEvReceive ' Received RThreshold # of chars.
InBuff = MSComm1.Input
Call HandleInput(InBuff)
Case comEvSend ' There are SThreshold number of
' characters in the transmit buffer.
Case comEvEOF ' An EOF character was found in the
' input stream.
End Select
End Sub
Sub HandleInput(InBuff As String)
' This is where you will process your input. This
' includes trapping characters, parsing strings,
' separating data fields, etc. For this case, you
' are simply going to display the data in the TextBox.
Text1.SelStart = Len(Text1.Text)
Text1.SelText = InBuff
End Sub
If anybody knows how to use MSComm with a DAQ board please help me out 
Thanks!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|