/libapt

An Open Source rewrite of the Thorlabs APT.dll based on the cross-platform libftdi1 library

Primary LanguageJupyter NotebookApache License 2.0Apache-2.0

libapt

An Open Source rewrite in C of the Thorlabs APT.dll based on the APT communication protocol and the libftdi1 library for low-level communication.

What?

The idea is to re-implement all the functions defined in the APTAPI.h protocol file, or at least the ones we need to make the micro-manager ThorlabsAPTStage device adapter work. By using libftdi1 and by re-using the APTAPI.h protocol file, replacing the APT.dll file provided by Thorlabs with the one provided here should be relatively straightforward. APTAPI.h is copyright (c) Thorlabs.

Why?

In micromanager, my ThorlabsAPTStage adapter relies on the APT.dll DLL provided by Thorlabs. The DLL although now available both for 32 bit Windows as well as 64 bit Windows still ties the APT device adapter exclusively to the Windows platform.

Which means:

  • The ThorlabsAPTStage device adapter will only work with a Windows OS.
  • The ThorlabsAPTStage device adapter only works with the TDC001 controller which is now obsolete.
  • The ThorlabsAPTStage device adapter will not work in Linux (32 or 64 bit).
  • The ThorlabsAPTStage device adapter will not work on Mac OSX (32 or 64 bit, either Intel, PowerPC or 68000 CPU).

So where are we at with the opensource adapter?

I got a few of the commands done, but there are still many I'm stuck on. On the TDC001 controller, MGMSG_MOT_REQ_PMDSTAGEAXISPARAMS does not return any information at all, for example. Time to look at some USB traffic with Wireshark methinks...

Still, you should be able to initialize the stage, home it, set positions, etc. The library, although far from being complete already shows some promise.

Other things I still need to look at: I have a very limited understanding of Autoconf. If someone wants to help with that, please send me a pull request. I think I wrote enough code to do a autoreconf -fvi;./configure;make;make install but there are no usable Python SWIG bindings, and I haven't worked-out yet how to reintegrate the main() part of my test_main.c with the libapt library.

As I said before, I'll spare whatever time I can on this project but don't expect too much. For now if you want to test this, you can type (to make libapt.so and install it):

autoreconf -fvi
./configure
make
sudo make install

Then if you want to run the sample application, type:

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"
gcc -o test_main src/test_main.c -lapt
./test_main

We're getting close everyone! :-)

Contrib files

TL;DR Do you want this fixed and finished? Please contribute. I will gladly accept any pull requests.

Cheers!