LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Feedback doesn't work with this

Solved!
Go to solution

I think there's a more elegant way to do this with the Feedback control but I can't get it to work.Capture.PNG

 

 

 

 

0 Kudos
Message 1 of 12
(3,880 Views)
Solution
Accepted by RHutchings

Note 1: There is a decrement function; so you could subtract 1 without an explicit constant.

Note 2: The Delete From Array removes elements from the end if no index is specified.

You could do something like this:

1.png

But the simplest form would be:

2.png

Paul Cardinale

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 2 of 12
(3,860 Views)

How does it not work?

 

Please attach an actually VI of your non-working attempt rather than a screenshot of the original code.

 

0 Kudos
Message 3 of 12
(3,853 Views)

Thank you. The simplest version worked great!

0 Kudos
Message 4 of 12
(3,842 Views)

It does work as it is. I just thought I could use a Feedback node somehow instead of the 2 local variables. This is just a part of a larger vi that I don't wish to share plus I thought it was simple enough to just show a photo.

0 Kudos
Message 5 of 12
(3,838 Views)

The more elegant - or more dataflow-ish - way to do this is to replace those local variable with wires from the control itself.  I am even a bit afraid to think about code where using local variables in this way was necessary.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 12
(3,824 Views)

@RHutchings wrote:

It does work as it is. I just thought I could use a Feedback node somehow instead of the 2 local variables. This is just a part of a larger vi that I don't wish to share plus I thought it was simple enough to just show a photo.


Yes.  But you said you tried an alternative with a feedback node that didn't work for you.

If you want help troubleshooting your alternative, then it would help if you posted that attempt.

0 Kudos
Message 7 of 12
(3,805 Views)

We really need to see the entire code to give more constructive advice. Local variables completely blur the distinction between control and indicator, we cannot tell what it is!

 

Is it a control where the user can manually change values at runtime? Is it a useful indicator that displays information? Is it a useless (even hidden) control/indicator for the sole purpose of data storage via locals?

For the third case, the data could exclusively live on the diagram (wires, shift registers, feedback nodes) and the front panel object could be deleted entirely. This is most efficient.

0 Kudos
Message 8 of 12
(3,799 Views)

That sounds great but doesn't work for me. There's reading and writing and this is the only way I know to do it. Here's the whole thing if you want to help me.

 

0 Kudos
Message 9 of 12
(3,792 Views)

I still don't see your failed feedback node attempt.

 

A couple things I see:

1.  I don't see any while loop in this VI.  So it seems to run once the stop.  Is that what you want?

2,   Event structures just about always belong in a while loop.  Write now, if you don't hit Load Setup 2 in the first 100 milliseconds after you start your VI, that event structure times out to never have a chance to run again.

3.  Too many local variables.  Rather than read from a local variable, you should be using the wire from another location.  Then you can get rid of the sequence structure. The other problem is that they cause race conditions.  Current(V1-V2) is written to at multiple locations.  Which value sticks depends on what section of code runs last.

4.  If you do need a sequence structure, then a flat sequence is better than a stacked for readability.

5.  Index Array is resizable.  Drag the bottom border down.  You'll get indices 0 through N automatically.

 Untitled

0 Kudos
Message 10 of 12
(3,787 Views)