Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx Multi Chan Dig Out

Hi Guys,
 
I am trying to generate data, clk, and frame synch using a high speed pci express 6537 board
The timing I need to achieve is a frame synch pulse one clock cycle before a word (16bits)
of data is written.  This is to be an event externally triggered.  The only thing I have yet to
figure out is what DAQmx calls to make in order to generate the frame sync pulse before I
spit the data out.  Should the two be independent tasks or is there a way to combine them into
a single task.  I am using the call to DAQmxWriteDigitalLines() to write my data in a serial stream.
 
Here is a section of the code I have so far.  I am trying to write data to the "data" Chan and the frame
sync to the "fs" chan.  I have figured out how to export the clk to PFI4 so thats all set.
 
Any help would be appreciated!
 

DAQmxErrChk (DAQmxCreateTask("DataBlast32",&taskHandle));

/* Instantiate the DO lines */

DAQmxErrChk (DAQmxCreateDOChan(taskHandle,"Dev1/port0/line0","data",DAQmx_Val_ChanPerLine));

DAQmxErrChk (DAQmxCreateDOChan(taskHandle,"Dev1/port0/line1","fs",DAQmx_Val_ChanPerLine));

/*********************************************/

// DAQmx Configure Clock

/*********************************************/

 

//DAQmx_Val_ContSamps

//DAQmx_Val_FiniteSamps

 

DAQmxCfgSampClkTiming(taskHandle,NULL,40e6,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,2000);

/*********************************************/

// DAQmx Configure Output Buffer

/*********************************************/

DAQmxCfgOutputBuffer (taskHandle,1000);

/*********************************************/

// DAQmx Configure Trigger

/*********************************************/

 

DAQmxErrChk( DAQmxCfgDigEdgeStartTrig(taskHandle, "PFI0", DAQmx_Val_Rising));

DAQmxErrChk(DAQmxExportSignal(taskHandle, DAQmx_Val_SampleClock, "PFI4"));

 

/*********************************************/

// DAQmx Write Code

/*********************************************/

//DAQmx_Val_GroupByScanNumber - interleaved

//DAQmx_Val_GroupByChannel - non-interleaved

DAQmxErrChk (DAQmxTaskControl(taskHandle,DAQmx_Val_Task_Commit));

DAQmxErrChk(DAQmxWriteDigitalLines(taskHandle, 16, 1, -1, DAQmx_Val_GroupByChannel,data,&wsample1,NULL));

printf("bytes written sample1 %d\r\n",wsample1);

 

check_done:

DAQmxErrChk(DAQmxIsTaskDone(taskHandle,tdone));

if (*tdone)

printf("Task is done...!\r\n");

else

//wait(10);

goto check_done;

 

 

Error:

if( DAQmxFailed(error) )

DAQmxGetExtendedErrorInfo(errBuff,2048);

if( taskHandle!=0 ) {

/*********************************************/

// DAQmx Stop Code

/*********************************************/

DAQmxStopTask(taskHandle);

DAQmxClearTask(taskHandle);

}

if( DAQmxFailed(error) )

printf("DAQmx Error: %s\n",errBuff);

printf("End of program, press Enter key to quit\n");

getchar();

return 0;

0 Kudos
Message 1 of 2
(3,335 Views)
Hi devnull,

By making a call to
DAQmxWriteDigitalLines() you are writing the same samples to all channels contained in the task.  As a result both "data" and "fs" will generate the same bits.  There's a couple of options that you could try:

1.  Set up 2 tasks, one that contains your "fs" channel and one that contains your "data" channel.  Each task would be configured to trigger off the same digital edge, and as long as you set the sample rate the same for both tasks they will be synchronized (both tasks will use the same timebase to derive their sample clocks).  The data would be such that your "data" channel is in an idle state while the "fs" channel is generating a high bit for the frame synch pulse.
2.  Set up 1 task that generates in a port format.  The data would be defined as unsigned integers written with DAQmxWriteDigitalU8() to port0.

Regards,
Andrew W
National Instruments
0 Kudos
Message 2 of 2
(3,310 Views)