12-09-2009 07:57 PM
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
12-10-2009 02:50 AM
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
12-10-2009 06:55 AM
12-10-2009 07:58 AM
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
12-10-2009 10:04 AM
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,