LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cumulative sum of previous elements in an array

Hi all, I am trying to solve the following issue: Problem set:

To controll a pressure profile I utilize the PID setpoint profile function to set a time - setpoint profile. The VI asks for absolut time

time setpoint

10        5

20        10

50        10

100     0

 This input sets the following profile:

10 s to 5 bar

10 s to 10 bar

20 s at 10 bar

30 s to 0 bar.

 

As you can see this is not very user friendly, especially with more complicated profiles.

More useful would be to have an array where the user enters the time for EACH segment and using an array operation with a foor loop to generate the absolute value time table the subVI asks for.

 

The VI I try to find should add the segment time cumulatively and update the n-1 entry in the array after each iteration of the loop so that the last segment time is added to the sum of all previous segment times.

 

Basically read n value from input array add to n-1 value write to new array

next step is to read the next value from the input table and add to the sum of the previous iteration so that

 

5

10

3

1

becomes

5

15

18

19

 

I very much appreciate your suggestions and help.

 

 

 

, e.g. 5s 10bar, 15s 20 bar, 60s 20bar the segment looks like compressing for 20 bar in 5 seconds, changing to 20 bar in 10s and holding 20 bar for 40s. This is not very inutitiv espcially for complicated profiles. It is much easier to have an imput with realtive time, e.g. relative run time of the segment.
I tried several versions of using an array combined with a for loop and shift register

0 Kudos
Message 1 of 6
(5,617 Views)

@fuSi0nized wrote:

I tried several versions of using an array combined with a for loop and shift register


A For Loop and shift register is exactly what you need.  Why don't you post whichever version of your VI that you felt came the closest to what you want, and then we can help you figure out where you need to fix it.

0 Kudos
Message 2 of 6
(5,591 Views)

Hi fusi,

 

The VI I try to find

Why do you search for such a VI? Why don't you write your own?

 

All you need is a FOR loop with a shift register…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 6
(5,590 Views)

Thanky you for your fast responses.

 

I solved the problem. Beforehand, I had no array to write my data into. The data was written to the input table. Solution was to create a new table using build table and apend the table after each iteration.

 

 

@Gerd you got me wrong I just ask for a hint and not the complete solution.

 

 

0 Kudos
Message 4 of 6
(5,574 Views)

Hi fusi,

 

@Gerd you got me wrong I just ask for a hint and not the complete solution

Well, you got hints from us… 😄

 

In your VI you don't need this additional BuildArray function in the loop: use an autoindexing output to create your Array2!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 6
(5,569 Views)

Thank you very much, this is a neat simplifcation.

 

Regards,

 

0 Kudos
Message 6 of 6
(5,564 Views)