braunb
2006-10-04 12:40:09 UTC
Hello,
I want to write data in to the fifo of the NI6534 I/0-card.
After then I will generate an data outpu stream with
by using the internal clock source.
I use Visual Basic 6.0 from Microsoft Excel.
My example compiles well, but I got a runtime error by following function call:
DAQmxErrChk
DAQmxCfgSampClkTiming(taskHandle, "", 1000, DAQmx_Val_Rising,
DAQmx_Val_AcquisitionType_FiniteSamps, 32)
Who has an idea, which would be the reason for this runtime
error! I guess it is a variable presentation problem of the variable
rate. Is that function usable in VB6.0 or works this function only in a
C enviroment?
the whole example below:
Dim sampsPerChanWritten As Long
Dim test As Long
Dim taskHandle As
Long
Dim delay As Double
Dim status As Integer
Dim data(256)
As Byte
Private Sub
Port_Out_Click()
DAQmxErrChk
DAQmxCreateTask("", taskHandle)
DAQmxErrChk
DAQmxCreateDOChan(taskHandle, "Dev3/port0", "",
DAQmx_Val_ChanForAllLines)
DAQmxErrChk
DAQmxCfgSampClkTiming(taskHandle, "", 1000, DAQmx_Val_Rising,
DAQmx_Val_AcquisitionType_FiniteSamps, 32)
For i = 0 To 255
data(i) = 1
Next
i
DAQmxErrChk DAQmxWriteDigitalLines(taskHandle, 32, False, 10#,
DAQmx_Val_GroupByChannel, data(0), sampsPerChanWritten, ByVal
0&)
DAQmxErrChk DAQmxStartTask(taskHandle)
DAQmxErrChk DAQmxWaitUntilTaskDone(taskHandle, 10)
DAQmxErrChk DAQmxClearTask(taskHandle)
End Sub
Public Sub
DAQmxErrChk(errorCode As Long)
'
' Utility function to handle errors by recording the
DAQmx error code
' and message.
'
Dim errorString As
String
Dim bufferSize As Long
Dim status As Long
If (errorCode < 0) Then
' Find out
the error message length.
bufferSize =
DAQmxGetErrorString(errorCode, 0, 0)
'
Allocate enough space in the string.
errorString = String$(bufferSize, 0)
'
Get the actual error message.
status =
DAQmxGetErrorString(errorCode, errorString, bufferSize)
' Trim it to the actual length, and display the
message
errorString = Left(errorString,
InStr(errorString, Chr$(0)))
Err.Raise
errorCode, , errorString
End If
End
Sub
I want to write data in to the fifo of the NI6534 I/0-card.
After then I will generate an data outpu stream with
by using the internal clock source.
I use Visual Basic 6.0 from Microsoft Excel.
My example compiles well, but I got a runtime error by following function call:
DAQmxErrChk
DAQmxCfgSampClkTiming(taskHandle, "", 1000, DAQmx_Val_Rising,
DAQmx_Val_AcquisitionType_FiniteSamps, 32)
Who has an idea, which would be the reason for this runtime
error! I guess it is a variable presentation problem of the variable
rate. Is that function usable in VB6.0 or works this function only in a
C enviroment?
the whole example below:
Dim sampsPerChanWritten As Long
Dim test As Long
Dim taskHandle As
Long
Dim delay As Double
Dim status As Integer
Dim data(256)
As Byte
Private Sub
Port_Out_Click()
DAQmxErrChk
DAQmxCreateTask("", taskHandle)
DAQmxErrChk
DAQmxCreateDOChan(taskHandle, "Dev3/port0", "",
DAQmx_Val_ChanForAllLines)
DAQmxErrChk
DAQmxCfgSampClkTiming(taskHandle, "", 1000, DAQmx_Val_Rising,
DAQmx_Val_AcquisitionType_FiniteSamps, 32)
For i = 0 To 255
data(i) = 1
Next
i
DAQmxErrChk DAQmxWriteDigitalLines(taskHandle, 32, False, 10#,
DAQmx_Val_GroupByChannel, data(0), sampsPerChanWritten, ByVal
0&)
DAQmxErrChk DAQmxStartTask(taskHandle)
DAQmxErrChk DAQmxWaitUntilTaskDone(taskHandle, 10)
DAQmxErrChk DAQmxClearTask(taskHandle)
End Sub
Public Sub
DAQmxErrChk(errorCode As Long)
'
' Utility function to handle errors by recording the
DAQmx error code
' and message.
'
Dim errorString As
String
Dim bufferSize As Long
Dim status As Long
If (errorCode < 0) Then
' Find out
the error message length.
bufferSize =
DAQmxGetErrorString(errorCode, 0, 0)
'
Allocate enough space in the string.
errorString = String$(bufferSize, 0)
'
Get the actual error message.
status =
DAQmxGetErrorString(errorCode, errorString, bufferSize)
' Trim it to the actual length, and display the
message
errorString = Left(errorString,
InStr(errorString, Chr$(0)))
Err.Raise
errorCode, , errorString
End If
End
Sub