02-21-2011 05:16 PM
Good evening
I am looking for a way to generate hardware signals from a proprietary protocol with PCI6224 board and DAQmx driver.
See attached photos.
However, after starting my DAQmx task, I find myself with a delay of 25 mS I can not minimize while my protocol requires a delay of 5 mS between each byte. How to reduce the time delay of 25 mS?
Someone can help me ?
BE CAREFUL : master (my bench) generate CLOCK ( taskHandle_timer ) for order and answer !
The source code:
To generate an order
DAQmxWriteDigitalLines (taskHandle_DO, SAMPLE * TIME * numSamps, 1, TIMEOUT, DAQmx_Val_GroupByChannel, data, NULL, NULL);
DAQmxStartTask (taskHandle_timer);
DAQmxWaitUntilTaskDone (taskHandle_DO, TIMEOUT);
/ / DAQ mx start
DAQmxStopTask (taskHandle_DO);
DAQmxStopTask (taskHandle_timer);
To read a response
DAQmxStartTask (taskHandle_DI)
DAQmxWriteDigitalLines (taskHandle_DO, SAMPLE * TIME * numSamps, 1, TIMEOUT, DAQmx_Val_GroupByChannel, data, NULL, NULL);
DAQmxStartTask (taskHandle_timer);
DAQmxReadDigitalLines (taskHandle_DI, SAMPLE * TIME * numSamps, TIMEOUT, DAQmx_Val_GroupByChannel, data_, SAMPLE TIME * * * numSamps numChannels_i, NULL, NULL, 0);
DAQmxWaitUntilTaskDone (taskHandle_DI, TIMEOUT);
DAQmxStopTask (taskHandle_DI);
DAQmxStopTask (taskHandle_DO);
DAQmxStopTask (taskHandle_timer);
NOTE taskHandle_DI, taskHandle_DO, taskHandle_timer are created in intialisation function (global variable)
Thank you for your help
PS : excuse me for my poor english
02-22-2011 11:10 AM - edited 02-22-2011 11:12 AM
Hi Pierrick MADIOT,
By default, each call to DAQmxStartTask() has to execute the verify, reserve, commit, and start state transitions, but you can perform some of these state transitions earlier by calling DAQmxTaskControl(taskHandle, DAQmx_Val_Commit), so that DAQmxStartTask() will only have to execute the start state transition. I don't know how much time it will buy you, but it should help.
An explanation of the NI-DAQmx task state model is in the NI-DAQmx Help file (on the start menu) under NI-DAQmx Key Concepts >> Channels and Tasks in NI-DAQmx >> Tasks in NI-DAQmx >> Task State Model.
Some other approaches that might help:
Brad
02-26-2011 02:15 PM
Hi Brad
Many thanks for your informations. I tried to experiment with your advice when I have a little time
But you have a typical case (an example) allowing the use of all options of the function to know DAQmxTaskControl ()?
Or you advise me to place functions DAQmxTaskControl () in my code with what option to reduce the execution time?
I ask you a lot 🙂 sorry
Thank a lot
Pierrick MADIOT
02-28-2011 02:03 PM - edited 02-28-2011 02:04 PM
I don't know of a good C example for this, but here's a LabVIEW one that illustrates the basic concept: Acquire & Graph Voltage-Internal Clock-Hardware Trigger Restarts
The overall flow:
The important part is that this performs the reserve and commit operations only once, instead of doing them many times.
For output tasks, you will need to write before starting, but you already know that judging from the code snippet you posted.
Brad