01-17-2007 04:58 PM
01-18-2007 02:40 PM
Hi Oleg,
Because CompactDAQ is on USB, you will have system dependent behavior when trying to run control loops. That said, I think you should probably be able to achieve better than 80ms loop rates.
What kind of computer are your running on? Is it relatively fast with a USB 2.0 connection?
There may also be some inefficiencies in your code. Perhaps you could post it and somone may see some places for improvements.
Thanks,
Sal
01-18-2007 04:17 PM
01-18-2007 04:30 PM
Hi Oleg,
I'm glad to hear that you were able to reduce your loop time. I'm not sure if this applies, but I wanted to let you know that if you are not changing any of your task's configurations between loop iterations, then you do not need to call any of the task configuration functions in the loop. You should only have to call the start and stop task functions in the loop. Calling the configure sample clock function will increase your loop time.
Your NI-CompactDAQ chassis allows for only one analog input task to be running at a time. So if you have one chassis with four modules in it, you will have only one AI task and a reader that will get the data acquired by all of the modules. You can have multiple modules in the task (if all of the modules aren't the same) by calling AIChannels.CreateVoltageChannel multiple times (once for each module).
If you are going to have many of the same module with the same input ranges in the same task, you can call AIChannels.CreateVoltageChannel only once and list all of the modules in it like this:
meas_channels_task(0).AIChannels.CreateVoltageChannel("cDAQ1Mod8/ai0:15, cDAQ1Mod7/ai0:15, cDAQ1Mod6/ai0:15, cDAQ1Mod5/ai0:15", "", AITerminalConfiguration.Rse, -10.0, 10.0, AIVoltageUnits.Volts)
If you have more than one cDAQ chassis, then you will need to have multiple tasks and multiple readers.
Thanks,
Sal
01-18-2007 05:03 PM
Hi Sal,
thank you for the approach which is new for me.
It looks like good solution, but I am not sure about the structure of output data. For example, if I read channels from 1 module, I get 2D data array - DATA(channels,samples). What is the structure of data array of multi modules task
meas_channels_task(0).AIChannels.Create VoltageChannel("cDAC1Mod8/ai0:15,cDAC1Mod7/ai0:15,cDAC1Mod6/ai0:15,cDAC1Mod5/ai0:15","", ....)?
Thanks,
Oleg.
01-19-2007 09:32 AM
01-22-2007 03:33 PM
Hi Sal,
As I told, I can build control loop with start/stop commands inside the loop:
meas_channels_task0.Start()
meas_channels_task0.Stop()
In this case I get correct data but loop time increases by approximately 100-130ms.
When I move these commands out of loop and use
a_r = read_task(i).BeginReadMultiSample(num_of_samples, Nothing, Nothing)
read_task(i).EndReadMultiSample(a_r)
inside, loop time decreases down to ~20ms. The problem is that I cannot get current data from the device. Instead of this I get the first measurement result obtained at the beginning.
Would you please advise me how resolve the problem?
Thanks,
01-22-2007 03:48 PM
Are you running a finite or continuous task? If you are running a finite task.. once you read all of the data that you set in "number of samples" your device stops acquiring data. (you won't get any new data). To get new data from the finite task, you need to stop it then start it.
A better way to do this would be to use a continuous task...
Take a look at how this is done in the shipping example:
C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\DAQmx\Analog In\Measure Voltage\ContAcqVoltageSamples_IntClk
01-22-2007 04:36 PM
Hi Sal,
You are right. I used finite task with stop/start inside loop.
When I use continuous task, I get error message (see attached).
In my case AI reading must be done ~10ms after applying pulse in each loop cycle. How can I synchronize these 2 processes?
Thanks,
Oleg.
01-22-2007 04:45 PM
Hi,
You are going to have to balance how many samples you get with each read call, how fast you are sampling and how often you are calling the read function. This will be very specific to your application so there isn't much guidance that I can offer.
Your original description of the problem is not quite a continuous acquisition. It seems like you are only interested in the data collected 15 ms after the pulse finishes. If you do continous acquisition, you will be acquiring all of the time.
It sounds like you may want to do some sort of retriggerable analog input acquisition. This can be pretty complicated to implement but it may give you the best results.
For more info on this, see this link: http://zone.ni.com/devzone/cda/tut/p/id/5382