LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do default values of indicators work?

in a vi with only a boolean indicator, indicator NOT connected to connector pane:
indicator comes in at default when loaded.
indicator is NOT set to default when vi is run
OK

in a vi with only a boolean indicator, indicator IS connected to connector pane:
indicator comes in at default when loaded.
indicator IS set to default every time vi is run
OK


in a vi with only a boolean indicator, indicator connected to a read local of itself:
it comes in at default when loaded.
it does NOT set to default when vi is run
OK

in a vi with two boolean indicators, 1st is connected to connector pane, a read local of the 1st is connected to the 2nd:
both come in at default when loaded.
manually change state of 1st (but not
default value)
neither indicator is set to default during first run
the 1st is set to default on the second run

What is going on here?
0 Kudos
Message 1 of 11
(3,735 Views)

Hi Steve,

I have to confess that I am having a hard time folling this.

Could you please post an example to clarify?

Without that I will put forth a theory that may explain what you are seeing.

First for the not wired to connector pane terminals.

The will be set to their default state when the VI is loaded in to memory. As long as the VI stays in memory the boolean will maintain its state until changed by an user or set via code. I have seen people uses controls as a type of memory. I do not.

Next, the boolean wired to the icon connector.
The control will take on the value assigned to it by the calling code via the wire that is connected to it. If no wire is connected, LV will set it to its default value in your behalf.

Does this help?

Otherw
ise post an example and we will investigate further.

Trying to help,

Ben


Ben Rayner
Certified LabVIEW Developer
www.DSAutomation.com

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 11
(3,735 Views)
Hi Ben,

Thanks for your reply.

I want to clarify:
I am talking about indicators, not controls. No value is assigned by calling code. No calling code is used in these examples.

Steps for using the examples:
Load an example
change the state of the indicator(s) to true
run the vi
note effects on the indicator
run vi again
note effects on the indicator

Examples are attached. The example called "indicator2connectorPane-ReadLocalTo2ndIndicator.vi" is the one that I find confusing.

Thank you for your help.

Steve
Message 3 of 11
(3,735 Views)
I see your confusion!

Two suggestions;

1) Repost just the puzzle version as a new questions and ask if this is a bug. I will watch for others to reply.

2) Report this as a bug to NI.

I suspect this is one of those "Don't do that!" bugs.

It appears the indicator is behaving as if it is a set for latch action.

Maybe someone else will spot something I am missing.

Please keep us updated if you hear something "off-list".

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 11
(3,735 Views)
PS

If you create a local for that indicator and use that to wire to the indicator, everything works as I would expect.

BUT,
That just don't make sense!

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 11
(3,735 Views)
An indicator that is connected to a terminal (if not updated) will pass its default value.
But why you have to run the vi twice to make the indicator restore to its default value, that I do not know
This is also an issue in version 6.02 that I have seen before (but never been woried about)
If I am to use an indicator that is connected to a terminal, I usually update it (may be wire a constant to it)
Message 6 of 11
(3,735 Views)
It is as if the default value is being applied AFTER the VI runs.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 7 of 11
(3,735 Views)
BUt then again,

why would the default be applied?

Still puzzled,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 11
(3,735 Views)
It has been like that since the days of LabView version 3.1 (when I started using LabView.
This is also true for controls.


I have this note hanging on my cubicle since late 1996
The controls that are not connected use their default values
The outputs (indicators) that are not connected use their default values
Controls and indicators (that are not connected to terminals of the vi)and their local variables use the updated values in each iteration/run

I must have been puzzled then, and apparently someone at NI helped me (I assume so).

But this is the behavior that has been all along, and if it changes in future versions, I may have to reexamine some vi's
Message 9 of 11
(3,735 Views)
Before I go into the details, here is the basic rules to remember.
Everything that comes into memory is given its default value. So we can
take that one off the table.

Objects not connected to the connector pane probably behave as you
expect. The have the value written to it via local, terminal, or value
property. The primary exception is the latched button, which will reset
to default when read via the terminal.

Objects connected to the VI connector pane take on a few new behaviors
in order to make function calls more predictable. If not passed in, an
input parameter will use its default. If this weren't the case, it
could take on the value of the last call. This could be made useful,
but would be annoying most of the time and would require wiring most
inputs in order to have consistent execution.

Output objects wired to the connector will normally update the value
written to them during the diagram execution. But what happens when the
terminal is inside of a case and never written to. Should it return the
value in the control, which would be the last value written to it?
Again, this would be useful sometimes, but othertimes it would be
annoying. These are typically called conditional indicators.

> in a vi with only a boolean indicator, indicator NOT connected to
> connector pane:
> indicator comes in at default when loaded.
> indicator is NOT set to default when vi is run
> OK
>
> in a vi with only a boolean indicator, indicator IS connected to
> connector pane:
> indicator comes in at default when loaded.
> indicator IS set to default every time vi is run
> OK

This is because this is presumably an unconnected or conditional indicator.

>
> in a vi with only a boolean indicator, indicator connected to a read
> local of itself:
> it comes in at default when loaded.
> it does NOT set to default when vi is run
> OK
>

This isn't a conditional indicator since it is written to. It will
return the last value put into the Boolean.


> in a vi with two boolean indicators, 1st is connected to connector
> pane, a read local of the 1st is connected to the 2nd:
> both come in at default when loaded.
> manually change state of 1st (but not default value)
> neither indicator is set to default during first run
> the 1st is set to default on the second run
>
> What is going on here?

To simplify things a bit, delete the second Boolean and wire the value
of the first to an empty sequence or another node. You see the same
behavior, but it is simpler because the second Boolean has nothing to do
with it.

This is an odd case in part because the value of an indicator is being
set interactively. This cannot happen at runtime except to set it to
its default value. What is happening is that the first time the VI is
run, it seems that the Boolean was changed since its last run -- the
change is interactive, but it is a change none-the-less. So the first
run, the Boolean isn't reset since it appears like it was changed. For
the second run, nothing happened to the Boolean, so it is rerun. If you
are to run the VI once, then toggle the button twice, then rerun, it
will not toggle since again, it seems that the value was changed between
runs.

So, is this a bug? It is consistent with the conditional indicator, but
it is fooled a bit by the fact that the user is modifying indicators,
something that doesn't normally happen.

I hope this sheds a bit of light on your riddle. Was there any more to
your question? Do you have a VI with indicators being read and operated
in edit mode? This isn't likely to change, but I'm curious about an
application that is heavily affected by this behavior.

Greg McKaskle
Message 10 of 11
(3,735 Views)