LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Refreshing a control variable

Hi,I'm quite new in LV [more or less one week :smileyhappy:]

 

I'm developing a front panel for moving a Newport device. More or less is already programed. I choose the kind of movement [absolut or relative, horizontal or vertical]  with an event structurewhere each case is activated with his own button.

 

In front panel there are two controls for chosing the distance. I want that when the user changes the number on one of this control my program refresh the variable.

I have tried what you can see in the image below but the problems is that the variable value "stops" just at the exit of the while and doesn't arrives at event structure. If I make it without the while loop the following occurs: when I run, controls send the variable valueat the event structure entrance ant then, if you change this value it doesn't refresh it until the next global while iteration, so you have to move it always twice [it's like you are always one iteration defased]

 

I hope you understand my bad english and the situation.

Maybe it's a simple problem by I don't see it.

 

Thank you very much in advance for each eventual response.

 

 LV.jpg

0 Kudos
Message 1 of 8
(3,701 Views)

I'm not sure I understand what you mean by "refresh the variable", but it seems like you may not be understanding how to use event structures, and are also not completely understanding dataflow programming. In your code the event structure cannot do anything until that little while loop has finished. That's because you have wires coming out of the loop, tunneling through it, and then tunneling into the event structure. Data on the wires between the while loop and the event structure will not be present until the while loop finishes. This is by design of the LabVIEW language.

 

Based on what I can see, it seems to me that you should be handling a "Value change" event for those numeric controls inside the event structure, and eliminate the small while loop. Thus, when the user changes the value of the control, the event structure will fire, and you can generate the string based on the control's value. See attached simple example

 

0 Kudos
Message 2 of 8
(3,695 Views)

Thank you very much for your response.

 

The fact is that I've already tried your suggestion before BUT in the front panel I have one number controller for 2 buttons.

 

For instance, in the "relative movement" case there is a number controller where you write how much the mover will move [say 2cm] and 2 buttons [one for moving forward and one for moving backward] so you can't make that the event depends on the number variation but on the pressing of buttons.

 

I understand now why it doesn't work with the while loop. That was a suggestion because I made before without it and then it occurs what I wrote, it works good but with "one button pressing" defase because the previous Relative [or Absolut] variable is already sent when you change it.

 

Hope you understand.

 

thank you 🙂

0 Kudos
Message 3 of 8
(3,690 Views)

I hope it's understandable...

 

The thing is: I run the program. The program sends to the event structure the Relative value A  [I dont see that as a user].

As a user I write a value B on the front panel, then press move forward fon instance. But the event structure executes it with the previous A Relative value, because it was already sent at the entrance point of the event structure. Then I write the value C, press move, and it moves to B, then I write D and it moves to C... and so on.

0 Kudos
Message 4 of 8
(3,687 Views)

Hi tinocasals,

 

Here is an example program. It may not be exactly what you need, but the ideas may be helpful.

 

One thing to keep in mind is that you don't need to create an event for a control if you are not going to do something based on that event. So if you only perform an action when the buttons are pushed, just read the values of the controls in the button event.

 

 

steve

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 5 of 8
(3,669 Views)
Note that in the above example the Stop button should be handled by an event case. Otherwise, the stop will only occur if you press another control after pressing the Stop button.
0 Kudos
Message 6 of 8
(3,648 Views)

Could you please attach an image? I can't open this vi because of my older LV version

 

[How can I give kudos to the people who helps me? I don't know, but I would like to be grateful with you :)]

0 Kudos
Message 7 of 8
(3,631 Views)

I hope you can open this version saved in LV 7.1. Unfortunately I don't have 7.1 on my system so I could not look at it (I saved it from LV 8.0). Let me know if you have trouble with it.

 

This was easier than adding multiple images and maybe more useful to you.

 

Thanks to smercurio_fc for mentioning the stop button issue. I added an event for it in this version.

 

Feel free to ask questions if needed.

 

steve

 

 

(about Kudos - just click on the yellow kudo button to give one when deserved - can't kudo yourself though :))

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 8 of 8
(3,611 Views)