Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Find the available room in write buffer

I have a PCIe6537, My output is using external clock  and I would like to stuff the write buffer as much as I can.  Using the DAQmxGetWriteSpaceAvail() always returns 0??? Using DAQmxRegisterDoneEvent() is too slow and too late to refill the output-buffer; clock are missed.

 

The following is my code:

 

DAQmxErrChk (DAQmxCreateTask("Out",&taskOut));

DAQmxErrChk (DAQmxCreateDOChan(taskOut,"Dev1/port2_16","",DAQmx_Val_ChanForAllLines));

DAQmxErrChk (DAQmxCfgSampClkTiming(taskOut,"PFI4",1200000,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,255));

DAQmxErrChk (DAQmxWriteDigitalU16(taskOut,BUFFSIZE,0,timeout,DAQmx_Val_GroupByChannel,dataOut,NULL,NULL));

 

DAQmxErrChk (DAQmxStartTask(taskOut));

DAQmxGetWriteSpaceAvail(taskOut,&room);

printf(

"roomm=%d",room);

0 Kudos
Message 1 of 7
(4,159 Views)

Also need a way to refill the output buffer without stopping and restarting the task.

 

0 Kudos
Message 2 of 7
(4,151 Views)

Hi Norman,

 

It looks like you have a finite task configured; are you trying to generate continuously?  Can you an example like ContWriteDigPort_ExtClk ? You can find that program in …National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Digital\Generate Values.

Matt
Applications Engineer
National Instruments
0 Kudos
Message 3 of 7
(4,119 Views)

The reason for using "Finite" because I have a 2GB file, that I have previously recorded, which I would need to playback. I don't believe PXIe-6537 allows me to "write" the entire file to the task.

0 Kudos
Message 4 of 7
(4,117 Views)

Howdy Norman!

 

Even though your file is finite, since it is so large you will need to write it to the PCIe-6537 in chunks by using a loop similar to the continuous acquisition examples.

 

Regards,

Barron
Applications Engineering
National Instruments
0 Kudos
Message 5 of 7
(4,097 Views)

Using the "Cont Read Dig Chan-Ext Clk" example, it reads a chunk of data, wait until it is completed, and read another chunk of data.

 

However, my output is driven by a 12MHz EXTERNAL clock, I will miss some clock pulses if I "write", "wait for done" before "write" again (a dozen of clocks will pass between the done event and my "write" in the callback). Missing a few clock pulses means inserting undesired idle period. To playback the same way as I recorded the samples, I will need to refill the output buffer before the buffer is empty out.

 

So, I need to start-off writing a chunk of data to the buffer, and I need to continuously top up the output buffer again before it is empty.

0 Kudos
Message 6 of 7
(4,087 Views)

Hi Norman,

 

Is your task configured to use regeneration mode?  If so that could be preventing the buffer from freeing up space after samples are generated.  Disabling regeneration should allow you to use the DAQmxGetWriteSpaceAvail function.

 

Regards,

Barron
Applications Engineering
National Instruments
0 Kudos
Message 7 of 7
(4,064 Views)