LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i deliver a single pulse of varying amplitude using Analog output and USB-6251?

I am trying to generate an analog output for the following waveform:

 

Pulse width: 300 usec, Frequency 40 Hz, Amplitude is following a sine wave with a 2 second period.

My approach is: Use an async timer with 1/[40 Hz] sec  interval. I set the DAQ output rate at 1 MHz and the approach has been to generate and write 300 samples of the amplitude I need to send out, then wait for the next async interval callback , update amplitude etc etc.  The assumption is that once the 300 samples are written and the task started , a 300 usec pulse would be sent out , task then stopped and then the analog output would be set to 0 waiting for he next pulse.  The reality is that I get a stream of pulses of 300 usec which last the whole timer interval. 

So , trying to establish whether what I am trying to do is feasible without actually sending a large array to the USB-6251 which would write zeros for the period after 300 usec.

Here is my timercallback code for review:

 

    switch (event)
    {
        case EVENT_TIMER_TICK:
        {     
  
            DAQmxErrChk(DAQmxStopTask(TaskAnalog));

 



Determine Voltage value algorithm here


            //Generate Waveform and start Task
            

            
            
            
            //Prepare AO arr
            
            for (k=0;k<300;k++)
            {
                AOArr[k] = 0;
                if (k<G_PulseWidth)
                {
                AOArr[k] =  VOLTAGE_OUTPUT;
                }
                
            }
            
            if (AOArr!=NULL)
            {  
                DAQmxErrChk(DAQmxWriteAnalogF64 (TaskAnalog, (int32) 300 , 0, DAQmx_Val_WaitInfinitely, DAQmx_Val_GroupByChannel , AOArr, &sampsPerChanWritten, NULL));
               
            }
            
            DAQmxErrChk(DAQmxStartTask(TaskAnalog));

            break;
            }
        }

 

Thanks

 

 

0 Kudos
Message 1 of 2
(2,626 Views)

I did resovle the issue I encountered. It was due to bad configuration of the Task.

My initial configuration was:

DAQmxErrChk(DAQmxCfgSampClkTiming(TaskAnalog, "",1.0E+06, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps , 300 * 1.0E+06));

 

which should be:

 

DAQmxErrChk(DAQmxCfgSampClkTiming(TaskAnalog, "",1.0E+06, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps , 300));      

 

 

THis did it. works very well.

THanks

 

0 Kudos
Message 2 of 2
(2,623 Views)