12-09-2010 04:02 PM
Hi,
I am using a NI-6008 USB module and have a software loop setup where I acquire analog signals, then digital signals, then switch one digital high or low and repeat. I am using the digital to multiplex outside hardware so that I can use 6 of the analog inputs to read 12 signals. The digital inputs I have are connected to buttons on a panel that are used for user input rather than the screen of the computer. My loop also takes care of building a buffer of all the signals on the analog and digital lines I am reading in so I can average and process this elsewhere in the program.
The issue I am running into is that this loop is very slow, and on the final product is run on a touchscreen XP embedded PC and just this acquisition loop takes up as much processor power as the rest of my program. I would say the loops drops to about 4 or 5 cycles per second, which means my multiplex signals update 2 or so times a second. I really would like better performance and not use so much of my processor resources.
I am using a rather basic way to do the acquisition loop, setting the AI settings, reading it, clearing the task, setting the DI settings, reading them, clearing the task and then setting the DO settings, writing to it and clearing the task, giving a slight delay and repeat.
Any thoughts on a better way to run the read/write than what I am doing?
I've attached sample code of the acquisition loop I am using.
Thanks!
Solved! Go to Solution.
12-09-2010 04:32 PM
First and foremost, the best plan is to move the DAQmx Create channel before the loop and use a DAQmx Start, then read/write in the loop, then clear after the loop is done. This configuration only needs to be done once, not every time that you write the channel. This should speed things up considerably.
12-09-2010 05:56 PM
Seth beat me to it, but your DAQ code might look something like this after you make his suggested modifications:
The key is that you should avoid reconfiguring and restarting your tasks on every loop iteration.
Best Regards,
12-10-2010 12:41 PM
Ah, interesting. I did not think you could do tasks in parallel with the NI-6008. I had used a different manufacturers USB device in the past and you could not do that. That works really well, I modified my code and it helped the performace significantly.
Thanks!