From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Iterative calculation - retaining and using values

Dear LabVIEW Forum Members,

 

This may appear to be a trivial question however I am having difficulty trying to solve this problem using the LabVIEW vi's & environment.  I explain as follows:

 

I need to calculate and display, in graph form, the contents of a Hopper that is initially filled to 100 tonnes.  The hopper is being discharged and filled at the same time, I have the values of filling and discharging in 1 second intervals.  The contents of the Hopper is a simple mass balance calculation, Hopper Contents = Inlet material - Outlet material.  Below are the first few data sets:

 

Material Into Hopper         Material out of Hopper        Theoretical Hopper contents

               0                                     0                                                 100

               0                                     1.534057                                   98.465943

          0.345                                  5.250186                                   93.560757

          0.6                                       6.801075                                   87.359682

 

How can I iteratively calculate and use the 'Theoretical Hopper contents' calculation from the Hopper inlet and outlet ?  I am using the Simulation & Control Frame so I cannot use the For Loop within this frame.  Attached is me vi program so far and the Build XY Graph2 is where I'm wanting to display this Hopper contents data.

 

Any help would be gratefully appreciated.

 

Regards,

0 Kudos
Message 1 of 16
(3,819 Views)

You can use a feedback node to pass the current contents to the next loop.  It works the same way as a shift register.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 16
(3,808 Views)

Hi bunny,

 

- you should use shift registers (or feedback nodes) to forward values from one iteration to the next...

- you should use a (while) loop in your VI to keep it running...

- you don't need to convert from ARRAY(DBL) to DDT to ARRAY(DBL) to apply a multiplication operation...

Best regards,
GerdW


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

I had not used the simulation toolkit, yet, so I took a minute to play with the wires - and to see if the snippet will work:

Plant_Simulator (20130515).png

0 Kudos
Message 4 of 16
(3,794 Views)

Thanks for your response post and snippet.  I'm not sure why you need to have the feedback element for X for all 3 graphs since the simulation time automatically increments in 1 second intervals.  The graph for Hopper contents in your snippet is not what I was expecting.

 

For my application the Hopper is pre-charged to 100 tonnes (start condition), I'm having trouble trying to get the program working with this pre-set value and then using the data (material inlet to Hopper and material out of Hopper) to update the actual Hopper contents.

0 Kudos
Message 5 of 16
(3,766 Views)

The feedback for x is because I removed the xy graph express VI, which makes the xy graph into an xy chart (kind of).

Looking at it again, perhaps it would be easier to use three regular waveform charts. Then you don't have to do anything with x.

 

I faked a data file instead of pulling the data out of the graphs you posted.

 

Oh, I put some breakpoints down and did some single-stepping. You are indexing the "Material Into Railcar" array with the Simulation time, which is not an integer.

0 Kudos
Message 6 of 16
(3,750 Views)

The problem I'm having is how to initialise the hopper contents to 100 tonnes and to then carry out the update on hopper contents based on the material input and output from Hopper in 1 second increments.  I know what to expect based on some hand calculations with approximate values however I'm having difficulty in implementing the calculation within LabVIEW.

 

You said in your reponse "You are indexing the "Material Into Railcar" array with the Simulation time, which is not an integer" - does this mean that it doesn't work properly ?  I though that this part was working ok ?

0 Kudos
Message 7 of 16
(3,734 Views)

Hello bunnykins,

 

I believe what crossrulz was referring to is that because you are using the simulation time (which is not an integer value) to index the array, you'll likely run into round-off error. This may be intentional, but is still worth mentioning.  For instance, if your simulation time is 1.73 seconds (coerced to 2), you'll be indexing at row 3 rather than row 2.

 

Regards,

Tom L.
0 Kudos
Message 8 of 16
(3,701 Views)

Thanks for the explanation.  I thought that the simulation time was in 1 second intervals (integer values) since within the Simulation Frame 'Configure Simulation Parameters', 'Continuous Time Step and Tolerance' I have set the following parameters to one (1) second:

'Initial Step Size' = 1s

'Minimum Step Size' = 1 s

'Maximum Step Size' = 1s

 

When I viewed the indicator value of the Simulation Time it appears to be incrementing in 1 second intervals.

0 Kudos
Message 9 of 16
(3,668 Views)

Maybe those values changed for me, though I don't know how - I didn't mess with them. Initial Step Size was 0.01. I only saw it while probing the wires.

0 Kudos
Message 10 of 16
(3,664 Views)