Code Monkey home page Code Monkey logo

pyapt's Introduction

**APT is being replaced by kinesis. Please use Instrumental with Kinesis **

PyAPT

Controlling Thorlabs APT using Python code using APT.dll and APT.lib, bypassing the activex controls. It even comes with a simple GUI!

Installation

Obtain APT.dll and APT.lib from Thorlabs directly, or from the APTDLLPack/DLL/ folder, picking the correct version (x86 or x64) Place APT.dll, APT.lib and PyAPT.py in the folder from which the scripts will be executed, or in the main add-on folder for python. You also require ThorlabsAPT software (obtainable from ThorLabs APT Software page )

Running the code

Ensure correct version (32 or 64 bit) APT.dll and APT.lib are in the folder containing the python script. Example.py contains an example of how to load the module, control the motor, and close the object.

Using the GUI

GUI is implemented using QT. First enter the serial number, and press the connect button. The GUI will attempt to connect to the APT motor, and probe for it's current position and velocity. If sucessfull, those values will be updated in the respective boxes. Pushbuttons under the position box are for movement in microns.

Support

PyAPT Supports the following motors:

Motor HWTYPE Description
BSC001 11 1 Ch benchtop stepper driver
BSC101 12 1 Ch benchtop stepper driver
BSC002 13 2 Ch benchtop stepper driver
BDC101 14 1 Ch benchtop DC servo driver
SCC001 21 1 Ch stepper driver card (used within BSC102,103 units)
DCC001 22 1 Ch DC servo driver card (used within BDC102,103 units)
ODC001 24 1 Ch DC servo driver cube
OST001 25 1 Ch stepper driver cube
MST601 26 2 Ch modular stepper driver module
TST001 29 1 Ch Stepper driver T-Cube
TDC001 31 1 Ch DC servo driver T-Cube
LTSXXX 42 LTS300/LTS150 Long Travel Integrated Driver/Stages
L490MZ 43 L490MZ Integrated Driver/Labjack
BBD10X 44 1/2/3 Ch benchtop brushless DC servo driver

I have no idea if it supports the KDC101. If you try it out and it does, please let me know so I can update it for others.

References

ThorLabs APT Software page ThorLabs APT Documentation page

Contact

This is still a rough copy that I am improving as I work on my project. Please report any bugs, and feel free to let me know of any comments or suggestions. Please report bugs and questions by creating an issues That way, others can see your questions and contribute to them too. Even better: make the changes and push them back to me!

Michael Leung

pyapt's People

Contributors

burggraaff avatar danielhampf avatar mbiskach avatar mcleu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyapt's Issues

Jog up/down function

Hi Michael,

Thanks for developing this Python wrapper for Thorlabs APT! I am trying to adapt it for a Thorlabs TDC 001 step motor in my instrument (I forked your repository using the account @Huanglab-ucsf last week ). The moving functions worked very well, but I found that there is no jogging function, which is crucial for my experiment. I tried to add it by calling self.aptdll.MOT_MoveJog(self.SerialNum, c_int()) but failed. It seems the library does have the MOT_MoveJog function, but I did not have the correct input. I was wondering if you have attempted to add a similar function and what arguments should be fed to it. Thanks!

Best,
Dan

DLL not found

Hi! Michael

First, thank you for developing this package. I was trying to run it after putting the dll and lib files in the same folder. I ran the following command

from PyAPT import APTMotor
Motor1 = APTMotor(83861368, HWTYPE=31)

and get error message like the following:

`ERROR: DLL not found

WindowsError Traceback (most recent call last)
in ()
1 from PyAPT import APTMotor
2 import time
----> 3 Motor1 = APTMotor(83861368, HWTYPE=31)

C:\Users\M-LAB\Desktop\TGS Python\pyAPT\PyAPT.py in init(self, SerialNum, HWTYPE, verbose)
47 if not os.path.exists(dllname):
48 print "ERROR: DLL not found"
---> 49 self.aptdll = windll.LoadLibrary(dllname)
50 self.aptdll.EnableEventDlg(True)
51 self.aptdll.APTInit()

C:\Anaconda2\lib\ctypes__init__.pyc in LoadLibrary(self, name)
441
442 def LoadLibrary(self, name):
--> 443 return self._dlltype(name)
444
445 cdll = LibraryLoader(CDLL)

C:\Anaconda2\lib\ctypes__init__.pyc in init(self, name, mode, handle, use_errno, use_last_error)
363
364 if handle is None:
--> 365 self._handle = _dlopen(self._name, mode)
366 else:
367 self._handle = handle

WindowsError: [Error 126] The specified module could not be found`

I am pretty sure I put the dll in the same directory, do you have any idea what might be wrong?

Thank you

Fwd Hardware - How to check if hardware is connected?

In the original APT software, there is an LED indicator that shows whether the hardware is connected to the controller or not. How do I implement the same here? Motor.initializeHardwareDevice() is not throwing any error even when there is no hardware connected to the specified controller.
(I'm using the Thorlabs FW103S filter wheels connected to a TCH001 T cube controller, which has individual TST001 controller units.)

PyAPT.py calls self.config.get_pitch even though self.config is not defined

In line 129 under the setStageAxisInformation() function variable pitch is set to equal c_float(self.config.get_pitch()) and it falls on "self.config is not defined". indeed self.config is nowhere to be found in the code. Is there a way to bypass that/set the axis information.
I'll keep looking for a way and update if i find something.

    def setStageAxisInformation(self, minimumPosition, maximumPosition):
        minimumPosition = c_float(minimumPosition)
        maximumPosition = c_float(maximumPosition)
        units = c_long(1) #units of mm
        # Get different pitches of lead screw for moving stages for different stages.
        **pitch = c_float(self.config.get_pitch())**
        self.aptdll.MOT_SetStageAxisInfo(self.SerialNum, minimumPosition, maximumPosition, units, pitch)
        return True

self.aptdll.APTInit() bug

Hi, I used the pyapt.py to control the stage, but when it ran through self.aptdll.APTInit() something was wrong, I couldn't figure out the reason. Can anyone help me? Thanks.

tpz001?

Thanks for the good work,

I was wandering it is possible to control a piezo cube controller TPZ001 with this wrapper?
Hardwaretype is 30.
System Level Exports command as GetHWInfo or APTInit work fine but no Specific Exports for piezo controller seems to exist in the apt.dll or APTAPI.h

Maxime

Cannot move backwards

Hi,
I'm using two NRT100/M stages with controller BSC202 (1ch driver card is SCC001, hwtype = 21).
I'm able to move my stage in the forward direction but it doesn't respond to any backwards moving commands including go_home. I tried different sets of home parameters but none of them helped.
I was wondering if you might know what I've missed to get it work?
Thanks.

go_home function error

I came across an error with the go_home() function. The problem is that when go_home() function is executed the program crashes with the following error message:

c:\PyAPT.pyc in go_home(self)
292 raise Exception('Please connect first! Use initializeHardwareDevice')
293 if self.verbose: print 'go_home SUCESS'
--> 294 self.aptdll.MOT_MoveHome(self.SerialNum)
295 return True
296

Any suggestion on how to solve this issue?

HW #40

How would I be able to get this to work for a hardware # of 40? I know it's not on the list but this seems like it might be the only way I can control it

"At Rev Limit" can't move back

I am getting error on the display "At Rev Limit" and it can't move back (KDC 101 Motor with Z812B stage).
I must admit that initially when i started my work (2 months back) I was able to move it back, but now I have many more features to my GUI ( I need to do other stuff too) and it doesn't go back!

Can anyone help?

Use in MATLAB

I am trying to interface with a MFF 101/102 Motorized flipper in MATLAB 2015bx32, and I was wondering where the header file for this library is and if you have a 32-bit version of the library.

I am a novice coder, so please excuse any ignorance in the above question. That being said, I would also love any suggestions you might have. All I need to do is get the motor to change positions.

Old DLL not compatible with KDC101

In principle the code seems to work fine with the Thorlabs Kinesis KDC101 controller using HWTYPE=31. However, only after replacing the DLL (APT.dll and APT.lib) with copies of the latest one from Thorlabs (found in the folders of the Thorlabs APT software after installing it or here APTDLL.zip ).

Triggering

This wrapper is great! Thanks for taking the time to do this.

I have one concern though. In my project, I am using a NI-DAQ to scan over a target. My plan is to use this motor control to move the target while I scan. Therefore, I need some sort of trigger. I saw the command MOT_SET_TRIGGER in the manual. I tried to load this command and noticed that it was not in the PyAPT.py file. So i figured I could add it and that did not work either. I opened up the APT.lib and the command was not even in the the .lib file.

Is there something I am missing here? I figured that the APT files would have all the command from the Thorlabs APT Controllers manual. If this is not possible, do you have any suggestions on how I can sync the start of the motor with the start of the scanning?

Thanks again for making this and I hope to hear from you soon!

Kinesis support?

I'm guessing this is outside the scope of this project, but I didn't see any closed issues on this, so: are there any plans to support Kinesis, or does anyone know of a Python project that does? The best I've found so far is instrumental-lib, which has a basic implementation for one device.

I guess Thorlabs introduced Kinesis in 2016 and is using that for new devices. My impression is that Kinesis software will drive APT devices, but APT software won't drive Kinesis devices.

Trigger out via low-level command

Very useful code !

I'm trying to use an OUT trigger from a motor (XY stage MLS203, controlled by BBD202 precisely) to trig a display.
In the manual of the controller BBD202 (5.3.4 section page 53), , it says that I must use the "LLSetGetDigOPs" method, which I cannot find in the APT.dll

It seems to be a low-level method : do you know how I can use it ? Do I have to use the RS232 connection, if so what are the commands to communicate ?

(also, I tried with APT user, but even when I select "persist to hardware" the trigger seems to be the same when I move the stage, i.e. a TTL output of a certain width even if I change the mode from "Max vel. reached" to "Motion complete" for instance)

Thanks !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.