LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read position in real time for Thorlabs

Solved!
Go to solution

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

0 Kudos
Message 1 of 12
(4,095 Views)
Solution
Accepted by Sman29

Simple solution, make a seperate loop to read the position and update the display.



-Matt
Message 2 of 12
(4,077 Views)

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

0 Kudos
Message 3 of 12
(4,074 Views)

Place the loop outside the main loop.



-Matt
Message 4 of 12
(4,072 Views)

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":

Error.JPG

 

Thanks,

SM

0 Kudos
Message 5 of 12
(4,067 Views)

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?



-Matt
Message 6 of 12
(4,060 Views)

Matt,

 

Please see attached for updated VI.


Thanks,

SM

0 Kudos
Message 7 of 12
(4,057 Views)

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

0 Kudos
Message 8 of 12
(4,055 Views)

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.



-Matt
Message 9 of 12
(4,051 Views)

: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

0 Kudos
Message 10 of 12
(4,049 Views)