04-04-2016 11:13 AM
One option that I have done before was write a FIFO buffer as an action engine. I stored about 1/2 hour of data in the buffer always, with "Add Data", "Read New Data", and "Read Historic Data" commands. I could then have my data save loop run at a very slow rate with automatic bunching, with the added option of recovering / saving 1/2 hour worth of data if ever needed.
04-04-2016
11:55 AM
- last edited on
05-14-2025
03:12 PM
by
Content Cleaner
@crossrulz wrote:
If you are using a Producer/Consumer, it is very easy. One way is to recieve multiple elements in your queue and then write all of them in a single TDMS write.
Aren't I doing that now in the code I posted? I have a cluster of elements the queue, are you saying lose the other two writes, and recmombine them later? This is the code i posted earlier that is slowing down:
04-04-2016 12:14 PM - edited 04-04-2016 12:14 PM
Yes. So with your top loop, put the dequeue inside of a FOR loop that can stop when there is a timeout. The reason for the FOR loop is to log multiple instances at once. I would set N to be something like 10 (or more if you can afford to wait longer between writes).
04-04-2016 12:16 PM
And looking at this code again, we should combine the two string writes into a single write, like we are doing with the numerics.
04-04-2016 12:44 PM - edited 04-04-2016 12:45 PM
@crossrulz wrote:And looking at this code again, we should combine the two string writes into a single write, like we are doing with the numerics.
How do I combine them but keep them appearing in the right columns like they are now? I made them separate since I needed the headers to appear in excel a certain way when I opened the TDMS in excel.
Also am I doing a best practice by having double queues, one for VISA and one for data? Should I move the VISA just into the main loop with all the graphing? would that save memory/prevent slow downs?
And did i implement the array preallocation correctly in the main graph?
04-04-2016 01:13 PM
@superomario wrote:How do I combine them but keep them appearing in the right columns like they are now? I made them separate since I needed the headers to appear in excel a certain way when I opened the TDMS in excel.
Well, if that is a requirement, then nevermind.
@superomario wrote:Also am I doing a best practice by having double queues, one for VISA and one for data? Should I move the VISA just into the main loop with all the graphing? would that save memory/prevent slow downs?
That is what I do.
04-04-2016 01:33 PM
Thanks, I will give the for loop a try and run the program again, if it still does not result in 20sample/sec data recording/display am I just SOL?
And when you say that is what you do, do you mean keep two queues or VISA in main loop?
04-04-2016 01:37 PM
@superomario wrote:And when you say that is what you do, do you mean keep two queues or VISA in main loop?
I have what I call "modules". In your case, there is an instrument module, a processing module, and a logging module. Communication between loops is done with queues, just like what you have now.
04-05-2016 10:03 AM - edited 04-05-2016 10:09 AM
@crossrulz wrote:Yes. So with your top loop, put the dequeue inside of a FOR loop that can stop when there is a timeout. The reason for the FOR loop is to log multiple instances at once. I would set N to be something like 10 (or more if you can afford to wait longer between writes).
How did you get the stop sign in the for loop? Nvm I got that.
I am getting the error REfnum became invalid while the node waited for it. if the for loop is in the code and i hit the stop button. what does that mean?
04-05-2016 10:17 AM
@superomario wrote:I am getting the error REfnum became invalid while the node waited for it. if the for loop is in the code and i hit the stop button. what does that mean?
Well, you are trying to stop this loop by destroying the queue. So that makes sense to me.