Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to program USB-6501 in ANSI C?

Hello all,

 

I've got an NI USB-6501 unit and the software which came with it; no LabView or Measurement Studio. I'm trying to control its digital outputs via DAQmx's ANSI C API functions, using Microsoft Visual C++ 2008 Express Edition. DAQmxWriteDigitalLines(), DAQmxWriteDigitalU8(), DAQmxSwitchConnect(), and DAQmxSwitchCloseRelays() look promising, but I haven't been able to get NI's sample code to compile and I don't know what device/relay name to use in the included ControlIndividualRelays.c sample program.

 

I'd like to be able to open and close the eight relays (digital outs) on Port 0 of this device, as can be done with NI's Measurement & Automation Explorer GUI. This probably shouldn't be so difficult, but I'm new to this and unsure how to proceed.

 

Thanks in advance for any assistance you can provide!

 

-- DigitalDave

 

 
0 Kudos
Message 1 of 5
(6,382 Views)

Hi Dave,

 

Just go to Start>Programms>National Instruments>NI DAQ>Textbased Code Support> ANSI C Examples>Digital I/O

There you will find the right functions to use.

 

 

Christian

0 Kudos
Message 2 of 5
(6,372 Views)
Sorry, no. Of course I have already tried this, and as I noted, not only was it not clear which of four or five DAQmx functions to use, but none of the sample code would even compile.
0 Kudos
Message 3 of 5
(6,368 Views)

Did you try to run C:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Digital\Generate Values\Write Dig Port example?

 

The functions would be:

 

DAQmxCreateTask

DAQmxStartTask

DAQmxWriteDigitalU32

DAQmxStopTask

DAQmxClearTask

 

The other functions you mentiond are for NI Switch hardware, not for DIO.

 

Christian

0 Kudos
Message 4 of 5
(6,358 Views)

What error did you receive when you attempted to compile the code?

 

For more help with the functions, you can also check out the NI-DAQmx C Reference Help, which will explain what each of the functions does.  This can be found at Start » Programs » National Instruments » NI-DAQ » Text-Based Code Support.

 

The examples are divided into several different functions.  Some write ports which are a collection of lines which are individual channels on your device.  Some of the examples continuously update the values, while some just update the values once.


Regards,

 

Seth B.
Principal Test Engineer | National Instruments
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 5 of 5
(6,351 Views)