From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
11-17-2013 10:45 PM
Hi People,
I am almost at the end of my tether. I really hope someone could please help me.
Any input would be welcome. VI attached.
VI explanation:
I initialize an array.
The random number generator simulates my camera input.
Depending on which iteration it is, the data is added into one of four output arrays.
'x-y*floor(x/y)' gives a remainder value of 0, 1, 2 or 3.
'Case Selector' just adds 1 to 'x-y*floor(x/y)' to get case 1, 2, 3 or 4.
Shots 1, 5, 9 etc are added to Array 1 (Case 1).
Shots 2, 6, 10 etc are added to Array 2 (Case 2).
Shots 3, 7, 11 etc are added to Array 3 (Case 3).
Shots 4, 8, 12 etc are added to Array 4 (Case 4).
Averaged Output displays the averaged value i.e. the total value divided by the number of shots saved in that array ('Set (IQ+1)').
My problems are:
1) I would like to output only the last 4 sets of data from the Averaged Output 1, 2, 3 and 4 to 4 different files (i.e. save as .csv what is displayed onscreen in indicators 'Averaged Output 1', 2, 3 and 4 at the end of all iterations.
Where should I place my file save diagram disable so that it does this?
Putting it outside the main For Loop with auto-indexing on gives me one file with all previous data. (This is not feasible as my number of shots should number in the thousands)
Putting it outside the main For Loop with auto-indexing off gives me only the last set of data. (I need the output for 4 Arrays, not just the last run)
Putting it inside the main For Loop (as shown) gives me the same number of files as number of iterations. (Again not feasible due to large number of files that will be generated and slow camera capture)
For the sake of fast camera capture, I would like these 4 files to only output once all the image captures are complete.
2) Would preferably like to name the file once and for the programme to append '(1)', '(2)', '(3)' and '(4)' to filename of the appropriate 'Averaged Output' Arrays but file path controls are another big headache for me.
3) P.s. is initializing one array enough to avoid using Memory Manager? Or should I initialize 4 arrays?
I am using Labview 2010.
Thanks so much,
Jaslyn
Solved! Go to Solution.
11-18-2013 12:47 AM
Hi,
First, what do you mean by "add"? Your code in your case strcuture sums your input values, so your array size doesn't change. However, you also said "Putting it outside the main For Loop with auto-indexing on gives me one file with all previous data. (This is not feasible as my number of shots should number in the thousands)" -- it sounds like you are expecting an array with thousands of elements. So, what should "Output Array N" look like?
(Note: Most of your arrays are 4x4, but in Case #2 you created 128x128. I prersume this is a typo?)
Second, why do you add your "simulated camera input" to the "Initialized Array"? You can add it direcly to the previous output inside your case structure.
Third, have a look at shift registers: http://www.ni.com/gettingstarted/labviewbasics/shiftregisters.htm. Use them instead of Feedback Nodes to make your code tidier.
@jaslyn wrote:
1) I would like to output only the last 4 sets of data from the Averaged Output 1, 2, 3 and 4 to 4 different files (i.e. save as .csv what is displayed onscreen in indicators 'Averaged Output 1', 2, 3 and 4 at the end of all iterations.
Where should I place my file save diagram disable so that it does this?
For the sake of fast camera capture, I would like these 4 files to only output once all the image captures are complete.
You will need to call "Write to Text File.vi" 4 times to write 4 files. So, you should finish your loop, then call this VI 4 times.
@jaslyn wrote:
2) Would preferably like to name the file once and for the programme to append '(1)', '(2)', '(3)' and '(4)' to filename of the appropriate 'Averaged Output' Arrays but file path controls are another big headache for me.
You can create strings first, then convert them into paths: http://zone.ni.com/reference/en-XX/help/371361G-01/glang/string_to_path/
@jaslyn wrote:
3) P.s. is initializing one array enough to avoid using Memory Manager? Or should I initialize 4 arrays?
I'm not sure what you're asking; can you please clarify what you mean by "avoid using Memory Manager"? But anyway, you've actually initialized FIVE arrays: 1 outside the loop, and 1 inside each case.
11-18-2013 12:59 AM - edited 11-18-2013 01:06 AM
Hi jaslyn,
I presume that you want to store the 4x4 array of average output for the last 4 iterations (correct me if I'm wrong). If so, I have set up the example as shown below:
So basically, what I have done is that I have created a comparator to check if the iteration is of the last 4 total iteration you have set. I have included a number at each of the case structures to define which case it belongs to. The comparator will pass a boolean output to the case structure which contains the algorithm to writing a file. Since you mentioned that you want to create a file for each of the case, I have created the build path function to create custom file name for each case. You'll notice that there is a concanate string.vi which allows me to customize the name of the file. Since the common file is to be Average Output, I take the numeric constant taken from the case structure and convert it to string and concanate it to make it into e.g. Average Output 1.txt. Please note that you'll need to put a base path such as for my case, I would like to save it in the folder named 'New folder(3)' at my desktop.
The write to file case only occurs if the condition is true (i.e. only the last 4 iterations of the for loop)
Once done, I have created the header and write it into that text file and followed by the spreadsheet data on the next line.
I have attached the code for your reference. Let me know if this is what you wanted.
Thank you
Warmest regards,
Lennard.C
11-18-2013 09:45 AM
Dear Lennard,
Ohmygosh thank you so much!!!! You have by and large solved my problem, thank you!!!!
I just have two questions..?
1) Why is the subtraction 4 in every case but case 4 which subtracts 3?
This is to determine if this iteration is one of the last 4 iterations, right? Why do you subtract 3 and not 4 in case 4?
2) What's in the Diagram Disable structure and why is it only disabled for case 1? (array size, index array, subtract 4, delete from array) What is it trying to do?
I blocked it out in one of the cases using DIagram Disable but it made no difference to the data.
Thank you so much, Lennard!!!
Jaslyn
11-18-2013 07:22 PM - edited 11-18-2013 07:25 PM
Hi jaslyn,
You're welcome. 😉
About your question:
Anyways, I have attached the modified version of that file based on your feedback.
Thank you
Warmest regards,
Lennard.C
12-01-2013 10:00 PM
Thanks so much Lennard!!
Hi JKSH,
I've been busy trying to complete the dang code, but for completeness so that other users can learn too, I shall answer your queries. 🙂 Thanks for looking in.
First, what do you mean by "add"? Your code in your case strcuture sums your input values, so your array size doesn't change. However, you also said "Putting it outside the main For Loop with auto-indexing on gives me one file with all previous data. (This is not feasible as my number of shots should number in the thousands)" -- it sounds like you are expecting an array with thousands of elements. So, what should "Output Array N" look like?
Ans: Output Array N should be a 4x4 array of the summation of all the numbers generated during every 4th iteration.
i.e. if random number 1=1, random number 2=2, etc, And 'No of iterations' is 12,
Output Array 1 should be 1+5+9:
15 15 15 15
15 15 15 15
15 15 15 15
15 15 15 15
(Note: Most of your arrays are 4x4, but in Case #2 you created 128x128. I prersume this is a typo?)
Ans: Kind of, I'm using a 4x4 array of randomly generated numbers as an example but my actual data will be the 128x128 pixel output of a camera. And during actual experimentation, 'No of Iterations' will number in the thousands.
Second, why do you add your "simulated camera input" to the "Initialized Array"? You can add it direcly to the previous output inside your case structure.
Ans: See answer to question 3
Third, have a look at shift registers: http://www.ni.com/gettingstarted/labviewbasics/shiftregisters.htm. Use them instead of Feedback Nodes to make your code tidier.
Ans: I did try.. But I can't seem to add shift registers to the case structure, only the for loops outside. Are you sure it can be done..?
jaslyn wrote:
1) I would like to output only the last 4 sets of data from the Averaged Output 1, 2, 3 and 4 to 4 different files (i.e. save as .csv what is displayed onscreen in indicators 'Averaged Output 1', 2, 3 and 4 at the end of all iterations.
Where should I place my file save diagram disable so that it does this?
For the sake of fast camera capture, I would like these 4 files to only output once all the image captures are complete.
You will need to call "Write to Text File.vi" 4 times to write 4 files. So, you should finish your loop, then call this VI 4 times.
Ans: How do I get it to extract the data from each of the 4 cases in my case structure?
jaslyn wrote:
2) Would preferably like to name the file once and for the programme to append '(1)', '(2)', '(3)' and '(4)' to filename of the appropriate 'Averaged Output' Arrays but file path controls are another big headache for me.
You can create strings first, then convert them into paths: http://zone.ni.com/reference/en-XX/help/371361G-01/glang/string_to_path/
Thanks
jaslyn wrote:
3) P.s. is initializing one array enough to avoid using Memory Manager? Or should I initialize 4 arrays?
I'm not sure what you're asking; can you please clarify what you mean by "avoid using Memory Manager"? But anyway, you've actually initialized FIVE arrays: 1 outside the loop, and 1 inside each case.
I've read that to avoid fluctuations in memory usage, it is a good idea to initialize arrays to their expected size before the start of data collection. That was just what I was trying to do.
01-15-2014 05:26 AM
Hi Guys,
Is it possible to store, for example tick counts or image pixel data, in an array first, then save it to a file AFTER the programme is done running (or at least when the instruments have done their work)?
The reason for this is so as not to slow the programme down by taking up resources saving as it is running.
Any thoughts? Thanks lots.
Best Regards,
Jaslyn
01-16-2014 08:58 AM
jaslyn wrote:Is it possible to store, for example tick counts or image pixel data, in an array first, then save it to a file AFTER the programme is done running (or at least when the instruments have done their work)?
The reason for this is so as not to slow the programme down by taking up resources saving as it is running.
Yes, since LabVIEW is a full featured programming environment, anything is possible. You should however start a new question instead of adding to an only remotely related old discussion that is already marked as solved.
How much data are you trying to accumulate?
01-19-2014 11:23 PM
Hey...
I thought I replied to this ages ago... Sorry for the delay.
Thanks for the reply, altenbach.. Feels good for a newbie to see a revered guru replying to her thread. 🙂
I'll start a new question, but basically, 10000 tick counts and 10000 128x128 pixel images. The images are being output automatically but I wish I could just highlight, copy and paste the tick counts from the array (like in Excel) after the programme is done running.
Thanks for replying!! ^^