How much faster is an XOP in an input/ouput loop?

Hello,
This is a follow up on an earlier post
http://www.igorexchange.com/node/2748#comment-1
regarding a PID loop to read data, operate on it, and output a change as quickly as possible.

I'm considering delving into the world of XOP writing. My question is, roughly how much faster would an XOP do a read/write loop than a function? I'm getting around 700 Hz just using a Do-while loop in a function. Would an XOP be only a few times faster, or more like orders of magnitude faster? Thanks.
It's hard to say. Real C/C++ code in and XOP tends to run like 10-40 times faster, but it will depend on what's happening inside the XOP. If the computation time is dominated by the data acquisition time, then you won't get that big a speed-up. I will say, though, that loops are one area that tend to get a big speed boost in an XOP. And, at least with NI DAQ devices, the acquisition tends to be quite fast (if you've minded your P's and Q's), so I would guess that an XOP would do it much faster.

I would also say that 700 Hz is pretty good for a user-defined function!

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
How fast do you need to go? If 700 Hz doesn't do it for you, then an XOP may be the way to go. It is often an order of magnitude faster, but it depends what you're doing in the XOP. If it's computation bound you'll speed stuff up. If it's IO bound it may not be much faster. There is also overhead calling the XOP from IGOR as well. We could help more if we have more detail.
I'd like to bump the loop rate up into the 10s of kHz range if possible. The idea is to control the Z piezo of an Atomic Force Microscope using a NI USB-6259 M Series DAQ. All that is needed is a fast PI control loop which does the following during a scanning waveform generation:

1) Read analog error signal
2) Perform standard proportional-integral gain math
3) Ouput a digital word OR analog voltage of the new value

There is a DAC chip in the AFM controller which I can send a digital word to and avoid analog transmission noise issues, but if sending Analog out is faster, then I can go that route with the aid of a buffer. My 700Hz loop I have now is rapidly acquiring the data into an FIFO and each iteration of the Do-while loop pulls out the latest point with FIFO2wave, then does the above operations. It works well, but I need the loop to run much faster to permit faster scan speeds. Hence the XOP thoughts, although my experience with writing such things is lacking so I want to get an idea if my returns on speed will be worth the effort.

For that kind of rate, you're definitely going to need at least an XOP.

I hate to say it, but Labview has PID control modules. Expensive, but if you're an indifferent C/C++ programmer, your time will also be expensive.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Very true, and we have LV, but I really like the all-inclusive nature of having the acquisition in Igor. I may just take the leap and try my hand at writing an XOP to see how it fares for this type of application. If that doesn't boost up the loop rate significantly then LV it is. Thanks.
Just out of curiosity.

How would you interface from the XOP with the NI device?
Doing callbacks to Igor might not be the fastest solution.
thomas_braun wrote:
Just out of curiosity.

How would you interface from the XOP with the NI device?
Doing callbacks to Igor might not be the fastest solution.

The best way would be to run a thread with the PID loop, using NI-DAQmx C/C++ calls to implement it. Of course, threading is an advanced technique...

That would leave Igor's main thread available to execute controlling functions.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com