Showing results for 
Search instead for 
Did you mean: 

Move motor and make a measurement (thorlabs motors and drivers)

Go to solution

Hi everybody, 


I was just born in this Labview  world and I´m quite lost. I´ll explain my situation: 


I have three motors from thorlabs (T-cube Stepper Motor controller) in three directions (x, y and z). What I need is to move the motors from initial position until final position in small steps in order to make measurements in every stop (this is other story). So, the thing is I need to measure one line in x stopping wherever I need, then come back to the initial point, go one line down in y axis and start the line in x again (as many times as neccesary). I think a state machine is what I need for this purpose, but I have no idea. 
Could anyone help me with this??
NOTE: the computer is an old xp without internet conection and there is no possibility to install labview packages as NI-DAQmx so I must use the motors nodes and properties that Thorlabs provides. 
Thank you very much!!!
0 Kudos
Message 1 of 10

If you just need something quick to get the job done, you could use nested for loops. Although, you are correct in that a state machine would be better.


Move X, Y, and Z will each be an individual state, with the measurement being yet another.  The positions (controlled in absolute instead of relative) can be passed to each state inside a queue.  I say to use absolute since it makes returning to home easier (don't have to keep track of how far you've moved).  Since i've not used the T-cubes before, i'm not sure if this is possible but it should be.


You'll want to store your data in an array (2D array) which can be used to make a graph or save (txt and csv files are easy to create for transfering data elsewhere)

0 Kudos
Message 2 of 10

Thank you pjr1121! Finally I got it. Next step is how to make measurement in every stop using a 2400 Keithley Sourcemeter, but this will be another post 😉 


Attached you can find the .vi (I´m sure is not that professional, but it works!! )



0 Kudos
Message 3 of 10

There are quite a few posts on these forums about the Keithley 2400 so there is plenty of material to look through.  Also, their manual is extremely well documented

0 Kudos
Message 4 of 10

Thanks again!! 😉 I must fight with Labview, but I´ll be able to get what I need Smiley Happy


I´ll check the examples and try to understand them!! 

0 Kudos
Message 5 of 10

Hi again, 


I got motors movement and IV measurement. Although is not a really clean code it works for the purpose it is wanted (attached).


My doubt now is: I need to save all the measurement data in a file (text file for example). When I run the program I got a text file with just one measurement, how could I get all the measurements? using a loop? I´ve been thinking but I do not know how to implement this when using a state machine. Any ideas?


Thanks in advance!


0 Kudos
Message 6 of 10

Hello again, 


finally I got (more or less) what I wanted (the IV in the previous post). However, I did this VI using times to wait before and after the measurement for example. Does anyone know how to improve this kind of thing? The idea would be that instead of having a time that I introduce manually, the VI should know when start the next step in my state machine (being sure that the measurement was properly taken and save). 


I´ve been thinking in time loops, but I wouldn´t like to change the state machine shape. 


Thanks in advance


Smiley Wink

0 Kudos
Message 7 of 10
Accepted by topic author lacorgui

Times to wait BEFORE a measurement is started is something you have to do manually since it's up to the user.


As far as how long to wait for the measurement to complete, the manual has examples of using registers and buffers to find out when the measurement is complete using a linear sweep (this is how I do it).  The idea is to pre-set the buffer equal to the number of datapoints (say 100 over your IV range), instruct what to measure (current, voltage, both), and poll the registers to find out when the buffer is full (say every 100-500 ms).  Let the keithley 2400 set the voltages for you over the specified range and return the data set when completed.


As far as knowing when the movement is complete, you'll have to see if there is a way to detect that with your equipment (otherwise stick with the pre-programed delay).  IF these are illuminated IV measurements, you could do the following.  Source ZERO volts and measure current.  check periodically after the movement commands are sent.  Once you measure a current, the Jsc for the cell, you have contact.


For data storage, use shift registers on the state machine itself.  Clear the register when starting a scan, and insert each measurement as it is taken (2D array, or array of clusters).  Another possibility is to use a separate while loop to save the data (a consumer) with the data being passed in a Queue and appended to file after each scan (this will help if you are concerned about failures resulting in lost data).  After each measurement, enqueue the data into a queue handled by this consumer.  (you'll need to keep track of which file to append data to).



Message 8 of 10

Thanks pjr1121. You know a lot, my friend!! I´ll do what you say! 

0 Kudos
Message 9 of 10

I had built a similar system before, but instead of xyz motors, i used multiple pins with a multiplexer built out of relays.

0 Kudos
Message 10 of 10