LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Strange behavior feedback node in shared clone

Solved!
Go to solution

Hello,

 

I have some strange behavior of a feedback node as can be seen in the inserted VI snippet.

The particular VI is called in a chain of shared clone calls (call parent and dynamic dispatch). 

When I remove the feedback node and rely on a previous value register further down the line all behaves properly.

 

Running a single chain of clones gives proper results for each interface, but running 2 chains in parallel give erroneous result due to the feedback node.

 

LV version 2019.0f1 64-bit

 

Am I overlooking an obvious need to know or is there a bug?

 

erroneous behavior feedback node.png

Regards,
André (CLA, CLED)
0 Kudos
Message 1 of 12
(3,936 Views)

Feedback nodes store some data and this storage is in fact provided by the dataspace of the VI in which a feedback node (or shift register) is present. LabVIEW creates one VI dataspace per VI instance. Normal VIs always have only one instance, clones use one instance per clone. Since you use shared clones there is typically only one or two instances in memory unless your application happens to call routines that access the same VI multiple times in parallel.

Basically the presence of feedback nodes or shift registers in VIs configured as shared clones is never really a good idea and it could be considered a bug that LabVIEW doesn't flag this as an error.

The use of feedback nodes and shift registers in reentrant clones is fully valid but most times not what the developer intended unless he knows exactly what he or she is doing.

 

In your situation you probably do not want to use a previous value tied to the VI instance but rather to your processor class so you should store it in that class and not rely on VI instance specific storage which has absolutely nothing to do with your class data.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 2 of 12
(3,906 Views)

Thanks Rolf for this explanation.

It looks like it's a bit of both then:

1. I overlooked some need to knows "avoid feedback nodes and comparable shift register implementations in shared clones" 

2. The use of feedback node and shift registers in shared clones should've somehow been flagged by LV as something to be careful with.

 

Regards,
André (CLA, CLED)
0 Kudos
Message 3 of 12
(3,898 Views)

andre.buurman@carya wrote:

Thanks Rolf for this explanation.

It looks like it's a bit of both then:

1. I overlooked some need to knows "avoid feedback nodes and comparable shift register implementations in shared clones" 

2. The use of feedback node and shift registers in shared clones should've somehow been flagged by LV as something to be careful with.

 


There are of course cases where feedback nodes in shared clones are perfectly OK. What should LV do, issue a warning? Nobody pays any attention to them at all.  What does VI Analyzer say about it? Does it flag a warning?

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

@Intaris wrote:

 

There are of course cases where feedback nodes in shared clones are perfectly OK. What should LV do, issue a warning? Nobody pays any attention to them at all.  What does VI Analyzer say about it? Does it flag a warning?

I can't easily think of one although I'm sure it's possible that that exists. Can you explain in what cases you would consider that a useful feature?

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 5 of 12
(3,871 Views)

I'd argue it isn't the use of shift registers and feedback nodes that is a problem, but the use of uninitialized shift registers or globally initialized feedback nodes.

 

SR's and FBN's are okay for loops where the data is intialized and fully consumed within the subVI.  As long as the SR or FBN is initialized when the clone starts executing when it is called, you're fine.

0 Kudos
Message 6 of 12
(3,870 Views)
Solution
Accepted by topic author andre.buurman@carya

@rolfk wrote:

In your situation you probably do not want to use a previous value tied to the VI instance but rather to your processor class so you should store it in that class and not rely on VI instance specific storage which has absolutely nothing to do with your class data.


This is actually what happens when I remove the feedback node. It then uses a previous values stored in a session object at a lower level specific to a particular interface and that works.

Regards,
André (CLA, CLED)
0 Kudos
Message 7 of 12
(3,855 Views)

@RavensFan wrote:

As long as the SR or FBN is initialized when the clone starts executing when it is called, you're fine.


Am I being dense?  If you initialize the SR or FBN when the clone starts executing, why even have the SR or FBN?

 

Oh, I think maybe I get it -- you're thinking specifically of clones with their own internal looping, not the classic single-iteration loop with a USR that I was thinking of.  Right?

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 8 of 12
(3,832 Views)

@rolfk wrote:


I can't easily think of one although I'm sure it's possible that that exists. Can you explain in what cases you would consider that a useful feature?


If a shared sub-VI needs to interact with another object with state where reading out some of the state is important for performant code.  Knowing when the cached state data is out-of-date (new object passed) is crucial to this.

 

It's not going to be a huge use case, but it is one and it's perfectly valid.

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

@Intaris wrote:

If a shared sub-VI needs to interact with another object with state where reading out some of the state is important for performant code.  Knowing when the cached state data is out-of-date (new object passed) is crucial to this.


But if both classes are accessing that VI at the same time, Shared Clone rules dictate that a new clone would be added to the pool.  So you will not have the "cached" data as the new fresh clone will be used.  What you are describing sounds more like it should be non-reentrant.



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 10 of 12
(3,822 Views)