Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to output/input large buffers with PCI 6534 using Visual C++ -> 5sec delay occured

I'm controlling the high speed scanning mirror device with PCI 6534 card.
For continous output of data that composed of lager amount of buffers , I used DOsingleBufExtTrig653x.C.
For setting number of channel and transfer time, I set the first three configuration buffers like this.
//configuration buffer
ibuffer[0] = 0x0002;//configuration buffer informing buffer
ibuffer[1] = 0x003E;//3 channels for output and 3 channels for input
ibuffer[2] = 0x0000//interval multiplier(0 means 24 us)
Then, real position data(x,y,z) is filled with sine curve in the same buffer.
ibuffer[3] =
ibuffer[4] =
..............................................................................................................
And continously output the buffer like below.
while(((Ibuffer*)pParam)->stop_flag == false)
    {  
      
        iStatus = Align_DMA_Buffer(iDevice, iResource, ibuffer,
            ulCount, ulBufferSize, &ulAlignIndex);
        iRetVal = NIDAQErrorHandler(iStatus, "Align_DMA_Buffer",
            iIgnoreWarning);
        iStatus = DIG_Block_Out(iDevice, iGroup, ibuffer, ulCount);
        iRetVal = NIDAQErrorHandler(iStatus, "DIG_Block_Out",
            iIgnoreWarning);
        printf(" Apply the digital trigger to the 'start trigger' pin to start the operation.\n");
        ulRemaining = 1;
        while ((ulRemaining != 0) && (iStatus == 0)) {
            iStatus = DIG_Block_Check(iDevice, iGroup, &ulRemaining);
            iRetVal = NIDAQYield(iYieldON);              
        }
        iRetVal = NIDAQErrorHandler(iStatus, "DIG_Block_Check",
            iIgnoreWarning);          
    }
When I run this program, there is significant delay (5 sec) beween two consecutive blockout operation.
How can I solve this problem?
I attached my program.
0 Kudos
Message 1 of 5
(3,600 Views)
Hello sunuk,

First of all, welcome to the National Instruments forums!  I would like to first point out that the driver you are using is our Traditional (Legacy) driver, which is no longer being upgraded and is much more complex to use than our newer driver DAQmx.  We strongly suggest using our new driver (which is free) for developing new code so that the code can be upgraded with new versions of the driver as it comes out.  The Traditional DAQ driver will not be supported on new operating systems, and our new hardware cannot be used with the old driver.  The new driver also has much more documentation and example programs written for it, to the point that a majority of applications require little or no modification of an example. 

In your case, there is an example called ContGenVoltageWfm_ExtClkDigStart which does what you are looking for.  The only modification you would have to make is to specify an internal clock.

That being said, I have some recommendations for your current code that may help with the delay you are seeing.  The while loop you added contains code that writes to the buffer and then waits until the buffer is emptied.  The wait is done with the nested while loop and the DIG_Block_Check function.  What this means is that your loop will not iterate until the data has completed being output.  So it will take at least that amount of time to loop.

I would recommend you take a look at the DOdoubleBufHandshake653x example.  This uses a double buffered setup (automatically taken care of in our new driver) to do a continuous output.  You can then add the triggering as done in the example you were looking at.

I hope this gives you a place to get started, please post back if you have any questions or comments.
Neal M.
Applications Engineering       National Instruments        www.ni.com/support
Message 2 of 5
(3,584 Views)

Hello

I tried to test ContGenVoltageWfm_ExtClkDigStart example with PCI-6534 card.

But there is an error message that denotes unsupported channel. The error message is as follows

DAQmx Error: Measurements: Physical channel specified does not exist on this dev
ice. Refer to the documentation for channels available on this device.
Device: Dev1
Physical Channel Name: ao0
Task Name: _unnamedTask<0>
Status Code: -200170
End of program, press any key to quit
 
My card does not support analog input/output?
 
And using Cont Write Dig Port-Ext Clk example, I also tried to test.
But DAQmxWriteDigitalU32 function only support unsigned data type such as uInt32.
How can I send sign curve which has the value ranging from +524287 to -524287(signed 20bit)?
And should i fill the data buffer with binary expression instead of integer? 
How about using DAQmxWriteRaw function to send signed int16 data buffer?
0 Kudos
Message 3 of 5
(3,550 Views)

Hello

I tried to test ContGenVoltageWfm_ExtClkDigStart example with PCI-6534 card.

But there is an error message that denotes unsupported channel. The error message is as follows

DAQmx Error: Measurements: Physical channel specified does not exist on this dev
ice. Refer to the documentation for channels available on this device.
Device: Dev1
Physical Channel Name: ao0
Task Name: _unnamedTask<0>
Status Code: -200170
End of program, press any key to quit
 
My card does not support analog input/output?
 
And using Cont Write Dig Port-Ext Clk example, I also tried to test.
But DAQmxWriteDigitalU32 function only support unsigned data type such as uInt32.
How can I send sign curve which has the value ranging from +524287 to -524287(signed 20bit)?
And should i fill the data buffer with binary expression instead of integer? 
How about using DAQmxWriteRaw function to send signed int16 data buffer?
0 Kudos
Message 4 of 5
(3,550 Views)
Hello again sunuk,

I am not sure why, but I was thinking you were trying to output an analog sine wave (which would not make sense since your card is digital only).  However, you found the digital example I should have pointed you too.  

I am still not clear on what signal you are trying to output.  You say you are trying to output a sine wave, do you mean digital values that are equivalent to a sine wave on your scanning mirror device?  Are you trying to do this with a signed 16 bit data type?  If you have 20 bits of data, I would think you would want to use a 32 bit word...

If you are trying to output signed 16 bit values (like you suggest using the DAQmxWriteRaw), then the best way to do that is with the DAQmxWriteU16 function.  This function should read the int16 as a uInt16. This should not change the actual bits in any way, it is just the way the program reads them.  What this means is that the actual bits are in twos compliment format.  I tried this (modifying the same example you did) on a simulated device, and it did not throw any errors.  However, since it was simulated, I could not scope the output.

I hope this clears things up, please post back if you have any more questions.

Neal M.
Applications Engineering       National Instruments        www.ni.com/support
0 Kudos
Message 5 of 5
(3,532 Views)