LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog and digital output generation after an event trigger

Dear Madam/Sir,

using a 6343 board and CVI, I need to output a digital and an analog waveform at the same time, starting their generation by an external trigger.

Using DAQmxCfgSampClkTiming() with the parameter DAQmx_Val_ContSamps, it starts the output at the first trigger event and then goes on cycling the buffer. With the parameter DAQmx_Val_FiniteSamps it produces the buffer once, starting at the trigger event.

What I need is the output of the (finite length) buffer at each trigger event, with no output between each event and the other.

What is the most appropriate approach for this task, taking into account that buffer output and trigger should be synchronized at the 100 microsec level?

Thanks in advance

Luca

 

0 Kudos
Message 1 of 3
(2,507 Views)

Problem solved. With DAQmx_Val_FiniteSamps, I raise an event in Windows with DAQmxRegisterSignalEvent and put Stop/Start task commands in the callback function. Then the system is ready for output when detects another trigger.

 

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

Dear Madam/Sir,

  I raise again this post to ask for detail which potentially bothers my experiment. Here below is the code to initialize the USB6343 board:

 

/********CVI CODE**********/ 

DAQmxErrChk (DAQmxCreateTask("",&DigitalWaveformsTaskHandle));
DAQmxErrChk (DAQmxCreateDOChan(DigitalWaveformsTaskHandle,DigitalWaveformChannels,"",DAQmx_Val_ChanForAllLines));
DAQmxErrChk (DAQmxCfgOutputBuffer(DigitalWaveformsTaskHandle,buffersize));
DAQmxErrChk (DAQmxCfgSampClkTiming(DigitalWaveformsTaskHandle,DigitalWaveformsClockSource,DigitalWaveformsSampleRate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,buffersize));
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig (DigitalWaveformsTaskHandle,USB6343"/PFI1", DAQmx_Val_Rising));
DAQmxErrChk (DAQmxWriteDigitalU32(DigitalWaveformsTaskHandle,buffersize,0,10.0,DAQmx_Val_GroupByScanNumber,databuffer,NULL,NULL));
DAQmxErrChk (DAQmxRegisterDoneEvent(DigitalWaveformsTaskHandle,0,DoneCallbackDigWFM,NULL));

/********END CVI CODE**********/ 

 

At the end of the Digital output generation the event is raised and the following callback is executed:

 

/********CVI CODE**********/ 

int32 CVICALLBACK DoneCallbackDigWFM(TaskHandle DigitalWaveformsTaskHandle, int32 status, void *callbackData)
{
int32 error=0;
char errBuff[2048]={'\0'};

DAQmxErrChk (DAQmxStopTask(DigitalWaveformsTaskHandle));
DAQmxErrChk (DAQmxStartTask(DigitalWaveformsTaskHandle));

Error:
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( DAQmxFailed(error) )
MessagePopup("DAQmx Error",errBuff);
}

/********END CVI CODE**********/ 

 

The execution of the callback requires some time and it works only if the period of the trigger signal provided to PFI1 is at least 30-40 ms larger than (buffersize/DigitalWaveformsSampleRate). If this delay is too short, the DO task starts on a trigger event over two, at the place of starting at each one. This delay is probably related to the complexity of the software which contains the routines above and which drives many other instruments and allows interaction with peripherals. I would like to reduce this delay to few ms. 

Is there a way to handle the DO output start synchronized with an external trig in a different way? Maybe without using the callback (directly handled by the board) or giving priority to the callback in the software (LabWindows/CVI)?

 

Thanks for the help

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