LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling Piezo Actuator with LabVIEW

Solved!
Go to solution

Hi all,

I'm having a problem interfacing my Thorlabs MDT693b controller with labview using NI-VISA commands. I've attached my subVI that talks to the controller for your reference. 

 

subVI purpose: essentially I give the program a location i want the translation stage to move to and this will give the serial commands to the piezo controller. it has a "closed loop" implementation but the functionality is simple. 

 

integration: I have the subVI integrated into a simple for loop in my main application that incrementally steps the translation stage

 

what works: I give the command to move to one location and it moves there. no errors

 

what isnt working: for some reason the time interval between movements slows down as the program goes on. it starts out with ~ 500ms between movements (which is about right considering the two 200ms wait functions in the subVI), but escalates up to as bad as 2s.

 

Things I've tried:

1) Movements remain quick when using the Thorlabs control software separate from labview.
2) If you stop the labview routine properly, then click run to restart the VI, the movements remain just as slow as before the program was ended.
3) If you go one step further and fully quit labview and restart it, movements become quick again (but then starts to bog down as usual).

The hardware seems to be working fine but something weird is happening inside the subVI causing the loop to slow down.

Any help is much appreciated!

- Luke

0 Kudos
Message 1 of 3
(4,241 Views)
Solution
Accepted by topic author Gaztick

integration: I have the subVI integrated into a simple for loop in my main application that incrementally steps the translation stage


Could you provide this simple loop VI as well? The subVI you attached, you are opening and closing the VISA session. If you call this a loop then we you will be opening and closing the session repeatedly. Generally it's good practice to open a session, then in a loop do all the read/write operations you want, then exit the loop and close the session. 

 

Just guessing here, but the slow down might be caused by a memory leak. Taking a look at the overall VI with the loop would help to see what could be happening.

dK
Message 2 of 3
(4,213 Views)

@sirknoxalot thanks for your response! 

1) I agree with you that the session should be opened and closed just once. The reason I'm doing this is during the code development stage sometimes I get an error in the middle of my routine and the visa reference does not close. I'll implement this in for sure at the end but for now I need to have it this way. 

2) It turns out my slow down actually came from a shift register, turns out its a lot faster to store arrays into a local variable at the end of the loop and read it at the beginning. 

0 Kudos
Message 3 of 3
(4,191 Views)