When using the variant data type, speed is an inherent cost. In order to accommodate different types of data into the variant data type, many operations are required in the conversion, which makes the process pretty slow compared to 2MHz. Furthermore, making calls to COM code slows down the code even more because the of the command switching and matching that must occur. Unfortunately, both bottlenecks are unavoidable.
So you're actually getting a double whammy in the speed department with your code as described. To speed up the process, I would recommend looking at ways to bypass the bottlenecks. Is the 2MHz speed absolutely necessary? Is there a specific reason why you're making COM commands? If you are simply doing data storage, you could just stream to d
isk using a binary file in LabVIEW without making COM calls. If it is data analysis you are wanting to do in COM, I would recommend waiting until the data acquisition is complete and the data is saved to disk.
Most important: Strictly typed data types are an order of magnitude quicker than weakly typed ones. I would recommend looking at moving towards that area.
Eric Sulzer
Applications Engineer
National Instruments
http://www.ni.com/ask
E. Sulzer
Applications Engineer
National Instruments