LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Acquisition questions regarding waveform generation

Hi, 

 

I am recently using the USB 6212 and want to write a small sample code to use the device as a analog voltage signal generator.  I was reading the sample code and encounter some issues, basically I declare the TaskHandle and create a task using 

CreateWaveformOutputInProject(&task); I thought the function already created a task running, so next time when I try to reconfigure the Output, I use 

DAQmxLoadTask("WaveformOutputInProject",&task);   but there is a error:

thread id 0x00000554: Function DAQmxLoadTask: (return value == -200088 [0xfffcf268]). Task specified is invalid or does not exist. Task Name: WaveformOutputInProject Status Code: -200088

 

Does this mean the task only run once after its been  created and then dismissed?  Should I call CreateWaveformOutputInProjet() function everytime when I change something(Amplitude , Frequency,. etc).  Or is there any other way to run them continuesly without refreshing in the code?

In addition, Is there any way I could update the analog output based on the data array I created?(Generates any waveforms if I want to)

 

Thank you in advance. 

 

Best Regards,

0 Kudos
Message 1 of 3
(3,612 Views)

Hello,

 

I am not familiar with the CreateWaveformOutputInProject function you mentioned and cannot find any documentation on it. With DAQmx you can use the

int32 DAQmxCreateTask (char Task_Name[], TaskHandle *Task_Handle);

function to get a hold of your task handle. The DAQmxLoadTask function is meant for loading tasks that were created in NI MAX.

 

Additionally, you can explore the Write Functions under the NI-DAQmx Library tree (bottom left corner of CVI) to find which DAQmx write function might work best for you. Taking a look at the function DAQmxWriteBinaryI16 it "writes unscaled signed integer samples to the task" and takes in an int16 Write_Array[] of values to send to the buffer to be written.

0 Kudos
Message 2 of 3
(3,572 Views)

CreateXXXInProject is the default name for the output of the DAQ Assistant wizard (launched with Tools >> Create/Edit DAQmx Task menu function). As can be understood from the function name, the task is created in the project, which means each time you want to run the task you must call this function. If you want a task to be persisted you may want to create it in MAX, either directly within the Measurment and Automation Explorer or using the same DAQ Assistant.

 

Having said this, if you need to change some parameters of the task you can edit the source code that is generated by the DAQ Assistant and change it in the appropriate way, for example by passing the relevant items as parameters to the function, so that each time is called you can specify the desired frequency, amplitude or what you want.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 3 of 3
(3,554 Views)