09-04-2015 08:17 AM
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!
09-07-2015 01:57 AM
nobody?
09-07-2015 03:25 AM - edited 09-07-2015 03:26 AM
There are two obvious problems I see here:
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:
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).
09-07-2015 09:33 AM
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 ?
09-07-2015 10:26 AM
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.