LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reset my Array and Graph without stopping the VI

Hello,

 

when I run my program, I click a button to read some data over TCP/IP for 40 seconds. This data is inserted into an array.

When I click the button the second time, I want the array to be reinitialized so that I get new data in it.

The problem is that the second time I still get the old values, even though I set the array to default values before I get the new data.

 

Is there any other way I can clear everything in the array without stopping the VI?

 

Any tips would be appreciated 🙂

 

Best regards

Edmond

0 Kudos
Message 1 of 5
(1,225 Views)

Hallo Edmond,

 

it doesn't help to clear any indicators/data sinks!

 

When you "think dataflow!" then you need to reset the data buffers/sources!

LabVIEW keeps data in wires and shift registers/feedback nodes.

In your case you need to reset your feedback nodes...

 

Even better would be to redesign the whole VI. No need to set all those front panel elements to default, no need to close front panel references.

 

What about a proper statemachine? What about LabVIEW style guide? What about removing all those Rube-Goldbergs?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(1,209 Views)

While it is almost impossible to debug a truncated picture, I agree with Gerd that you are way overcomplicating this.

My guess is that you have more than three times the code needed for all required functionality. Simplify!!!

 

Any indicator just displays whatever data it receives, so just change what's in the wire. Indicators never need to be reset to default!  In rare instances, resetting a control is sometimes used, but typically a local variable is preferable over that. None of these invoke nodes are needed. And no, you don't need to close static references. That's a no-op.

 

  • You are not inserting into an array, but appending to an array. For that, the correct tool is "built array"!
  • an "X OR FALSE" just returns X unchanged. (not sure what's in the other case)
  • For code readability, don't have wires flowing in all directions, especially right-to-left. Don't hide wires under structures and make sure tunnels show their wires on both side.
  • Since you are appending single points, maybe a "chart" would be more appropriate. No need to even build any arrays.
  • "equal" and "not equal" comparisons of DBLs are a minefield! Just don't do it. (If the values are actually integers, the wires should be blue!)

 

Maybe if you would attach your VI, we could give more specific advice. Many things cannot be seen in an image (VI settings, mechanical actions settings, code in other cases, code outside the truncated view, etc.). We are here to help. 😄

0 Kudos
Message 3 of 5
(1,185 Views)

Hello,

It's my first Labview project ever and I was asked to do difficult things for a beginner 🤣. Yes I believe the whole thing can be simplified.
I have attached my VI, thanks for your help!!!

 

0 Kudos
Message 4 of 5
(1,172 Views)

See if this can give you some ideas.

 

(cannot test, so there are probably bugs. This is a "near literal" translation of your code. Most likely there are better approached to several of the constructs and I would probably do things differently once I know all requirements, but this should get you started.)

0 Kudos
Message 5 of 5
(1,161 Views)