08-23-2011 01:57 PM
Only a month and a half later and I have finally been able to get back to this problem. I very much appreciate both of your help and comments. I ended up using the producer consumer methodology as you showed in the example you provided Bob. I just had to modify it to work with a cluster of 60 different elements but it worked great and I am much happier with my data.
11-15-2011 04:19 AM - edited 11-15-2011 04:19 AM
Hello!
I have a similiar task, in which I am to recreate a data acquisition programm which originally used the DAQ assistant to work with cRIO in real-time. The goal is to collect eg. 1000 data points and send these as a package to the Host-VI. The data is to be collected on the Host-VI until a "stop-acquisition" button is pressed, then all collected data displayed on a graph and saved onto a spreadsheet file. So far I seem to have a working VI for the Target system, however I am having problems transferring the data losslessly onto the Host-PC. It seems to me that only half the data is being received by the Host-VI and also different amounts each time.
I am using Shared Variables to acquire the data - single process variables with RT FIFO for the communication between the deterministic and non-deterministic loops, and a network shared variable to send the data to the Host-VI.
I have attached the target VI [LabVIEW 2010]. I would very much appreciate help in setting up a proper communication between target and host. Does anyone have any suggestions for me?
Greeetings,
Dawn
11-16-2011 04:26 PM - edited 11-16-2011 04:26 PM
Hi Dawn,
Are you using a buffered shared variable to transfer the data to your host computer? If not, this could be causing your loss of data, because if new data is written before the old data is read by your host, the old data would be overwritten.
If that doesn't fix your issue could you please attach a zip file of your project? Having just the VI doesn't give much information because I don't have the files which contain the shared variable data, or target data.
Regards,
Matt M.
11-16-2011 05:46 PM - edited 11-16-2011 05:49 PM
Hi Matt,
I have an extremely similar problem as Dawn. The sampling frequency cannot reach the desired level (100Hz). The maximum achievable sampling rate is 50Hz and anything above that would result in inconsistency. Can you please have a quick look at my code and give my some suggestions on solving the problem?
The model of the hardware I am using are NI cRIO 9024 controller and NI 9205 module. Thanks in advance!!
Vincent
11-17-2011 02:46 AM
Hi Matt,
For some reason I cannot recreate the problem I had when I posted this. Instead I have a whole load of other problems. I also have two different implementations now. The first one uses buffered network shared variables to transfer the information from the target to the host. The buffer size may need adjusting, I still haven't fully understood the concept. What I need the VI to do, is to gather the data in a spreadsheet file with the milliseconds past next to each value.
The other solution uses Network Streams to transfer the data from the shared variable on the target to the host VI. This was suggested by NI Support. My problem here is an error message that pops up when I stop the VIs, stating that there is not enough memory to complete the operation.
Which of these two methods is the recommended one or better for my purpose? Eventually this programm will be running non-stop testing equiptment.
Kind regards,
Dawn
11-17-2011 09:43 AM
Vincent,
Loop rate is determined by your hardware, and the code inside your loop. I took a quick look at your code, and I see that you are using the Elapsed Time Express VI. This is not recommended because Express VIs are extremely complex and take a very long time to run compared to normal real-time code that you want executing as fast as possible. You should be able to do just the acquisition at a loop rate of 100Hz. So you could try just taking out the elapsed time, and running your code to see if that allows you to set your dt to 10ms.
Instead of using elapsed time, you can use the Actual Start [i] value from the Right Data Node in your timed loop. To get the Right Data Node right click on the timed loop and select "Show Right Data Node". You can then left click on the node and select Current Iteration Timing --> Actual Start [i]. If you multiply that number by the period of your loop clock source you will get the elapsed time since the loop started. If you use the Mhz clock you can get nanosecond resolution, if you want. I have attached a screenshot of the structure.
If that elapsed time VI is there for benchmarking purposes, I recommend you take a look at the LabVIEW example for benchmarking real-time code. You can find it in Help --> Find Examples, and search for "benchmark". I hope that helps!
Regards,
Matt M.
11-17-2011 09:51 AM
Dawn,
Network streams are the most efficient option for sending data between the target and host.
The memory issue has to do with the hardware you are running your code on. Either you are writing values to the cRIO (this is not recommended), or you are taking up too much memory on the host, but that would be very hard to do with just shared variables. I would recommend creating a new discussion for this topic so more people can see the exact issue you are having, since this thread is about data acquisition, and your issue is now about running out of memory.
Regards,
Matt M.
11-20-2011 06:31 PM
Hi Matt,
I have implemented some changes in my program because now we need to measure an additional signal (temperature) simultaneously but at a lower sampling rate (1/min). I have added another timed loop with lower priority (in cRIO.vi) and introduced extra network variables to transfer data between the VIs. I have basically repeated the same steps for my previous measurement. However I am encountering some strange problems.
1) The elapsed time is not updating its value properly, it is slower than the actual time. (Elapsed time is important for data analysis purpose)
2) I need to write the two different measurements into two different files, so I have added another write2measurement express VI. While the original one works fine (except for the elapsed time problem), the second express VI (writing temperature values at 1/min) is not writing a n rows by 21 columns matrix like the first express VI.
I have attached the newer version of my program. Thanks a lot!!
P.S. I understood the recommendation of using network streams but unfortunately I have only access to labview 2009 at the moment.
11-20-2011 06:58 PM
Sorry there is another problem: it was intended that when the stop button is pressed (in Computer.vi), it would stop both VIs, it worked previously, however it doesnt stop cRIO.vi anymore after the changes were implemented. Can you please look into that issue as well? Thanks!!
11-21-2011 01:43 AM
Hi Matt!
Thanks for your help! I have managed to solve most of my problems now 🙂
Hi Vincent!
I had the same problem as you, after changing my programms a couple times, the VI running on the cRIO would no longer respond to the Shared Variable. By using a Local Variable I solved this problem. However I am not sure if this is the best solution.
Kind regards,
Dawn