02-27-2006 08:10 AM
02-27-2006 09:07 AM
02-28-2006 09:12 AM
03-02-2006 06:41 AM
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);
03-02-2006 07:17 AM