From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Pulse train analog ouput generation and analog input measurements

Hello,

 

   My project involves generating pulse trains on an analog output and measuring certain amount of data from one of the analog inputs while the pulse in on the high state.  I'm using a M-series DAQ board and CVI for programming DAQmx 8.x.

 

   My implementaion of the project is attached at the end of this message. 

   Conceptually, it works like this.

 

   1. DAQmxWriteAnalogScalarF64(..) to output voltage (high state)

    2. DAQmxReadAnalogF64(...) to acquire data for some time (determined by rate and number of points)

          this step also deterines the width of voltage pulse on the DAC channel

    3. DAQmxWriteAnalogScalarF64(..) to output voltage (low state)

    4. DAQmxReadAnalogF64(...) to acquire data for some time (determined by rate and number of points)

          this step also deterines the width of voltage pulse on the DAC channel -> disregard data acquired in this step

    5. Repeat step 1-4

 

   At first, it seemed work.  However, I found distortions and missing points in the data when I connected the output signal from DAC0 to ADC0 although I expected to find the ADC input data exactly same as the pulse train on DAC0. 

  What am I doing wrong? Or any suggestion for better way of handling this situation?

 

  Thanks.

 

  My code looks like this.

-------------------------------------------------------------------------------------------------------------------------

  DAQmxErrChk (DAQmxCreateTask("",&taskHandle));  //for ADC input
  DAQmxErrChk (DAQmxCreateTask("",&taskHandleDAC));   //for DAC output
  
  DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL));
  DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandleDAC,"Dev1/ao0","",-10.0, 10.0, DAQmx_Val_Volts,NULL));  

 

  DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,sampsPerChan));
  

  /* memory allocations */

 

  DAQmxErrChk (DAQmxStartTask(taskHandle));           //start ADC input task
  DAQmxErrChk (DAQmxStartTask(taskHandleDAC));   //start DAC output task
  
  for (index = 0; index < index_end; index++) {
        temp = 0;  
  DAQmxErrChk (DAQmxWriteAnalogScalarF64(taskHandleDAC,1,5,xout[index],NULL)); //output voltage high
  DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,sampsPerChan,10.0,DAQmx_Val_GroupByChannel,data,sampsPerChan*numChannels,&numRead,NULL));

//stay at the high voltage while reading data for sampsPerChan determined by rate

/*some manipulations on the acquired data*/ 

 

  DAQmxErrChk (DAQmxWriteAnalogScalarF64(taskHandleDAC,1,5,0.0,NULL)); //output voltage low
  DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,sampPerChan_low,10.0,DAQmx_Val_GroupByChannel,tempdata,sampPerChan_low*numChannels,&numReadtemp,NULL)); 

/* disregard data acquired during the low state of the pulse */ 

  
  }
  

PlotXY(panel,PANEL_GRAPH,&(xout[0]),&(averaged_data[0]),index_end,VAL_DOUBLE,VAL_DOUBLE,VAL_SCATTER,VAL_SMALL_SOLID_SQUARE,VAL_SOLID,1,plotColors[9]);

0 Kudos
Message 1 of 2
(2,559 Views)
**Push
0 Kudos
Message 2 of 2
(2,536 Views)