Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

Find a function / code example in VB to activate channnels for USB-9472 carrier

Go to solution
Hi all,We bought a USB-9472 carrier to be used in an RF test Set-up. 4 of the 8 channels are connected to 4 Switches (2 states each) which themselves are connected to several Measurement Instruments. I'm trying to find an NI DAQmx C API function (or set of functions) to use them in a VB application which will allow me to change / activate 1 or 2 (24 V) channels at the NI USB-9472 carrier - which is connected through USB with the PC.Can someone help me with that?Thank you,Dan
0 Kudos
Message 1 of 3

Hello Dan,


I understand that you are looking for the NI-DAQmx C Api functions necessary to program your USB-9472 in Visual Basic. Assuming that your computer is running a Windows OS, you can find the NI-DAQmx C API Visual Basic 6.0 Help document by going to Start >> Programs >> National Instruments >> NI-DAQ >> NI-DAQmx C API Visual Basic 6.0 Help.  You will also need to refer to the NI-DAQmx C Reference Help document which is in the same folder.  Lastly, if you would like to see the examples for DAQmx in Visual Basic, you can find the examples at the following (or a similar) location in your directory structure:

C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\Visual Basic 6.0


Best wishes,

Wallace F.

National Instruments
Applications Engineer
0 Kudos
Message 2 of 3
Accepted by topic author Dan P

Hi Wallace, 

I used the function DAQmxWriteDigitalLines.

Initially I tried with parameter: DAQmx_Val_ChanForAllLines and created 1 task for all lines. But the param. writeArray (which is of Byte type) accepts - in VB - only the values 0 or 1 (it should be between 0 and 255)  i.e.: 

Dim ByteArray As Byte


DAQmxErrChk DAQmxCreateTask("", TaskHandle)

DAQmxErrChk DAQmxResetBufInputBufSize(TaskHandle)

DAQmxErrChk DAQmxCreateDOChan(TaskHandle, "Dev1/port0/line0:7", "", DAQmx_Val_ChanForAllLines)

ByteArray = 2

DAQmxErrChk DAQmxWriteDigitalLines(TaskHandle, 1, True, 5000, DAQmx_Val_GroupByChannel, ByteArray, 0, 0)

DAQmxErrChk DAQmxStartTask(TaskHandle)

StopTask (a subroutine to stop and clear the task)


For example, when I assign val. 2 (which is the equivalent to "00000010" in binary), I'm getting the following error message:


DAQmx error code = -200562

Error message = Measurements = Attempting writing digital data that is not supported.


If I assign values 0 or 1 to ByteArray, then everything it's OK, except that I can only activate line 1 (when ByteArray = 1)



So instead of using the param. DAQmx_Val_ChanForAllLines, I used DAQmx_Val_ChanPerLine and I created 4 tasks - 1 for each of the 4 lines that I am using to connect to the Switches.

This way I only need to use 0 (OFF) or 1 (ON) for each Line - and it works.

The Issue should be considered resolved.


Thank you and best regards,

0 Kudos
Message 3 of 3