I want to take my VI a step further. I'm currently saving the locations and amplitudes of the peaks for the individual scans. In addition to that, I now also want calculate and save the the average of the peaks locations and amplitudes after every 20 scans (e.g., 0-19, 20-39, 40-59 etc.). Any help will be appreciated.
You could keep a running sum and the number of scans in shift registers. When the number of scans has reached 20, divide to get the average, save your average, and reset your shift registers to 0.
The "simple answer" to your question is to arrange your "Take Data" case to accumulate the 20 "single items" you are writing in an array by passing them out of the For loop through indexing tunnels, then before exiting the Event structure, forming averages from these arrays and writing them to a file with a slightly different name (maybe "Image Average").
A more complete answer is that it would really surprise me if your code works! There are numerous "style" problems with the part shown on your post that could (and should) be improved by doing such things as "hiding the details inside subVIs". Here are a few examples:
Can you show me how it can be implemented? I have seen similar ways of doing it but I always get broken wires when I try it.
I understand your concerns about my VI but the truth is that I'm very new to LabVIEW. I've been able to come up with this thanks to the good people on this forum and so far it works fine. To be honest with you I don't know how I'll implement or fix most of the issues you raised. Please help me if you think there are areas that need improvement. Thank you.
Just a quick note on something I saw in your diagram:
Don't open and close VISA sessions every time you use an instrument.
Open a VISA session at the beginning of your program
Use shift registers to pass the VISA session around the loop and reuse it every iteration
Close the VISA session at the end of your program
I followed your steps but it seems I messed up somewhere. Can you please check for me. Thank you.
Hello RT SLVU,
Can you please wire what you're suggesting for me. I not sure of what you're talking about. You can do it in the VI above. Thank you.
This is your Project. You've gotten numerous suggestions, but don't seem to have implemented many of them. Try "starting over", using the suggestions, but trying to do just one thing at a time. If it works (and it should), then add something else. Start with using a single Error Line ...
I assume you are trying to learn LabVIEW. In my experience with trying to learn a number of Programming Languages and paradigms (including LabVIEW), there is no substitute for writing programs when learning how to write programs. Having someone do your work for you doesn't really teach you to "do it yourself".