Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Data acquisition slower for similar program in C# compared to LabView

Hi

I am trying to do the same program using Visual Studio C# which has already been done in LabView platform but the data acquisition time was very slow compared to the LabView platform. For the same no. of samples, LabView is taking around 57 secs while the Visual studio is taking around 5-7 mins. Is it due to the fact that the digitizer works well with LabView platform or is it due to some problem in the programming? Please help me. I've posted the code for C# and also posted the LabView program. 

0 Kudos
Message 1 of 6
(5,695 Views)

Hi Paritosh,

 

A comparison of the different Application Development Environments (ADE) can be found here. Being that you have a working application in LabVIEW, why are you trying to rewrite the code in C#?

 

Your digitizer is designed to acquire data at the specified rate and it stores that data in its onboard memory. The data is then transferred from your device whenever the Fetch command is called.

I did notice that you are writing the acquired data to a file. In LabVIEW you are using parallel loops to ensure that the Fetch loop rate is not slowed down by the Write to Spreadsheet File by using parallel loops. In other words, you are making use of LabVIEW's multi-threading capability to speed up the operation.  Are you using parallel loops in C#?

Tunde S.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(5,670 Views)

We wanted to upgrade the program making the acquisition and processing faster, so we opted for visual studio but it seems that it was a bad idea. I am using the multi-threading in C# as well to save the data in parallel loops and i made use of maximum thread possible but still the results were not what I expected. 

 

As I can see in the link you posted, integration capability of visual studio is lower compared to LabView. Can it be the reason? Please help..

0 Kudos
Message 3 of 6
(5,667 Views)

The ADE layer defines the procedure for your application. Through the ADE you make driver calls to communicate with your device. In other words, both LabVIEW and Visual Studios call the same DLL to communicate with your device. How you interface or integrate the driver may look different between different languages, but the process is the same. You make driver calls to create, configure, read/write, and close your task.

 

From your original post, it sounds like both LabVIEW and C# are both accomplishing the same task right now. However, you are trying to define your code for better timing statistics. You mentioned that your current LabVIEW code takes 57 seconds, but is there an elapsed time goal that you are unable to reach that caused you to move to another language? My advice is to find which process in your code takes the longest time and focus on that task. For example, if writing to a file is taking too long, you might want to look at the Write To File Speed Test.vi in the LabVIEW Example Finder.

 

I believe you installed the NI-SCOPE .NET Driver Support through the link here because your code structure is similar to the Configured Acquisition example? How was your acquisition when you used this example without any modifications?

Tunde S.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 6
(5,657 Views)

Right now labview platform is taking a lot of memory and we are forced to use 2 pcs, one for data acquisition and another for laser scanning. So we wanted to use Visual studio platform for data acquisition so that we can use only 1 pc for our system. But the data acquisition using visual studio is slower than our requirement.

 

I installed NI-SCOPE .net class library 1.1.1 and used the configured acquisition file as a reference. In fact the code I've sent is a modification of the configured Acquisition.cs itself. The data acquisiton part is same, i just changed the part of the program to process the data acquired. And I also removed the data table that was used in the program to speed up the process because arranging the data in the table for display was taking a long time. So we can say that acquisition from the example program without any modification was taking even longer due to the fact that it was arranging the data in table for display. 

 

I even used multi-record.cs and made a simple modification of saving the incoming data in a hard disk but still the acquisition was slower. 

0 Kudos
Message 5 of 6
(5,638 Views)

From your last post, it looks like the write process is taking too much time. Have you considered writing to a binary file? Please let me know if you'd like clarification on the information presented in the Developer Zone. 

Tunde S.
Applications Engineer
National Instruments
0 Kudos
Message 6 of 6
(5,630 Views)