Quantcast
Channel: Multifunction DAQ topics
Viewing all articles
Browse latest Browse all 7020

Smoothly change analog output on a PXI device via C

$
0
0

Hello,

 

I'm trying to use the analog outputs on a PXI-4461 to drive a fast steering mirror.  I need to set each AO channel to some DC values, wait a short period of time for the mirror to settle, and then measure something.  I can use the AO channels to output the values using this code:

 

void PxiMirrorAxes::set_dc(double valX, double valY)
{
    int i;
    for (i=0;i<buffer_size/2;i++) // Write a bunch of the same value to a small buffer
    {
        buffer[i]=valX;
        buffer[i+buffer_size/2]=valY;
    }
    if (taskHandle) {  // If a task is currently running stop it
        DAQmxStopTask(taskHandle);
        DAQmxClearTask(taskHandle);
        taskHandle = 0;
    }
    int err;
    err= DAQmxCreateTask("",&taskHandle);
    err = DAQmxCreateAOVoltageChan (taskHandle, chan_char_x, "", -10.0, 10.0, DAQmx_Val_Volts , NULL);
    err = DAQmxCreateAOVoltageChan (taskHandle, chan_char_y, "", -10.0, 10.0, DAQmx_Val_Volts , NULL);
    err = DAQmxCfgSampClkTiming(taskHandle,"",sampling_rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,buffer_size/2);

    int32 written;
    err = DAQmxWriteAnalogF64(taskHandle,buffer_size/2,0,10.0,DAQmx_Val_GroupByChannel,buffer,&written,NULL);
    err = DAQmxStartTask(taskHandle); // Task is left running
}

 This works fine to go to a specific pair of values and stay there -- however I can't call this in a loop to scan the mirror because every time I call it, the value of the outputs briefly drops to zero, presumably when I call the DAQmxStopTask.  How do I change the output values of the two channels without them going to zero at all?  (Note that when I use code like the above with a normal PCI-based DAQ where I don't have to write a buffer, it never goes to zero between calls).  Thanks,

 

Alex


Viewing all articles
Browse latest Browse all 7020

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>