2

I'm trying to control a Thorlabs APT ActiveX motor through PyQT4. Here is the simplest version of my initialized class, inspired by code from here and here.

import sys

import comtypes.gen.MG17MotorLib as APTMotorLib

from PyQt4 import QtGui
from PyQt4 import QAxContainer

channel1 = APTMotorLib.CHAN1_ID

class APTMotor(QAxContainer.QAxWidget):
    def __init__(self, parent):
        self.parent = parent
        super(APTMotor, self).__init__()
        self.setControl('MGMOTOR.MGMotorCtrl.1')
        #motor specific initialization
        self.SetHWSerialNum(my_serial_number)
        self.StartCtrl()
        self.EnableHWChannel(chanel1)

app = QtGui.QApplication(sys.argv)
motor = APTMotor(app)

My motor object works in many respects. For example, all of the following return the values that I expect.

motor.GetStageAxisInfo_MinPos(channel1)
motor.GetStageAxisInfo_MaxPos(channel1)
motor.GetPosition_Position(channel1)
motor.GetStatusBits_Bits(channel1)

However, passing arguments into the methods of my motor object doesn't quite work properly. For example, consider the method MoveAbsoluteEx(int lChanID, double fAbsPosCh1, double fAbsPosCh2, bool bWait);.

I can call motor.MoveAbsoluteEx(channel1, destination, 0., True) without error (my motor does not have a channel2). In fact the motor does move. The problem is that, no matter the value of destination, my motor always moves to zero mm.

I know from the APT event log that the command being sent actually is zero. The relevant output is CMGMotorCtrl::MoveAbsoluteEx(0,0.0000,0.0000,1). The integers are correct (and change when I change the python variables), but the floats are always passed as zero.

Community
  • 1
  • 1
untzag
  • 21
  • 2

0 Answers0