LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2D raster scan thorlabs KDC101

Solved!
Go to solution

Hi all,

 

So I'm newbie here in Labview world but I'm wondering is there anyone who has been done or could help with 2D stepped raster scanner with 2x Thorlabs KDC101 brushed motor controller and 2x Thorlabs translation stages MTS50/M-Z8? I wanted to generate scanner which scans 

 

I'm using Windows 11, Thorlabs Kinesis software and communicating with motor controllers via USB ports.

 

I saw the C# example for the same example in Youtube made by Thorlabs itself, but I cannot implement that on Labview same way. Here is the link for that: https://github.com/Thorlabs/Motion_Control_Examples/blob/main/C%23/Benchtop/BBD302_Raster_Scan/Progr...

 

Also here is my current code snapshot...

0 Kudos
Message 1 of 8
(1,195 Views)

Seems like a part of my text is missing...I meant to say that I want to make a scanner that scans every column in the first row of the matrix, then moves on to the next row. So the idea is to take a certain step forward in the x-direction, stop for a short time, and continue after that.

 

So the input would be the step length, the number of columns (number of steps taken), and the number of rows. This is used to scan for example 5 mm x 5 mm area as fast as possible.

 

0 Kudos
Message 2 of 8
(1,168 Views)

@markutol wrote:

I saw the C# example for the same example in Youtube made by Thorlabs itself, but I cannot implement that on Labview same way.


Why not? I haven't worked with those specific Thorlabs devices, but I assume you have the BenchtopBrushlessMotor class, which can allow you to create what you need? I'm not surprised to see that the code has nested for loops, where you move to the next Y and then within that row move to the X values.

 

Working with .NET code in LV can be cumbersome, but I would also suggest creating VIs, particularly for reusable functions (you can write the code and then select it and select Edit>>Create SubVI).


___________________
Try to take over the world!
0 Kudos
Message 3 of 8
(1,141 Views)

So here is my current version of that code which I said to be done. It still doesn't work properly, but I'd like to get suggestions on how to handle the change in engine direction and how to get the engine direction information.

 

I also put in some C# code (.txt file) that I made that will help to move the motor in the desired direction. I would still like the motors to be controlled via labview...

Download All
0 Kudos
Message 4 of 8
(1,123 Views)

Well, for one thing, your C# code and the Thorlabs example code don't match what you have in your LV code. Each of them uses different classes and methods, at least for the initialization.

 

If you want to call a .NET constructor in LV, you need to use the Constructor Node. That said, I would suggest that you actually stick to using the UI control, because my experience with using the Thorlabs .NET code was that it was possible not to use the UI control as the basis for the connection, but that it wasn't very stable. I'm assuming that even though the classes are different, you would still have the methods you need.

 

Another thing which was a pain was that you need to take all of the Thorlabs DLLs and place them in the folder of your LV project (or EXE when you build that) for this to work. They have a tool which is supposed to copy just the DLLs that you need for your specific device, but as far as I could tell, that doesn't actually work.

 

I don't have the right stuff installed, so I can't see all of the details for your code, but I see that you do have a direction input on the MoveJog method. If you create a constant from that, LV should translate it correctly from the .NET enum to a LabVIEW ring control with the relevant values. I'm not sure why you wired 60000 to it.

 

As for how to handle the direction change, in LV the wires usually fill the rows of variables and you can add a shift register to a loop to pass values to the next iteration, but I would suggest just looking at the value of the loop iteration terminal. Feed it into a Quotient and Remainder primitive to divide by 2 and then you can check if the remainder output = 0 and use a Select primitive to output either FW or BW as the direction.

 

 


___________________
Try to take over the world!
0 Kudos
Message 5 of 8
(1,111 Views)

Okay, thanks for the help in direction handling! I have to say that I just need to practice using the construction nodes to get proper control of the translation stages.

 

But as far as specifying the MoveJog invoke node, I already enter a constant as input for the direction, which I can specify as either forward or backward enum. The constant 60000 is just an input for the waitTimeOut.

 

 

0 Kudos
Message 6 of 8
(1,106 Views)

@tst wrote:

 

I don't have the right stuff installed ... but I see that you do have a direction input on the MoveJog method. ... I'm not sure why you wired 60000 to it.

 Looks like this is a bug in LV. If you don't have the relevant DLLs installed, it looks like LV shows the method name twice and then pushes all of the other parameters one row down, causing a shift in which value is wired into which parameter.

 

Anyway, like I said, working with the Thorlabs API can be tricky, so I would suggest taking it in small steps (such as setting up a UI to manually invoke the movements) to make sure you can get the functionality you want before implementing all the logic. Also make sure you can build a functional EXE if that's your goal.


___________________
Try to take over the world!
0 Kudos
Message 7 of 8
(1,066 Views)
Solution
Accepted by markutol

Thanks for your answers! I managed to solve it by myself and little bit struggling in the beginning. So here is my current code which is working pretty good, and it's pretty precise.

 

Hopefully it's useful for someone who is thinking the same procedure.

0 Kudos
Message 8 of 8
(1,056 Views)