Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Data Transfer Mechanism IRQ in VB 6.0

I'm trying to configure my NI-USB-6211 to watch for a digital input as an interrupt request instead of an on-demand sample. I'm using Visual Basic 6.0. I've identified the DAQmxSetDIDataXferMech function and the DAQmx_Val_Interrupts value, but the help files I have refer to C code instead of VB code.

From Help:
int32 __CFUNC DAQmxSetDIDataXferMech(TaskHandle taskHandle, const char channel[], int32 data);

So far, I get an "= expected" error when I try to use it in my code:
Private Sub SetupTriggerDAQ()
    Dim sampsPerChanRead As Long
    Dim data As Long
    Dim numBytesPerSamp As Long
    Dim bufferSize As Long
    Dim channelList As String * 255
    Dim arraySizeInBytes As Long
    Dim readArray() As Byte
   
    On Error GoTo ErrorHandler
   
    arraySizeInBytes = 1        'Can be changed to read more digital channels
    bufferSize = 255
   
    '  Re-initialize a dynamic array to hold values read off the digital lines
    ReDim readArray(arraySizeInBytes)
    
    'Load the DAQmx task that was created in NI-DAQ MAX
    DAQmxErrChk DAQmxLoadTask("TriggerDigIn", TriggerHandle)
   
    'Start the task running and read from digital lines
    DAQmxErrChk DAQmxStartTask(TriggerHandle)
    DAQmxErrChk DAQmxReadDigitalLines(TriggerHandle, 1, 10#, _
        DAQmx_Val_GroupByChannel, readArray(0), arraySizeInBytes, _
        sampsPerChanRead, numBytesPerSamp, ByVal 0&)

    DAQmxSetDIDataXferMech(TriggerHandle, "DigitalIn",  DAQmx_Val_Interrupts)
   
    If readArray(0) <> 0 Then
        bTrigger = True
    End If
   
    DAQmxClearTask (TriggerHandle)
    Exit Sub
   
ErrorHandler:
    MsgBox Err.Number & " " & Err.Description, , "Error"
End Sub
Attached is the MAX task that is loaded, should that be of any use. Your help is appreciated.
Thanks,
Chad
0 Kudos
Message 1 of 5
(3,766 Views)

Hi Chad,

I believe the error that you are getting is due to a syntax error in your code, does the error have a line number associated with it? From looking at your code it would also be helpful to see the section where “DigitalIn” is declared to rule out any syntax errors there. You are using the correct function for setting up a IRQ transfer, I would begin troubleshooting by confirming proper syntax on and around the line numbers given in the error.  

JaceD
Signal Sources Product Support Engineer
National Instruments
0 Kudos
Message 2 of 5
(3,753 Views)

Guys,

I have similar problem that I need help with. I need to use interrupt on a given INPUT PIN that notifies my program about its status change. I am using VB6 platform. Would appriciate any clues.

Thanks,

MikeA

0 Kudos
Message 3 of 5
(3,513 Views)
Sorry. I never got this command to work for me. I just ping the digital signal often to look for a change of state.

Good luck.
0 Kudos
Message 4 of 5
(3,510 Views)
Hey MikeA,

Can you give more details about what problems you are having with the function? Are you getting a "= expected" error similar to what Raidoh was getting? Also, can you post the exact error message you are receiving if so?
Regards,

Chris Delvizis
National Instruments
0 Kudos
Message 5 of 5
(3,478 Views)