LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Thorlabs rotation stage control using LabWindows

Hi there

 

I have been trying to program automated control of Thorlabs rotation stage PRM1Z8 based on TDC001 DC servo controller using Lab Windows Actives Controller Wizard.

 

The steps followed by me as follows:

 

1. Insert Activex control (thorlabs stage GUI) in the panel using .ocx file obtained with the stage. Edit the control properties to put in the controller serial number and then right click on the control to generate the activex control driver. 

 

The following code was written. Although I do not obtain any compiling error, I have not managed to communicate with the stage. 

#include "MG17Motor.h"		
#include "AProt.h" 
#include <cvirte.h>		
#include <userint.h>

static HRESULT _tmp8;
static long _tmp9;


static HRESULT _tmp3;
static long _tmp4;

static int _tmp2;
static CAObjHandle _tmp1;


static int panelHandle;


int main (int argc, char *argv[])
{
	if (InitCVIRTE (0, argv, 0) == 0)
		return -1;	/* out of memory */
	if ((panelHandle = LoadPanel (0, "AProt.uir", PANEL)) < 0)
		return -1;
 
 DisplayPanel (panelHandle); 

 RunUserInterface (); 
	 

	DiscardPanel (panelHandle);  
	

  
	return 0;
}



 
int CVICALLBACK imagepanel (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
switch(event)
{
	case EVENT_COMMIT:

_tmp2 = GetObjHandleFromActiveXCtrl(panelHandle, 2, &_tmp1);    


	
_tmp3 = MG17MotorLib__DMG17MotorStartCtrl (_tmp2, NULL, &_tmp4);

_tmp8 = MG17MotorLib__DMG17MotorIdentify (_tmp2, NULL, &_tmp9);

 break;
}
	return 0;
}

 Please could you help me sort out any programming error that I might have committed here. 

 

Thanks

Deepa

0 Kudos
Message 1 of 2
(3,849 Views)

Hello Deepa,

I never used Thorlabs products, but as you can see in the online help for the command, GetObjHandleFromActiveXCtrl returns the obtained handle into the last parameter, in your case _tmp1; I suppose this is the variable you must pass to the following command(s) in the Thorlabs library. The return value _tmp2 is an error code which you should use to add some error checking to your code.

You should also check into Thorlabs documentation the exact meaning and usage of the command you are using: it is possible that the return values are error codes that may give you some guidance on how to clean up any error you may have in function calls.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 2
(3,841 Views)