Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

PXI-6289 DAC takes long time to set

Solved!
Go to solution

I am using a PXI-6289 and a PXIe-8101 controller. The controller is setup with a real-time OS. Recently I moved from LabWindows/CVI 2012 to 2013. When I made changes to my application on the PXI I had to update the software on the PXI system so it would be compatible with the software in the LabWindows/CVI. After I did this I recompiled my PXI application and noticed some undesirable behavior. I finally narrowed it down to the part where I am setting the DAC on the PXI-6289. I noticed it is taking 80ms to change the DAC output. I am thinking I might have some software installed which has some compatibility issues with the realtime OS on the PXI. The software installed is the NI-DAQmx 9.7.5. Has anyone had similar problems?

 

It probably would not be noticeable in most applications but I can see it because I am measuring the transient response of an RC filter so I am trying to catch the DAC setting change while I am acquiring a waveform with the DUT. Like I said this only started happening after I moved from LabWindows/CVI 2012 to 2013 so I think it might be the software. Below is a snippet fo the code which sets the DAQ; maybe there is a better way of doing this.

 

DAC_statusMessages_t SetDACoutput(double output)
{
 DAC_statusMessages_t status = DAC_OUT_STATUS_OK;
 float64 VoltageLevel;
 char ErrorMessage[DAC_ETHERNET_MESSAGE_LEN];
 char DAQ_ErrorMessage[DAC_MESSAGE_LEN];
    TaskHandle taskDACOut;
 int32 returnDAQmx_status;
 char DeviceName[AO_6289_CHAN_TEXT_SIZE]; 

 strncpy(DeviceName, PXI_6289_NAME_STR, sizeof(DeviceName));
 strncat(DeviceName, DAC_OUT_CHAN_0, sizeof(DeviceName));
 VoltageLevel = (float64) (output);

 returnDAQmx_status = DAQmxCreateTask("DACOutTask",&taskDACOut);
 if( 0 != returnDAQmx_status)
 {
  strncpy(ErrorMessage,"DAC out Error: ", DAC_ETHERNET_MESSAGE_LEN);
  DAQmxGetErrorString (returnDAQmx_status, DAQ_ErrorMessage, DAC_MESSAGE_LEN);
  strncat(ErrorMessage,DAQ_ErrorMessage,DAC_ETHERNET_MESSAGE_LEN);
  strncat(ErrorMessage,"\n",DAC_ETHERNET_MESSAGE_LEN);
  SendRT_ErrorMessage(ErrorMessage);
  // Clear the task
  DAQmxClearTask (taskDACOut);
  return DAC_OUT_STATUS_NOK;
 }
    returnDAQmx_status = DAQmxCreateAOVoltageChan(taskDACOut,DeviceName,"",-10.0,10.0,DAQmx_Val_Volts,"");
 if( 0 != returnDAQmx_status)
 {
  strncpy(ErrorMessage,"DAC out Error: ", DAC_ETHERNET_MESSAGE_LEN);
  DAQmxGetErrorString (returnDAQmx_status, DAQ_ErrorMessage, DAC_MESSAGE_LEN);
  strncat(ErrorMessage,DAQ_ErrorMessage,DAC_ETHERNET_MESSAGE_LEN);
  strncat(ErrorMessage,"\n",DAC_ETHERNET_MESSAGE_LEN);
  SendRT_ErrorMessage(ErrorMessage);
  // Clear the task
  DAQmxClearTask (taskDACOut);
  return DAC_OUT_STATUS_NOK;
 }
    /*********************************************/
    // DAQmx Start Code
    /*********************************************/
    returnDAQmx_status = DAQmxStartTask(taskDACOut);
 if( 0 != returnDAQmx_status)
 {
  strncpy(ErrorMessage,"DAC out Error: ", DAC_ETHERNET_MESSAGE_LEN);
  DAQmxGetErrorString (returnDAQmx_status, DAQ_ErrorMessage, DAC_MESSAGE_LEN);
  strncat(ErrorMessage,DAQ_ErrorMessage,DAC_ETHERNET_MESSAGE_LEN);
  strncat(ErrorMessage,"\n",DAC_ETHERNET_MESSAGE_LEN);
  SendRT_ErrorMessage(ErrorMessage);
  // Clear the task
  DAQmxClearTask (taskDACOut);
  return DAC_OUT_STATUS_NOK;
 }

        /*********************************************/
        // DAQmx Write Code
        /*********************************************/
    returnDAQmx_status = DAQmxWriteAnalogF64(taskDACOut,1,1,10.0,DAQmx_Val_GroupByChannel,&VoltageLevel,NULL,NULL);
 if( 0 != returnDAQmx_status)
 {
  strncpy(ErrorMessage,"DAC out Error: ", DAC_ETHERNET_MESSAGE_LEN);
  DAQmxGetErrorString (returnDAQmx_status, DAQ_ErrorMessage, DAC_MESSAGE_LEN);
  strncat(ErrorMessage,DAQ_ErrorMessage,DAC_ETHERNET_MESSAGE_LEN);
  strncat(ErrorMessage,"\n",DAC_ETHERNET_MESSAGE_LEN);
  SendRT_ErrorMessage(ErrorMessage);
  // Clear the task
  DAQmxClearTask (taskDACOut);
  return DAC_OUT_STATUS_NOK;
 }
 g_SetDACActual = GetTimeUS();  // get the time to sort out how long this function is taking to finish
 // Clear the task
 DAQmxClearTask (taskDACOut);

 

 return status;
}

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

I would recommend downloading and installing DAQmx 9.9 and then installing DAQmx 9.9 to the PXI controller to see if that changes the output.

 

Let me know if this helps!

Rob B
FlexRIO Product Manager
0 Kudos
Message 2 of 3
(3,880 Views)
Solution
Accepted by topic author DPearce

I found that the SetDACoutput() function was taking 80ms to complete. I fixed it by splitting up this function into three functions

Create and setup the task

Set the DAC

Clear the task

 

I create and setup the task at the beginning of my application. And clear the task at the end of my application. During the test I only cal DAQmxWriteAnalogF64().

This worked out well. Still do not understand why the time changed so dramatically in LabWindows/CVI but the work around is better anyway.

 

 

0 Kudos
Message 3 of 3
(3,874 Views)