11-16-2016 11:19 AM
Hello,
I am using LabVIEW 2013 to control a Thorlabs controller (KDC101/K-Cube). Right now the controller is moving a single axis stage. Attached is my VI's. The VI called "test .net.vi" is my main VI. Right now, everything works how I want it to. however, while the stage is moving, the program kind of "blocks", meaning that it cannot perform any other actions while it is moving the stage. I need to read and display the "Current Position" in real time and update, say 4 times a second. Does anyone have any ideas for this?
Thanks in advance for any help!
SM
Solved! Go to Solution.
11-16-2016 11:40 AM
Simple solution, make a seperate loop to read the position and update the display.
11-16-2016 11:43 AM
Hello Matt,
I tried doing that (inside the main WHILE loop) and all it would do was sit there reading the position, it wouldn't go outside and do anything else?
Thanks,
SM
11-16-2016 11:44 AM
Place the loop outside the main loop.
11-16-2016 11:48 AM - edited 11-16-2016 11:52 AM
Tried that and it will not go into that loop that gets the position... Any other ideas?
EDIT: I also get this error when having a seperate loop outside the main loop and then I press "Stop":
Thanks,
SM
11-16-2016 11:58 AM
I briefly looked at your example, but i believe i understand the problem now. I think that error is created because you try to read the position before the device is connected, an assumption based on the error you gave. Use data flow to make sure your read loop doesnt iterate before the second loop. Also you need that get position VI inside the second loop. Can you provide your new code?
11-16-2016 12:00 PM
Matt,
Please see attached for updated VI.
Thanks,
SM
11-16-2016 12:03 PM - edited 11-16-2016 12:04 PM
Also I just noticed, while the stage is moving, the Stop button (or any other button) will not work. What can I do about that?
Thanks,
SM
11-16-2016 12:10 PM
To fix the read position, you have a wire coming from your main loop to the read loop, that data will not pass from the main loop into the read loop until the main loop exits, thats why it is not reading. Delete that wire and replace it with the same wire, but grab the wire outside the main loop, between the servo control and the main while loop.
I have not worked with this controller before, but it seems it will hold data flow there until motion is complete. You may have to rethink architecture at this point and find a way to abort that motion if stop is pushed. Sometimes controllers like this have a next option, so that the controller does not wait until position is reached before moving forward in the program. You may want to look into that.
If there is a way to abort motion, you may be able to use a QMH, you can search on NIs website for this and there should be a template built in. You can then monitior the controls and if stop is pushed you can abort motion and move forward in the program.
11-16-2016 12:15 PM
:To fix the read position, you have a wire coming from your main loop to the read loop, that data will not pass from the main loop into the read loop until the main loop exits, thats why it is not reading. Delete that wire and replace it with the same wire, but grab the wire outside the main loop, between the servo control and the main while loop."
I tried that already too, still didn't pass any data and still pops up that error... Any other ideas?
"I have not worked with this controller before, but it seems it will hold data flow there until motion is complete. You may have to rethink architecture at this point and find a way to abort that motion if stop is pushed. Sometimes controllers like this have a next option, so that the controller does not wait until position is reached before moving forward in the program. You may want to look into that.
If there is a way to abort motion, you may be able to use a QMH, you can search on NIs website for this and there should be a template built in. You can then monitior the controls and if stop is pushed you can abort motion and move forward in the program."
I will look into it.
Thanks,
SM