Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Using a NI 6281, is it possible to burst a Digital pattern which involves driving on 5 lines and acquireing on 3 lines? As when I try to specify lines of both input and output for a task an error occurs.

Hi!
   I know for shure that in digital I/O you have to define separate tasks for input  and outputs, so you should  define 2 tasks.  If these tasks need to be synchronized, the problem will be on how to synchronize 2 tasks, and this depends upon the hardware.  The 6281 seems not to be a simulòtaneous-sampling card, so you would  have to use SW synchronization techniques, but I don't  know in depth this card, (and this subject....), sorry!

   Please let me know how you solve!

   Have a nice day!

graziano
0 Kudos
Message 2 of 5
(3,310 Views)
Hi
 
The M-Series of National Instruments MIO data acquisition products includes the capability to synchronize digital input and output with other operations. You can couple buffered digital tasks with the analog, counter/timer, or external clocks. The Digital I/O subsystem does not have its own internal clock source, and therefore, an external signal or clock from another subsystem on the board must be provided - thus correlating the digital data to this signal. With the 6281 you have 24 DIO lines.
 
Essentially if you've tried to do two DIO tasks at the same time i.e. tried to read and write you're likly to get Error -200587 Requested operation could not be performed, because the specified digital lines are either reserved or the device is not present in NI DAQ MX. It is possible that these lines are reserved by another task, the device is being used .... if you are using these lines with another task, wait for the task to complete.... Etc.
 
Is this the error message that you are seeing?
 
Graziano is correct in that you would have to define seperate tasks for input and outputs.
 
Kurt
0 Kudos
Message 3 of 5
(3,292 Views)

Hi Kurt,

I've been in touch with NI on this subject ans they have given this solution below with added comments from me which works great.

Thanks for the advice, Andy.

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

      
//Trail for a simple drive and aqchire pattern.
//________________________________________________
//Create the clkgen task to supply sample clocks for the digital Subsystem of the M series card
DAQmxCreateTask ("", &clkgen);

//Create a clock from the COUNTER ctr0 internal output. Note: the inital delay before pulses is required
//to ensure the ReadDigitalU8 waits for the pulses to start, otherwise some pulse could be missed.
//This delay will vary depending on PC processor speed.
DAQmxCreateCOPulseChanFreq (clkgen, "Dev1/ctr0", "", DAQmx_Val_Hz, DAQmx_Val_Low, 10e-03, 10000, 0.5);

// This configures the counter timing to contin pulses
DAQmxCfgImplicitTiming (clkgen, DAQmx_Val_ContSamps, 1000);

//________________________________________________
//Create the drive DigitalOutput task
DAQmxCreateTask ("", &DOtask);

//Create the Digital Output channel (4 lines)
DAQmxCreateDOChan (DOtask, "Dev1/port0/line0:3", "", DAQmx_Val_ChanForAllLines);

//Congiure the Drive task sample clock to be Ctr0 internal output
DAQmxCfgSampClkTiming (DOtask, "/Dev1/Ctr0InternalOutput", NULL, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 10);

//Write the array values to the Drive channel BUT it will not start because there are No do/Sampleclks yet
DAQmxWriteDigitalU8 (DOtask, 10, 0, 10.0, DAQmx_Val_GroupByChannel, dataout, &written, 0);
DAQmxStartTask (DOtask);

//________________________________________________
//Create the Aqcuire task
DAQmxCreateTask ("", &DItask);

//Create the Digital input channel, 4 lines this time.
DAQmxCreateDIChan (DItask, "Dev1/port0/line4:7", "", DAQmx_Val_ChanForAllLines);

//Configure the Aqcuire task sample clock to be Ctr0 internal output also, BUT on the FALLING edge.
//Note: if you need to move the aqciure strobe time you could alter the "duty Cycle" of the pulses
//coming from the ctr0internalOutput.
DAQmxCfgSampClkTiming (DItask, "/Dev1/Ctr0InternalOutput", 1000, DAQmx_Val_Falling, DAQmx_Val_FiniteSamps, 10);

//MUST start the clkgen task first, but be aware it has an initial delay so the next "ReadDigital" will wait.
DAQmxStartTask (clkgen); 

//Aqcuire the samples into "datain" array. This will not start until ctr0 clks happen after the delay above.
DAQmxReadDigitalU8 (DItask, 10, 10.0, DAQmx_Val_GroupByChannel, datain, 10, &read, 0);

//________________________________________________
//wait for Drive and Aqcuire tasks to finish
DAQmxWaitUntilTaskDone (DOtask, 2);
DAQmxWaitUntilTaskDone (DItask, 2);

//________________________________________________
//Clear all tasks if nessercary
DAQmxClearTask (DOtask);
DAQmxClearTask (DItask);  
DAQmxClearTask (clkgen);

0 Kudos
Message 4 of 5
(3,281 Views)
Hi Andy,
 
I believe it was my colleague Jon that you had called. I wasn't aware you were working with CVI. I'm glad its all working for you. cool!
 
Cheers
Kurt
 
0 Kudos
Message 5 of 5
(3,270 Views)