01-21-2019 02:46 PM
Hello,
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.
Petmar
01-22-2019 07:00 AM
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.
01-22-2019 07:16 AM
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:
Bob Schor
01-22-2019 04:24 PM
Hello crossrulz,
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.
Petmar.
01-22-2019 04:40 PM
Hello Bob,
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.
Petmar.
01-23-2019 06:46 AM - edited 01-23-2019 06:49 AM
@petmar wrote:
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.
01-23-2019 09:37 AM
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
01-23-2019 09:58 AM
Hello crossrulz,
I followed your steps but it seems I messed up somewhere. Can you please check for me. Thank you.
Petmar.
01-23-2019 10:12 AM
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.
Petmar.
01-23-2019 11:13 AM
Petmar,
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".
Bob Schor