MGMotor XOP

Hi 

Is the MGMotor XOP still running under Igor 8 ? If not, is there any other XOP for controlling Thorlabs translation stages?

Cheers

Silvan

Howard was just recently interacting with a customer about this XOP. He has updated the XOP to run with the 64-bit Igor64.exe application. You can download the new version from https://www.wavemetrics.net/Downloads/FTP_Archive/IgorXOPToolkit/Exampl…. I think we're relying on the customer to test the XOP since we don't have the hardware, but the customer reported that it still worked well for whatever hardware they were using.

MGMotor was originally written in 2008 in Visual C++ 2005 for 32-bit Igor only. I just uploaded a new archive that includes a 64-bit version as well as a 32-bit version compiled in Visual C++ 2008 and also includes the MGMotorMoveJog contributed by Hiroyuki Yoshida. We don't have any Thorlabs hardware so these new XOPs have not been tested.

The Visual C++ 2008 project is available here.

 

 

I have verified that the new XOP works with a BSC202 stepper motor controller with two NRT type stages.  Although, I haven't tested it extensively, I had no problems.  The biggest drawback for my use is that it seems to be able to control only one stage at a time.  Several commands take a channel parameter to indicate which stage to address, however this does not appear to be implemented in the current version.

Several commands take a channel parameter to indicate which stage to address, however this does not appear to be implemented in the current version.

I'm not sure if "does not appear to be implemented in the current version" refers to the current version of the XOP or the current version of the BSC202 stepper motor controller.

The source code for the XOP is available from the link in the post above from July 13, 2022.

The channelID parameter is just passed by the XOP to the Thorlabs ActiveX control. For example:

int
MGMotorMoveAbsolute(MoveAbsoluteParams* p)
{
    CMgmotorctrl1* pMotor;
    long mgResult;
    int err;

    // This is needed in every XOP function that can be called directly from Igor.
    AFX_MANAGE_STATE(AfxGetStaticModuleState());    // For MFC XOPs only.

    p->result = 0;

    if (err = MGGetMotorControlObject(&pMotor))
        return err;

    mgResult = pMotor->MoveAbsolute(p->channelID, p->wait);
    p->result = mgResult;

    return 0;
}

So if the channelID parameter is not working, I don't think there is anything I can do about it.

Perhaps ask Thorlabs about it.

Hello Howard,

My comment referred to the XOP.  However, I was confused.  After further testing with the 2ch simulator, I see the channel parameter does select which channel/stage to affect and both channels are shown in the ActiveX control window.

My controller (BSC202) is a single box with two cards for two stages.  However, in Thorlabs APT User application it appears as two separate controllers (see attached image).  Is it possible in MGMotor XOP to instantiate two controller windows at the same time?

BSC2002 in APT user

Is it possible in MGMotor XOP to instantiate two controller windows at the same time?

My guess is that it is possible. I'm not sure that I can do it given that I don't have the hardware and have only a superficial understanding of the underlying software framework (MFC).

I get compile errors when I try to compile the MGMotor XOP with Visual C++ 2015. I compiled it in July with Visual C++ 2008 but I don't have access to the machine with VC2008 right now.

Also, I don't see from relevant header file (mgmotorctl1.h which is in the project linked above) how to choose which card the software is supposed to control. Is the choice of card done via the user interface?

 

In reply to by hrodstein

Also, I don't see from relevant header file (mgmotorctl1.h which is in the project linked above) how to choose which card the software is supposed to control. Is the choice of card done via the user interface?

I'm not certain how to answer this.  When APT user runs, it seems to query the USB for controllers and create the GUI depending on the controllers that were found.  In the Igor XOP,  mgmotorSetHWSerialNum(SerialNumber) is used to set the active controller.  

This example MATLAB code may help (I found it on the ThorLabs website.):

%% Create ActiveX Controller
h = actxcontrol('MGMOTOR.MGMotorCtrl.1',[20 20 600 400 ], f);
 
%% Initialize
% Start Control
h.StartCtrl;
 
% Set the Serial Number
SN = 45822682; % put in the serial number of the hardware
set(h,'HWSerialNum', SN);

% Indentify the device
h.Identify;
 
pause(5); % waiting for the GUI to load up;
%% Controlling the Hardware
%h.MoveHome(0,0); % Home the stage. First 0 is the channel ID (channel 1)
                 % second 0 is to move immediately

It seems like they get a handle for the ActiveX control, set its serial number and use methods on the handle to run the controller.

I'm only faintly acquainted with MATLAB programming and I haven't programmed C++ (I did program in C a long time ago.), so I'm not if this answers your question.

The XOP does implement a MGMotorSetHWSerialNum function. This section:

DisplayHelpTopic "MGMotor XOP[Getting Started]"

talks about how to use it.

Possibly this would allow you to set which motor controller you are controlling.

 

Hi Howard,

I had tested MGMotorSetHWSerialNum & it does work.  I haven't done much testing on this, but it seems cumbersome to switch between two devices (for example, to control xy travel with two stages) by changing the MGMotor window's active serial number .  So this gets back to my desire to instantiate two MGMotor windows each addressing a different device.  I don't have much experience with C++, but will take a look at the XOP source code.

I managed to get the XOP to compile under Visual C++ 2022 Community Edition by adding MFC to my VC2022 installation.

After that I had to fix a bunch of errors and warnings.

I then I downloaded and installed  "APT 64-Bit Software for 64-Bit Windows" version 3.21.6 from the Thorlabs download page.

I then restarted my machine though this may not be necessary.

Now I can execute:

MGMotorCreateWindow()
MGMotorShowWindow()

and the "MG Motor Control" window appears.

So that's a lot of progress but whether I can support multiple MG Motor windows is still unknown. I will continue looking into it.

 

Thank you for working on this!  I will be happy to test it on my hardware when your XOP is ready.  By the way the link that you posted to ThorLabs gives a page not found error on WaveMetrics.com.

By the way the link that you posted to ThorLabs gives a page not found error on WaveMetrics.com.

Fixed. It was missing "https:\\".

 

I have created a new MGMotor2 XOP that allows you to create multiple MGMotor windows and to control multiple Thorlabs cards. You can download it here.

Since I don't have Thorlabs hardware, I have not thoroughly tested the MGMotor2 XOP.

See the "MGMotor2 Help" file for details. If you used the original MGMotor XOP, see the section "Differences Between MGMotor and MGMotor2" in the help file.

 

Works fine with a simulation with two controllers.  Thank you!  I will be in the lab later this week to test with hardware.

I noticed that the example code in the command help shows "MGMotor2KillWindow("MG Motor 1")" as the example for MGMotor2AboutBox function. 

Howard,

I tested all the functions in the new XOP this afternoon using my BSC202 controller with 2 stages.  No problems to report.  The revised code to permit instantiating two controllers worked fine.  Thank you for your effort on this!