06-13-2017 11:42 AM
Arbo,
You might consider looking elsewhere for information on thread locking and file manipulation. I am happy to help you with any problems acquiring data or using National Instruments functions to log it, but I am not a .NET/C# developer. I would recommend posting on MSDN forums or stackoverflow.com.
06-13-2017 12:47 PM
HI
thanks for your helpful notes. i will post related post about threads in stackoverflow com
but do u know something about strange behaivior of NI DAQ
when i'm using continuous mode for generation and acquisition of NI DAQ 6343 i get more precise data.
when i'm using finite mode for something 4000-6000 samples, the precision downgrades, the differences about 0.1 up to 1%
06-14-2017 03:35 PM
Arbo,
That sounds like a great question for the DAQ forums.
08-11-2017 11:03 AM
I don't know if this is related to the wrong result you get but I see a potential problem in your code:
the line
WriteTextAsync(data[i].ToString(), tx, pass_freq);
initiates an asynchronous write but uses data contained in global class variables. At the time the writing is performed it is not guaranteed that these variables will have the right values because in principle the next callback may occur because the write is done.
To correct this you need to pass a copy these variables along with the delegate. In other words, if you define a delegate like in
inputCallback = new AsyncCallback(InputRead);
but you want each instance of inputCallback to access different copies of these variables, you should encapsulate the delegate (here InputRead) in a new class containing the copy of the data needed by the callback and pass the class instance, this is a standard procedure. So you would have something like this:
myCallbackDelegate = new myCallbackClass(data, tx, pass_freq); //initialize with copies of the data needed by the callback
inputCallback = new AsyncCallback(myCallbackDelegate.InputRead);
The new class myCallbackClass to create will contain only copies of the data and the callback function InputRead. Then InputRead callback will be called as a member of the new instance of the class so that it will get access to the copies you created before.
Otherwise you can of course use a simple synchronous "WriteText" and see if it helps.
08-11-2017 11:11 AM
it should rather be
myCallbackDelegate = new myCallbackClass(tx, pass_freq);
and "data" should be only copied after it is read in the InputRead function