LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Write analog values to USB-6009

I am trying to write a single analog value to the AoO ouput to the USB-6009 device.  In my program the user will choose what the value will be set as instantaneously.  I have not found any example code to give examples of this or anything close to it.  I have found the "output drive type" example but it pertains to digital ouptuts.  
 
I am using the DAQmxWriteAnalogF64 function, but it doesnt seem to be what I need  exactly (I dont need an array, just a single value) but I havent found any other functions that are useful (none came with the CD included with the NI-USB-6009).  As well I have found  the 'NIDAQmx I/0 Controls' instrument and I have loaded it, but is there any other .fp file that I should be loading and using with more write functions than what is in NI-DAQmx LIbrary?
 
Here is the relevant lines of code that I have so far, no errors, but no voltage shows up on the ouput. 
 
NIDAQmx_NewChannelAOCtrl (panelHandle, PANEL_CHANNEL_2, 1)
DAQmxCreateTask ("", &analog_task)
DAQmxCreateAOVoltageChan (analog_task, "Dev1/Ao0", "", 0, 5.0, DAQmx_Val_Volts, "");
DAQmxStartTask(analog_task);
DAQmxWriteAnalogF64 (analog_task, 1, 1, 5.0, DAQmx_Val_GroupByChannel, write_array, &samples_per_chan, 0);
 
with write array declared as followed      static float64 write_array[1];
 
Is there anything wrong or missing with the above code?
 
 
It should be noted as well that I am able to get output when i create a task in the Measurement & Automation Explorer on the same port.
 
Thanks in advance
0 Kudos
Message 1 of 2
(2,987 Views)
Hello eward,

The NI-DAQmx driver should install text-based examples on your machine under the directory C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C.  There are several examples in there that show how to program analog output.  I would also recommend the document titled DAQmx C  Reference Help, which can be found under Start >> Programs >> National Instruments >> NI-DAQ.

Your code looks fine, you are using the function calls in the correct order, but you should nest those functions in DAQmxErrChk fucntions to handle error checking.  See the example programs for how to do this.  Also are you including the following header file in your program?

#include "NIDAQmx.h" 

I hope this helps!

Regards,
Travis G.
0 Kudos
Message 2 of 2
(2,961 Views)