01-04-2012 07:33 PM
Hello everyone,
I have written a labVIEW program using 9.0 (attached below) which acquires data from 4 sensors. I need to continuously acquire data and then upon a user input, sample only 5000 samples and perform an analysis on the data. The problem I am running into is that I can take a measurement fine the first time (take the 5000 samples), but if I want to take another data point I get this error:
Error -200429 occurred at DAQmx Read (Analog 1D Wfm NChan NSamp).vi:5
Possible reason(s):
Measurements: Value passed to the Task/Channels In control is an empty string (or I/O control).
The value must refer to a valid task or valid channels.
I am not sure if it is a matter of how I am clearing the tasks or not?
As a matter on the side, I do not know what I changed in my code, but when I select the "Take Measurement" button to initiate taking the 5000 samples and run the analysis on the data, the "Instrument Readings" Table does not display the raw, scaled and averaged data from the instruments from which the analysis was performed using those values.
Suggestions and direction would be greatly appreciated!
-Ellen
01-05-2012 09:20 AM
Let me understand correctly, you want to measure 5000 samples on 4 channels but only when there is a user input (software trigger).
Why don't you use triggered acquisition for that? Are you interested saving the samples before the trigger appears?
Ion R.
01-05-2012 09:57 AM
I would reccomend that you look into a producer consumer. Then I would go to continuous buffered data acquisition and make it do what I need. So you are actually sampling all of the time but you post process the data to save what you need. It is a little more complicated at first but will make your life easier down the road.
If you choose not to do it that way then you need to look at a state machine system and start and stop the read. So you would take everything that is outside of you while loop and move it into an initilization or star step and add a stop step where you clear the task so you can reastart it,
01-05-2012 10:27 AM
ion R
I am not interested in saving the samples taken before the trigger to read 5000 samples and process them. For this experiment we need to keep a constant eye on what the pressure and temperature readings are like so on the front panel we would use indicators or a chart to watch what the pressure and temperature readings are at all times during the test. There is no need to save this data. Hopefully that clears up a little what I am attempting to do?
Thanks,
Ellen
01-05-2012 11:11 AM
Tim,
I have previously considered trying that method before. Except I am worried about going through all of the work to change my code to do that and then not have it do what I want it to do. I am under the impression that as soon as you switch from the initialize state where data is read continuously to another state that the initialize state no longer performs its functions.
I need my program to continuously acquire and read the samples to display to the front panel concurrently with taking the 5000 samples when there is a user that triggers it to do so.
-Ellen
01-05-2012 11:33 AM
Ellen,
Before you try to change to a more versatile and robust architecture (I agree with Tim's recommendation), make a backup copy with a new name. Then start the changes from one of the copies. This has the obvious benefit of not modifying you only copy. It also allows you to compare both programs to be sure they produce the same results or to copy working pieces from the original to paste into the revised version.
I have not studied the entire thread in detail but it seems that you could acquire continuously and either save all the data to a file or keep a buffer of the last 10000 or 20000 samples and then extract the subset you want when the user input requires it. This approach is much simpler on the data acquistion side and is completely compatible with a producer/consumer architecture.
Lynn
01-05-2012 11:50 AM
Hello Lynn,
It's not the acquiring continuously I am worried about right now, it is being able to read continuously. I am having issues with my code to continuously update the coefficient of lift, velocity, and Reynolds Number outputs to the VI (which do not need to be saved) on the front panel. The only reason for doing this is to be able to figure out during testing if we need to speed up or slow down the velocity in the wind tunnel to obtain the correct coefficient of lift before we begin taking the 5000 samples.
-Ellen
Plus, I need to be able to have a working code by Monday, so for right now I'm just hoping to force what I have to work because I am sure I would require possibly more help in converting what I have now to the producer/consumer architecture as well as I do not fully understand the concept of the queue. I do, however, plan on rewriting the code after testing next week. (I was recently told we would be making a trip to use a wind tunnel without having a fully working program so I'm racing to finish it! )
01-05-2012 12:10 PM
Ellen,
If nothing is selected from the Menu cluster, it looks like your loop should just keep grabbing blocks of 1000 samples. With the sample rate set to 25600 you should theoretically get a new reading every 4 ms. Of course your display and the user's eyes cannot keep up with that. You also have 1000 data points but only display the calculations on one of them. Despite these issues I do not see anything in your program which would prevent it from updating the indicators often enough to let you adjust the wind tunnel.
Did you read my response about clearing the tasks in your duplicate thread?
What do you see happenning which makes you think it is not updating often enough?
Lynn
01-05-2012 12:28 PM
Lynn,
Yes, I did see your response in the duplicate thread. I have since removed the clearing tasks and that solved my problem, so a late thank you for the help!
I do not believe it is constantly updating because when I apply a pressure to the tubing connected to my instruments the front panel does not show any change in the velocity or reynolds number... which there definitely should be.
Also, I am having trouble understanding what you are referring to when you say I have 1000 data points but only display the calculations on one of them.
-Ellen
Also, I have made some changes to the code.. so here's my most recent version
01-05-2012 01:32 PM
Ellen,
The 1000 data point issue is explained by the comments on the image. Analog Read gets 1000 samples. This is converted to the Dynamic datatype (who knows what happens in there?). The Dynamic data is connected to scalar indicators which cna only display one value at a time. What happens to the other 999?
Wire indicators to the "i" terminal in the loop and to the wire going into the case selector terminal (the "?" box on the left side of the case structure). These will tell you whether the loop is still running and which case is executing. An indicator on the error out wire from the analog read might help also.
Lynn