Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

non-blocking precisely timed digital output

Hello,

 

I'm fairly new to DAQ coding so please bear with me. 

 

I have a PCI-6221 that I'm using to send 16 bit signals to one device, read multiple analog signals from another device, and send a 1 bit signal to a third device. These 3 operations are controlled by a matlab program that runs at ~1khz. At certain points during operation I need the first two operations, the 16 bit signal and the analog read, to continue while the third signal is sent with as high a temporal accuracy as can be achieved, much better than the 1khz the matlab program runs by default. The third signal is sent in trains of ~100-200ms with between 40 and 120 pulses with arbitrary timing.

 

My question is: is there a way to offload the responsibility for sending this third signal completely to the DAQ card and have it run autonomously while that is being generated? As in, can I turn the digital write into a non-blocking 

operation? I had thought to create a buffered digital output task and give it a vector containing the entire signal train in discrete time chunks, relying on the card's internal timer to send each consecutive element in the vector on time, but so far I've been unsuccessful with this approach. This may be due to my programming, but if anyone can tell me if this is even possible before I continue banging my head against it, I would appreciate it. If anyone has a better approach, that would also be appreciated, as the vector containing the entire 200ms signal at 1mhz can get fairly large (200,000 elements).

 

To put it in schematic form, I need the following:

 

Matlab program calls DAQ mex file with 200ms digital output task

DAQ card buffers/internalizes this output task somehow

control is returned to matlab

at time point x DAQ card sets port high with no matlab oversight

at time point y DAQ card sets port low with no matlab oversight

contd for duration of signal train...

at the end of the signal the DAQ card frees the resource for matlab to use on the next signal train iteration

 

Thanks!

 

0 Kudos
Message 1 of 2
(4,526 Views)
If I understand correctly, you want to code a digital output task for your application. The main idea behind the program would be to start with a DAQmxCreateDOChan function, then set your timing using the DAQmxCfgSampClkTiming function. 
 
Once this is all set up, I would create the array of values you want to write before outputting them to the channel (keep in mind the Digital Output FIFO can handle up to 2047 samples at a time, see page 6 on the specification document http://www.ni.com/pdf/manuals/371290g.pdf). 
 
Once you have the array you can use a DAQmxWriteDigital to write the array to the FIFO and then go ahead and call DAQmx Start to transition the task to the running state.
 
Once DAQmx Start is called, the FIFO will empty itself in hardware (no SW calls involved) at the sample rate set previously by DAQmxCfgSampClkTiming. 
 
Hope this helps!
0 Kudos
Message 2 of 2
(4,499 Views)