07-04-2014 03:04 PM
Hi,
I am using NI9234 to save some data. I prepared the FPGA and RT vi (based on the examples in labview). Everything is okay but when i use queue to save the data, it doesn't save anything. I attached the vi to this post.
there are some problems that I cannot solve
1. if you run the code, after some time, it just stops for no reason! and I don't recieve any error!
2. the saved file is empty! I think the enqueue block is in the right place and wiring is correct, but there is no data in txt file
3. I am using dequeue block, are you suggesting to use flush queue instead? because too many data is in the queue, and maybe flushing is better than just dequeuing them one by one.
4. I need a save buttom in my code, when I click save, I want the queuing process to start. I tried to use boolean and case structure around enqueue block, but that doesn't solve the problem
any help would be appreciated.
07-04-2014 03:34 PM
Your RT VI has a data dependency between the producer and consumer loops. You have a boolean wire going between them for the stop condition. This means that the consumer loop can't even start until the producer loop is stopped.
I would recommend moving your Enqueue Element into the case structure so that you only enqueue something when you actually have data. Then when the producer loop is complete enqueue an empty array. The consumer loop then does a check for an empty array when it dequeues. If you got an empty array, stop your loop. This also makes sure you saved all of your data. Once the consumer loop is done, you can close your file and release your queue just like you have now.
07-04-2014 04:57 PM
Thanks for the reply! I changed the code and it worked. there is still some issues
consider, I choose data rate as 5.689 Ks/s and sample per channel as 5 KS/ch. one issue is that the elements in the queue starts to grow, and when I stop the code, I have to wait for the queue to save the remaining data one by one.
I think I have to use flush queue, when pressing stop buttom. I tried it but wasn't successfull. could please help me with that too?
also, I have to increase the depth of buffer on host side, the predefined size was 3 times the total block size, and I changed it 10 times because, I was getting buffer overflow error. Is this okay or there is still something worng with code that cause the overflow to occur.
I attached the modified code to the post.
07-04-2014 08:14 PM
I think your main problem is that you are really only getting the data every other cycle. Use the Elements Remaining even when you read data to set the number of samples to grab the next iteration. Also, since you have 4 channels, you should make sure the number of samples you have is divisible by 4. Using Quotient & Remainder and then subtract the remainder works well for that.
In order to save your data faster, you may want to save your data in a binary file instead of a text file. It is less converting and will write the data faster. Of course, you will have to make your own reader to view the data.
07-05-2014 05:42 PM - edited 07-05-2014 05:43 PM
I changed the code based on what you said. also I delete the graph because it seems that it is slowing the code.
I think the problem is that, my consumer code is very slow comparing to producer. in that case, the elements in producer grows and when I stop the vi, I have to wait for the consumer to emtpy the queue. it is taking a lot of time and not practical
but the good news is, I am not missing any data, but the consumer is very slow! I also delete all the indicators in the consumer and change to binary saving, but it did'nt change anything
is there any other method to increase the speed of consumer?
07-07-2014 07:51 AM - edited 07-07-2014 07:52 AM
You are still converting the array to a string. I am recommending removing that and save the raw binary of the array.
So here is what I recommend to spead this thing up some. I changed the queue to hold a 1D array. So you just get the samples and plug then into your queue directly in the producer loop. In the consumer loop, we can save this array straight to a binary file. Make sure the Prepend Array Size is set to FALSE or you will get extra data in your file that you don't want.
But as I said before, you will also need to make a program to read this file later. It will be a simple read the file as a double.