08-31-2012 08:20 AM - edited 08-31-2012 08:22 AM
I am writing a program that every second runs through a lot of data and calculates an unknown number of parameters. Each of these parameters calculated I want to append into its own waveform, one time per second I want to add onto the values of all of these so that I can plot the multiple values each one with a different color on a screen.
I can do this with one wave form no problem. All I am doing is appending a new value onto the tail end of a waveform. The trouble comes when I try to pass the data through the shift register that things fall apart. Infact just setting up a variable quantity of waveforms I am habving issues with.
Below is a copy of my attempt at a code to initialize waveforms 1:N. What is the correct way to initialize 1:N waveforms? Next once I do that how do I then take a 1D 1:N array and incrementally append once per calculation the new values to their respective waveform?
Thanks,
Adam
08-31-2012 08:27 AM
If putting multiple waveforms into the shift register is what you want to do then the shift register has to contain an array of waveforms.
This means you have to wire an array of waveforms to the shift register to initialize it accordingly.
Just drop an array constant from the array palette and drag your left waveform constant into it.
Regards Florian
08-31-2012 08:37 AM
@Florian.Ludwig wrote:
If putting multiple waveforms into the shift register is what you want to do then the shift register has to contain an array of waveforms.
This means you have to wire an array of waveforms to the shift register to initialize it accordingly.
Just drop an array constant from the array palette and drag your left waveform constant into it.
Regards Florian
Hi Florian,
If you look at the screenshot that I put in here the issue I am having is I don't know how many waveform arrays I will need. Thus I need to build a waveform that is a 1xN array, I can't seem to figure out how to go about doing that.
Thanks,
Adam
08-31-2012 08:47 AM
08-31-2012 08:48 AM
Hi,
I did look at the screenshot - the shift register in it is not initialized as an array of waveforms at all. If you follow my instructions above, thus initializing the shift register with an empty array of waveforms, you can add as many elements (i.e. waveforms) as you like. This is what you seem to be trying to do in the screenshot.
Additional info: It is usually not recommended to grow an array inside a loop like you plan to do. The programs memory usage may grow out of bounds - but sometimes this implementation is the way to go. Only you may know.
08-31-2012 09:06 AM
@Florian.Ludwig wrote:
Hi,
I did look at the screenshot - the shift register in it is not initialized as an array of waveforms at all. If you follow my instructions above, thus initializing the shift register with an empty array of waveforms, you can add as many elements (i.e. waveforms) as you like. This is what you seem to be trying to do in the screenshot.
Additional info: It is usually not recommended to grow an array inside a loop like you plan to do. The programs memory usage may grow out of bounds - but sometimes this implementation is the way to go. Only you may know.
Hi Ludwig, sorry, I did not realize that you could build a waveform into an array as Gerd showed above, I am still on the early side of the learning curve here. With that being said, Gerd what were those index array functions you used? I believe I have LabVIEW full 2011 and those functions don't seem to appear under the array tab. Could you get me the names of them so I can search for them?
Thanks for the help,
Adam
08-31-2012 09:11 AM
08-31-2012 09:54 AM
@GerdW wrote:
Hi Adam,
I'm pretty sure you will find IndexArray and ReplaceArraysubset on your array functions palette.
The other two functions are found on the waveform palette: GetWaveformComponents & BuildWaveform...
See my program below, it appears to be working for the last wave I put in but I am still trying to debug what is occuring with the rest of it, I have altered the program so that I now initialize outside of a while loop running in a higher level program.
One thing interesing is that my Index Array and Replace Array icons look different than yours and lack what would appear to be the 2D nature that yours shows. I would think this may just be a difference in versions of the program?
I have used the build array tool before but haven't used the top input. If I am correct does that top link where it shows the wave above the "Y" simply append the new value of Y on the back of the wave form?
If so have I done this correctly?
Thanks,
Adam
09-02-2012 04:00 AM - edited 09-02-2012 04:03 AM
Hi Adam,
some points for your code example:
- use autoindexing when you need to do the same operation for each element (for both the waveform input as the "input values" input as well [they need to have the same amount of elements!])
- use BuildArray instead of InsertIntoArray when you want to append to the end of an array
"I have used the build array tool before but haven't used the top input. If I am correct does that top link where it shows the wave above the "Y" simply append the new value of Y on the back of the wave form?"
It seems you talk about the waveform functions and not about array functions. Ever considered to open the context help and ever considered to read the (linked) extended help to understand what each input of a function is used for?
06-03-2013 09:19 AM
Dear all,
I have a similar problem, I want to add waveforms of multiple channels within a loop using a shift register.
Attached is a sample problem. Even after some research, I cannot get it to work.
I want to keep the time stamp and simply add the new arrays at the end of each channel.
Also attached is a sample solution, which is not working probably.
Thank you for your advice.
Jack