LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I transfer one control value to other control

Solved!
Go to solution

Hello,

 

Sorry for asking a silly question but I'm stuck on logic and need your help.

 

In one part of my project I've to do something like this:

 

The value of Input A (DBL) will be transferred to Input B (DBL) and then I can change the value of Input B independently and the Input A value will remain unchanged. 

 

Note: I tried with the property node but, I can't be able to change the Input B value anymore.

 

QQ.png

 

Appreciate your kind effort 🙂

 

 

0 Kudos
Message 1 of 12
(4,054 Views)

To write to a control that resides in the same VI, use a local variable (not a value property node!).

 

You currently have a greedy loop and a glaring race condition because you cannot tell if B is read before or after the value got transferred. ANd with every iteration of the loop (millions of times per second!) you are again writing the A value to B, fighting and undoing any user interaction on B.

 

The most important question is what triggers a transfer? Obviously, you only want this transfer to occur in specific situations (when a condition occurs? When the program starts? What the user pressed a button?, etc.) Please carify!

0 Kudos
Message 2 of 12
(4,044 Views)
Solution
Accepted by topic author REDUANUL

Something like that?

 

altenbach_0-1626795016261.png

 

Message 3 of 12
(4,043 Views)

Hello altenbach,

 

I am afraid no additional button can be added. My project was in QMH so I made another example with my current design structure.

 

In the attachment Input A value will be transferred to Input C and afterward Input C can be changeable (Input A will remain unchanged). No additional button can be added to implement this that was one of the requirements!

 

Please check the attachment ZIP.

 

 

0 Kudos
Message 4 of 12
(4,005 Views)

@REDUANUL wrote:

 

I am afraid no additional button can be added.


The button is just for demonstration. One way or another the program needs to be aware of a condition that triggers a transfer of the A value to the B control. You can use anything on the diagram (values of wires, change to a certain state, change in A, etc.)  to detect a transfer trigger. It is really up to you to make that decision. (Haven't looked at your new example, posting by phone).

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

@REDUANUL wrote:

In the attachment Input A value will be transferred to Input C and afterward Input C can be changeable (Input A will remain unchanged). No additional button can be added to implement this that was one of the requirements!

 


OK, looking at your code and it makes no sense. In exactly what state should the transfer happen?

Most of your cases are not reachable. Then you have glaring race conditions, for example you write two (typically different) values to the same "output" indicator. Whatever writes last wins!

 

altenbach_0-1626805774538.png

 

0 Kudos
Message 6 of 12
(3,990 Views)

@altenbach wrote:

what state should the transfer happen?

The transfer should happen when I change Input value A. So somehow this condition should give logic for your previous code then I think it will work.

 

 

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

and basically when the Input A value being updated then Input C will get the same updated value and when I change Input C then It will take that value not from the Input A value (But Input A value remains unchanged).

 

So in your code, it will work if we can think how can we make this as a case selector value (that you tried before as transfer 1)

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

Thanks, Altenbach I found the solution which will exchange the value 🙂

0 Kudos
Message 9 of 12
(3,956 Views)
Solution
Accepted by topic author REDUANUL

@REDUANUL wrote:

Thanks, Altenbach I found the solution which will exchange the value 🙂


Feel free to share your solution. Make sure you don't overcomplicate it, e.g. by using value property nodes. Also make sure that the B update occurs before the B terminal is read to avoid possible race conditions.

 

Here's one possibility:

 

altenbach_0-1626828287826.png

 

(In LabVIEW 2020 you also have the "Is value changed.vim". You could also do something with events.)

 

Message 10 of 12
(3,926 Views)