LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

adding to multiple waveform arrays with for loop

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

0 Kudos
Message 1 of 10
(4,850 Views)

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

0 Kudos
Message 2 of 10
(4,844 Views)

@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

0 Kudos
Message 3 of 10
(4,840 Views)

Hi adam,

 

see here:

check.png

- initializing an array of waveforms

- picking one waveform, change the waveform data

- replace waveform in array

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(4,831 Views)

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.

0 Kudos
Message 5 of 10
(4,830 Views)

@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

0 Kudos
Message 6 of 10
(4,822 Views)

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...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 10
(4,817 Views)

@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

 

0 Kudos
Message 8 of 10
(4,810 Views)

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

check.png

 

"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?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(4,799 Views)

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

Download All
0 Kudos
Message 10 of 10
(4,526 Views)