LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

menu ring + property node to control devices to be opened

Hello!

I am trying to open 3 controllers that move in the 3 spatial directions:

1-get controllers'names

2-asign ctrlr1 to ox, ctrlr2 to oy, ctrlr3 to oz or any other combination which is why I am using the menu ring

3-open devices, get positions, close

What I have tried does not work and I can't fix it because I don't know what is wrong : I want the position to be read from the device only after I pressed the 'get' button, then use that information to command the motion and so on. But I don't receive any information in the way it is set right now.

Please help!nogood.jpg

 

0 Kudos
Message 1 of 5
(3,207 Views)

nobody?

0 Kudos
Message 2 of 5
(3,168 Views)

There are two obvious problems I see here:

 

  1. You're setting the value of the rings in parallel to the loop, so there's no guaratee it will happen before the loop runs.
  2. You're reading the value of the ring outside the event structure. That means that when the event actually happens, the value on the string wire was already set. You should be able to see this in your string indicators and it will also be made more clear if you turn on highlight execution and run the VI.

The second issue is most likely your problem and it's a basic cornerstone of dataflow, so you should get comfortable with it. The most simple solution to your issue is probably to add a timeout event so that the loop keeps iterating and you read updated values, but the more correct solution is to read the rings only inside the event case, and then they will be read only when you press get.

 

There are other issues with this code that I don't have time to address, but here are some comments:

 

  1. When possible, don't use the value property to read the value. Use the terminal.
  2. If you're indexing, I32 is a better type for the ring to avoid coercions.
  3. You should place the get terminal inside the event case, because latching boolean terminals are reset when they read in the code.
  4. You don't need a wait if you have the event structure.

 

Read up on event structures. Jack Dunaway had a good presentation on events and there's video of it here - https://lavag.org/topic/16091-ni-week-2012-videos (follow the FTP login instructions and look at the NIWeek 2013 presentations).


___________________
Try to take over the world!
0 Kudos
Message 3 of 5
(3,149 Views)

Thank you very much for the reply, tst !

I am glad you brought up the index array problem; what I want to do is the following:

-get the motors' names to fill the text ring in order 0,1,2;

-asign the motor I want to the corresponding axis 1=ox,2=oy,0=oz 

and this asignment remains until the while loop stops.

The reason I am commanding the array index with the value of the menu ring is : I don't know how to do it otherwise.

At the output of the menu ring I put an indicator and it shows the characters corresponding to the controllers'names instead of a number indicating the position of that name in the list.

I have modified the vi and now it works but the indicators outside the event only keep the position value for as long as the timer dictates 1s; after that the readings go back to zero. Is there a way to make the output keep its last value? 

I used a timeout because the while loop would not stop as the event structure was probably preventing from doing so because it was waiting for a status change indefinitely

.How do I asign to the timeout event the last value of the readout event:

the vi reads: 800,1600,0 the current positions , stops, and when it goes to timeout case, instead of outputing 0,0,0 it outputs the last values read 800,1600,0 ?

stop.jpg 

0 Kudos
Message 4 of 5
(3,127 Views)

no need for timeout case: just add an event and put the STOP button inside of it(as seen in this video: https://www.youtube.com/watch?v=eGlvOiqYVxg ) , then tie it to the while loop stop.

perfect.

0 Kudos
Message 5 of 5
(3,112 Views)