ThorLabs APT 64 bit driver

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

ThorLabs APT 64 bit driver

Gilles V
Hello All

Our lab recently got some ThorLabs APT devices as Z-stages. At the moment there is only a 32 bit driver available. We are using micromanager 64bit for our data acquistion and we have a hodge podge workaround running MM 32 bits in parallel to control the z-stage.
I know some have raised the issue and ended up switching to 32 bits, but is there a way to easily convert the driver to 64 bit ?

Thank you for your help

Best regards
Gilles Vanwalleghem
Reply | Threaded
Open this post in threaded view
|

Re: ThorLabs APT 64 bit driver

Egor Zindy
Hello,

On 10 March 2016 at 01:45, Gilles V <[hidden email]> wrote:
> Hello All
>
> Our lab recently got some ThorLabs APT devices as Z-stages. At the moment
> there is only a 32 bit driver available. We are using micromanager 64bit for
> our data acquistion and we have a hodge podge workaround running MM 32 bits
> in parallel to control the z-stage.
> I know some have raised the issue and ended up switching to 32 bits, but is
> there a way to easily convert the driver to 64 bit ?

Easily? No. The device adapter relies on APT.dll, which is 32 bit only.

I did start rewriting the code in C for maximum portability
(win/linux/macos/32/64). It implements the functions defined in the
Thorlabs' APTAPI.h file and uses the FTDI's D2XX library. I got some
functions implemented and then got stuck.

Anyway, I have just put all the relevant code on github. Hopefully,
there should be enough there to get someone started on this. I will
gladly accept any pull request, but I do not have time to look into
this further myself.

https://github.com/zindy/libapt

the code for now is contained in
https://github.com/zindy/libapt/blob/master/test_main.c

Kind regards,
Egor

>
> Thank you for your help
>
> Best regards
> Gilles Vanwalleghem
>
>
>
> --
> View this message in context: http://micro-manager.3463995.n2.nabble.com/ThorLabs-APT-64-bit-driver-tp7586748.html
> Sent from the Micro-Manager mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
> _______________________________________________
> micro-manager-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/micro-manager-general

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: ThorLabs APT 64 bit driver

Nico Stuurman-2

On 3/16/16 3:24 AM, Egor Zindy wrote:

> Hello,
>
> On 10 March 2016 at 01:45, Gilles V <[hidden email]> wrote:
>> Hello All
>>
>> Our lab recently got some ThorLabs APT devices as Z-stages. At the moment
>> there is only a 32 bit driver available. We are using micromanager 64bit for
>> our data acquistion and we have a hodge podge workaround running MM 32 bits
>> in parallel to control the z-stage.
>> I know some have raised the issue and ended up switching to 32 bits, but is
>> there a way to easily convert the driver to 64 bit ?
> Easily? No. The device adapter relies on APT.dll, which is 32 bit only.
>
> I did start rewriting the code in C for maximum portability
> (win/linux/macos/32/64). It implements the functions defined in the
> Thorlabs' APTAPI.h file and uses the FTDI's D2XX library. I got some
> functions implemented and then got stuck.
>
> Anyway, I have just put all the relevant code on github. Hopefully,
> there should be enough there to get someone started on this. I will
> gladly accept any pull request, but I do not have time to look into
> this further myself.
>
> https://github.com/zindy/libapt
So this is a rewrite of the Thorlabs implementation of the APT interface
in platform independent C?  Very nice!

Looking at the Thorlabs site itself, they appear to have a native 64 bit
APT now:
http://www.thorlabs.us/software_pages/ViewSoftwarePage.cfm?Code=APT&.
Does that include a 64 bit APT.dll?  If so, I think that a 64bit
Micro-Manager adapter could be build using that dll.

Best,

Nico



------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: ThorLabs APT 64 bit driver

Egor Zindy
In reply to this post by Egor Zindy
Hi Nico,

>> https://github.com/zindy/libapt
> So this is a rewrite of the Thorlabs implementation of the APT interface
> in platform independent C?  Very nice!

Yes, but very preliminary. I used the Thorlabs APTAPI.h prototype file
and used it for re-implementing my own functions in test_main.c -- At
a later date I was going to decouple the main() which I used for
testing from the rest of the code, which would become my APT.dll /
APT.so

The really basic functions were easy to do. For instance:

long WINAPI MOT_Identify(long lSerialNum) {
  FT_STATUS ftStatus;
  FT_HANDLE ftHandle;
  long nBytes;
  long channel;
  long destination;
  BYTE txbuf[6] ={0x23,0x02,0x00,0x00,0x50,0x01};
  ftStatus = GetChannelInfo(lSerialNum, &ftHandle, &channel, &destination);
  if (ftStatus == FT_OK) {
    txbuf[2] = channel+1;
    txbuf[4] = destination;
    ftStatus = FT_Write(ftHandle, txbuf, 6, &nBytes);
  }
  return ftStatus;
}

... for which I got the txbuf[] string from
http://www.thorlabs.us/software/apt/APT_Communications_Protocol_Rev_15.pdf
page 20.

Basically, all the functions in APTAPI.h could be guessed easily using
the manual. I just... ran out of time after I got stuck.

> Looking at the Thorlabs site itself, they appear to have a native 64 bit
> APT now:
> http://www.thorlabs.us/software_pages/ViewSoftwarePage.cfm?Code=APT&.
> Does that include a 64 bit APT.dll?  If so, I think that a 64bit
> Micro-Manager adapter could be build using that dll.

OK, this is very interesting. I found an APT.dll after downloading and
installing the http://www.thorlabs.us/software/apt/Application/APT%20Install%20x64/Setup.exe

According to http://stackoverflow.com/questions/495244/how-can-i-test-a-windows-dll-to-determine-if-it-is-32bit-or-64bit

$ file "C:\Program Files\Thorlabs\APT\APT Server\APT.dll"
C:\Program Files\Thorlabs\APT\APT Server\APT.dll: PE32+ executable
(DLL) (GUI) x86-64, for MS Windows

...means that APT.dll is indeed a 64 bit DLL.

Here are the 3 files zipped on my dropbox:
https://dl.dropboxusercontent.com/u/7580140/APT_x64.zip

Interestingly, there is a ftd2xx.dll file in the same folder, but
dependency walker does not show that APT.dll depends on it.

Could you / someone look into recompiling my ThorlabsAPTStage for
Windows 64 bit? If you don't have time, I'll try and do this myself. I
don't have a recent micromanager tree on my computer any more though.
Could take a while.

Kind regards,
Egor

>
> Best,
>
> Nico
>
>
>
> ------------------------------------------------------------------------------
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
> _______________________________________________
> micro-manager-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/micro-manager-general

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: ThorLabs APT 64 bit driver

Gilles V
Hello,

so I did try to recompile your ThorlabsAPTStage as a 64bit dll, it compiles, but is unavailable in the micro-manager hardware config wizard (it's greyed out).
I rebuilt micro-manager to be sure it was not a version issue and it still doesn't work out unfortunately.
Do you know what it may be ?

Kind regards,
Gilles Vanwalleghem
Reply | Threaded
Open this post in threaded view
|

Re: ThorLabs APT 64 bit driver

Egor Zindy
In reply to this post by Egor Zindy
Hi Gilles,

On 27 June 2016 at 04:14, Gilles V <[hidden email]> wrote:
> Hello,
>
> so I did try to recompile your ThorlabsAPTStage as a 64bit dll, it compiles,
> but is unavailable in the micro-manager hardware config wizard (it's greyed
> out).

as a matter of fact, I did. And yes, it is working! :-)

I was able to compile my ThorlabsAPTStage using the DLLs I linked to
in my previous post using VS2012 in Windows 8.1 in 64 bit / release
mode.

Quick and dirty instructions for compiling:

Download the x64 APT.lib / .dll / .h from
https://dl.dropboxusercontent.com/u/7580140/APT_x64.zip and drop the
files in the micromanager-upstream\DeviceAdapters\ThorlabsAPTStage
folder then compile for x64 / release.
Then copy "micromanager-upstream\DeviceAdapters\ThorlabsAPTStage\build\Release\x64\mmgr_dal_ThorlabsAPTStage.dll"
to your micromanager folder, as well as the APT.dll file.

Obligatory screenshot: http://i.imgur.com/un2CWcb.png

Here are the two DLLs to drop into the latest nightly (1.4.23
20160627) x64 folder.

https://dl.dropboxusercontent.com/u/7580140/ThorlabsAPTStage%20-%20x64%20dlls.zip

> I rebuilt micro-manager to be sure it was not a version issue and it still
> doesn't work out unfortunately.

I didn't have to, I just downloaded the latest nighty but...

> Do you know what it may be ?
>

Don't forget to also install the 64 bit APT drivers from Thorlabs as
per https://micro-manager.org/wiki/ThorlabsAPTStage to make it work.
Until you do (or if the 64 bit APT.dll is missing from the
micromanager folder) then yes, the ThorlabsAPTStage will be greyed
out.

I would really appreciate if you could either test my compilation
method or the DLLs in my dropbox and let the list know whether this is
working for you or not.

If it does, it would be nice to have the 64 bit version of
ThorlabsAPTStage included in the nightlies from now on...

Kind regards,
Egor

> Kind regards,
> Gilles Vanwalleghem
>
>
>

On 27 June 2016 at 04:14, Gilles V <[hidden email]> wrote:

> Hello,
>
> so I did try to recompile your ThorlabsAPTStage as a 64bit dll, it compiles,
> but is unavailable in the micro-manager hardware config wizard (it's greyed
> out).
> I rebuilt micro-manager to be sure it was not a version issue and it still
> doesn't work out unfortunately.
> Do you know what it may be ?
>
> Kind regards,
> Gilles Vanwalleghem
>
>
>
> --
> View this message in context: http://micro-manager.3463995.n2.nabble.com/ThorLabs-APT-64-bit-driver-tp7586748p7587259.html
> Sent from the Micro-Manager mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
> _______________________________________________
> micro-manager-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/micro-manager-general

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: ThorLabs APT 64 bit driver

Gilles V
This post was updated on .
Hi Egor,

>Here are the two DLLs to drop into the latest nightly (1.4.23
>20160627) x64 folder. <quote author="Egor Zindy">

This worked fine when I used it with the nightly build, I also compiled it while adding the latest KDC101 controller and that works too, thanks a lot ! I don't know if it was the APT.dll or the nightly build that did the trick though.

I now have a weird bug where I can only move forward and not in rev with the stage in micro-manager... I'll try to have a look at your code and see what may be the issue.
The KDC101 comes with a led display and it displays at Rev Limit, it looks like the min position is screwed up for some reason.

But thanks a lot for your help !

Gilles



Reply | Threaded
Open this post in threaded view
|

Re: ThorLabs APT 64 bit driver

Gilles V
Hi Egor,

So we tried it on the TDC001 controller, same stage and it works flawlessly either the one you sent or the compiled ones.
For the KDC101 I don't know what's happening, it looks like some bug during the initialization, from the log it can read the position and all infos fine, it's just the controller freaks out and is convinced that it is beyond the 0 and at the reverse limit. It gets fixed by launching the APT software though, so I don't know what's going on.
We'll probably use the old controllers in the mean time as I don't have the know how to fix the driver issue on my own.

Gilles
Reply | Threaded
Open this post in threaded view
|

Re: ThorLabs APT 64 bit driver

Egor Zindy
In reply to this post by Gilles V
Hi Gilles,

> So we tried it on the TDC001 controller, same stage and it works flawlessly
> either the one you sent or the compiled ones.

Good to know, thanks! That's the controller I checked the 64 bit code
with as well, so I'm glad we agree on this.

> For the KDC101 I don't know what's happening, it looks like some bug during
> the initialization, from the log it can read the position and all infos
> fine, it's just the controller freaks out and is convinced that it is beyond
> the 0 and at the reverse limit.

Crapshoot in the dark, but this could be a signed / unsigned integer
issue. My code would probably benefit from the more formal int32_t /
uint32_t / int64_t etc conventions. This should be a relatively easy
change and at least we will be able to rule that one out.

Unfortunately, I only have the TDC001 controller to play with at the
moment, so all the testing I could do will be limited to that
controller.

> It gets fixed by launching the APT software
> though, so I don't know what's going on.

This is interesting. Might be worth sniffing-out the traffic between
the PC and the controller using wireshark / usbpcap. Then
cross-reference this with the APT protocol document which Thorlabs
provides. These instructions should work if you want to try it out:
http://blog.philippklaus.de/2015/12/usb-capturing-on-windows/

> We'll probably use the old controllers in the mean time as I don't have the
> know how to fix the driver issue on my own.

That sounds like your best bet fr now unfortunately. Well, you never
know, maybe making sure we use the right data types when talking to
APT.dll will fix the problem...

Kind regards,
Egor

>
> Gilles
>
>
>
> --
> View this message in context: http://micro-manager.3463995.n2.nabble.com/ThorLabs-APT-64-bit-driver-tp7586748p7587281.html
> Sent from the Micro-Manager mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
> _______________________________________________
> micro-manager-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/micro-manager-general

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: ThorLabs APT 64 bit driver

lika
In reply to this post by Gilles V
Hi Egor,

Did you ever get the KDC101 working under MM, either 32 or 64 bits?
The TDC001 model is not available any more and I have to find a new replacement.

Thanks,

Lika
Reply | Threaded
Open this post in threaded view
|

Re: ThorLabs APT 64 bit driver

Egor Zindy
In reply to this post by Gilles V
Hi Lika,

On 31 August 2016 at 13:57, lika <[hidden email]> wrote:
> Hi Egor,
>
> Did you ever get the KDC101 working under MM, either 32 or 64 bits?
> The TDC001 model is not available any more and I have to find a new
> replacement.

Unfortunately, I do not have one of those for testing, so I can't
really help you with this.

The obvious question is, is libapt supposed to work with the new
controllers? Otherwise, we're stuck.

Cheers,
Egor

>
> Thanks,
>
> Lika
>
>
>
> --
> View this message in context: http://micro-manager.3463995.n2.nabble.com/ThorLabs-APT-64-bit-driver-tp7586748p7587536.html
> Sent from the Micro-Manager mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> _______________________________________________
> micro-manager-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/micro-manager-general

------------------------------------------------------------------------------
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: ThorLabs APT 64 bit driver

derinsevenler
Hi all,

I had the same problem as you all, and recently wrote a driver for KDC101 stage controllers that uses Thorlab's new Kinesis interface: https://www.thorlabs.com/software_pages/ViewSoftwarePage.cfm?Code=Motion_Control. Unfortunately, the APT software is now legacy software and Thorlabs wants everyone to switch to APT.

You can read more about the driver here, if it's useful for you: https://github.com/micro-manager/micro-manager/issues/461. It's important to note that it's only usable right now out-of-the-box with KDC101 (DC servo) controllers. If you have another K-cube controller you need to make a few changes to the code.

Hope that helps.
Reply | Threaded
Open this post in threaded view
|

Re: ThorLabs APT 64 bit driver

Egor Zindy
In reply to this post by Egor Zindy
Hello Derin,

just to clear some confusion,

> Unfortunately, the APT software is now legacy software and Thorlabs wants
> everyone to switch to [Kinesis] APT.

As I understand, there are two separate things Thorlabs calls APT:
* The APT System Software, which you are right, is the legacy software
platform based on ActiveX (now superseded by Kinesis) and
* The APT Controllers Host-Controller Communications Protocol

The APT DLL is an implementation of the latter, using a low-level
library (D2XX) to directly send commands to the USB controllers,
without the need for ActiveX or Kinesis.

By the sound of it, what we're missing is the "type" value for the new
KDC001 controllers which isn't defined in APTAPI.h.

I made some progress towards rewriting the DLL using the
cross-platform and open-source libftdi1 library. See
https://github.com/zindy/libapt

If you do manage to compile and run the test app, this will give us
the APT Type value I need to recognise the KDC001 controller in the
ThorlabsAPT device adapter.

For example, if I run test_main with two TDC001 controllers attached,
here is the output. It's quite messy (debug mode) but it will output
the APT Model Number and APT Type for any Thorlabs APT controller
plugged in via USB.

Initialized libftdi 1.2 (major: 1, minor: 2, micro: 0, snapshot ver: unknown)
Checking device: 0
Manufacturer: 'Thorlabs', Description: 'APT DC Motor Controller',
Serial No: '83841000'
Checking device: 1
Manufacturer: 'Thorlabs', Description: 'APT DC Motor Controller',
Serial No: '83840847'
Number of Thorlabs devices found: 2

Dev 0: 83841000
InitHWDevice txbuf (6 bytes):
  0000  05 00 00 00 50 01                                ....P.
InitHWDevice rxbuf (90 bytes):
  0000  06 00 54 00 81 50 c0 7a f2 04 54 44 43 30 30 31  ..T..P.z..TDC001
  0010  00 00 10 00 08 00 02 00 54 44 43 30 30 31 20 44  ........TDC001 D
  0020  43 20 53 65 72 76 6f 20 44 72 69 76 65 00 00 00  C Servo Drive...
  0030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  0040  00 00 00 00 00 00 00 00 31 30 33 38 31 39 41 75  ........103819Au
  0050  67 00 08 00 02 00 00 00 01 00                    g.........
 APT SerialNumber=83841000
 APT Model Number='TDC001'
 APT Type=31
 APT HardwareType=16
 APT FirmwareVersion='2.0.8'
 APT Notes='TDC001 DC Servo Drive'
 APT HardwareVersion=2
 APT ModState=0
 APT Number of Channels=1
MOT_Identify txbuf (6 bytes):
  0000  23 02 00 00 50 01                                #...P.
MOT_EnableHWChannel txbuf (6 bytes):
  0000  10 02 01 01 50 01                                ....P.
MOT_MoveHome txbuf (6 bytes):
  0000  43 04 01 00 50 01                                C...P.
MOT_MoveRelativeEx txbuf (12 bytes):
  0000  48 04 06 00 d0 01 01 00 00 00 00 00              H...........
MOT_MoveRelativeEx rxbuf (6 bytes):
  0000  64 04 0e 00 81 50                                d....P
MOT_GetPosition txbuf (6 bytes):
  0000  11 04 01 00 50 01                                ....P.
MOT_GetPosition rxbuf (12 bytes):
  0000  12 04 06 00 81 50 01 00 00 00 00 00              .....P......
Position=0.00

Dev 1: 83840847
InitHWDevice txbuf (6 bytes):
  0000  05 00 00 00 50 01                                ....P.
InitHWDevice rxbuf (90 bytes):
  0000  06 00 54 00 81 50 c0 7a f2 04 54 44 43 30 30 31  ..T..P.z..TDC001
  0010  00 00 10 00 08 00 02 00 54 44 43 30 30 31 20 44  ........TDC001 D
  0020  43 20 53 65 72 76 6f 20 44 72 69 76 65 00 00 00  C Servo Drive...
  0030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  0040  00 00 00 00 00 00 00 00 31 30 33 38 31 39 41 75  ........103819Au
  0050  67 00 06 00 02 00 00 00 01 00                    g.........
 APT SerialNumber=83840847
 APT Model Number='TDC001'
 APT Type=31
 APT HardwareType=16
 APT FirmwareVersion='2.0.8'
 APT Notes='TDC001 DC Servo Drive'
 APT HardwareVersion=2
 APT ModState=0
 APT Number of Channels=1
MOT_Identify txbuf (6 bytes):
  0000  23 02 00 00 50 01                                #...P.
MOT_EnableHWChannel txbuf (6 bytes):
  0000  10 02 01 01 50 01                                ....P.
MOT_MoveHome txbuf (6 bytes):
  0000  43 04 01 00 50 01                                C...P.
MOT_MoveRelativeEx txbuf (12 bytes):
  0000  48 04 06 00 d0 01 01 00 00 00 00 00              H...........
MOT_MoveRelativeEx rxbuf (6 bytes):
  0000  64 04 0e 00 81 50                                d....P
MOT_GetPosition txbuf (6 bytes):
  0000  11 04 01 00 50 01                                ....P.
MOT_GetPosition rxbuf (12 bytes):
  0000  12 04 06 00 81 50 01 00 00 00 00 00              .....P......
Position=0.00

Cleaning-up...

Cheers,
Egor

------------------------------------------------------------------------------
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: ThorLabs APT 64 bit driver

derinsevenler
Hi Egor,

Thanks for the explanation re. APT.dll vs the APT software. I have a KDC101 so I can try to run your code when I have a free moment, and let you know what I get.

It would be cool to have a single adapter that supported all K-Cube devices.

Thanks,
Derin



> On Nov 16, 2016, at 7:39 PM, Egor Zindy <[hidden email]> wrote:
>
> Hello Derin,
>
> just to clear some confusion,
>
>> Unfortunately, the APT software is now legacy software and Thorlabs wants
>> everyone to switch to [Kinesis] APT.
>
> As I understand, there are two separate things Thorlabs calls APT:
> * The APT System Software, which you are right, is the legacy software
> platform based on ActiveX (now superseded by Kinesis) and
> * The APT Controllers Host-Controller Communications Protocol
>
> The APT DLL is an implementation of the latter, using a low-level
> library (D2XX) to directly send commands to the USB controllers,
> without the need for ActiveX or Kinesis.
>
> By the sound of it, what we're missing is the "type" value for the new
> KDC001 controllers which isn't defined in APTAPI.h.
>
> I made some progress towards rewriting the DLL using the
> cross-platform and open-source libftdi1 library. See
> https://github.com/zindy/libapt
>
> If you do manage to compile and run the test app, this will give us
> the APT Type value I need to recognise the KDC001 controller in the
> ThorlabsAPT device adapter.
>
> For example, if I run test_main with two TDC001 controllers attached,
> here is the output. It's quite messy (debug mode) but it will output
> the APT Model Number and APT Type for any Thorlabs APT controller
> plugged in via USB.
>
> Initialized libftdi 1.2 (major: 1, minor: 2, micro: 0, snapshot ver: unknown)
> Checking device: 0
> Manufacturer: 'Thorlabs', Description: 'APT DC Motor Controller',
> Serial No: '83841000'
> Checking device: 1
> Manufacturer: 'Thorlabs', Description: 'APT DC Motor Controller',
> Serial No: '83840847'
> Number of Thorlabs devices found: 2
>
> Dev 0: 83841000
> InitHWDevice txbuf (6 bytes):
>  0000  05 00 00 00 50 01                                ....P.
> InitHWDevice rxbuf (90 bytes):
>  0000  06 00 54 00 81 50 c0 7a f2 04 54 44 43 30 30 31  ..T..P.z..TDC001
>  0010  00 00 10 00 08 00 02 00 54 44 43 30 30 31 20 44  ........TDC001 D
>  0020  43 20 53 65 72 76 6f 20 44 72 69 76 65 00 00 00  C Servo Drive...
>  0030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>  0040  00 00 00 00 00 00 00 00 31 30 33 38 31 39 41 75  ........103819Au
>  0050  67 00 08 00 02 00 00 00 01 00                    g.........
> APT SerialNumber=83841000
> APT Model Number='TDC001'
> APT Type=31
> APT HardwareType=16
> APT FirmwareVersion='2.0.8'
> APT Notes='TDC001 DC Servo Drive'
> APT HardwareVersion=2
> APT ModState=0
> APT Number of Channels=1
> MOT_Identify txbuf (6 bytes):
>  0000  23 02 00 00 50 01                                #...P.
> MOT_EnableHWChannel txbuf (6 bytes):
>  0000  10 02 01 01 50 01                                ....P.
> MOT_MoveHome txbuf (6 bytes):
>  0000  43 04 01 00 50 01                                C...P.
> MOT_MoveRelativeEx txbuf (12 bytes):
>  0000  48 04 06 00 d0 01 01 00 00 00 00 00              H...........
> MOT_MoveRelativeEx rxbuf (6 bytes):
>  0000  64 04 0e 00 81 50                                d....P
> MOT_GetPosition txbuf (6 bytes):
>  0000  11 04 01 00 50 01                                ....P.
> MOT_GetPosition rxbuf (12 bytes):
>  0000  12 04 06 00 81 50 01 00 00 00 00 00              .....P......
> Position=0.00
>
> Dev 1: 83840847
> InitHWDevice txbuf (6 bytes):
>  0000  05 00 00 00 50 01                                ....P.
> InitHWDevice rxbuf (90 bytes):
>  0000  06 00 54 00 81 50 c0 7a f2 04 54 44 43 30 30 31  ..T..P.z..TDC001
>  0010  00 00 10 00 08 00 02 00 54 44 43 30 30 31 20 44  ........TDC001 D
>  0020  43 20 53 65 72 76 6f 20 44 72 69 76 65 00 00 00  C Servo Drive...
>  0030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>  0040  00 00 00 00 00 00 00 00 31 30 33 38 31 39 41 75  ........103819Au
>  0050  67 00 06 00 02 00 00 00 01 00                    g.........
> APT SerialNumber=83840847
> APT Model Number='TDC001'
> APT Type=31
> APT HardwareType=16
> APT FirmwareVersion='2.0.8'
> APT Notes='TDC001 DC Servo Drive'
> APT HardwareVersion=2
> APT ModState=0
> APT Number of Channels=1
> MOT_Identify txbuf (6 bytes):
>  0000  23 02 00 00 50 01                                #...P.
> MOT_EnableHWChannel txbuf (6 bytes):
>  0000  10 02 01 01 50 01                                ....P.
> MOT_MoveHome txbuf (6 bytes):
>  0000  43 04 01 00 50 01                                C...P.
> MOT_MoveRelativeEx txbuf (12 bytes):
>  0000  48 04 06 00 d0 01 01 00 00 00 00 00              H...........
> MOT_MoveRelativeEx rxbuf (6 bytes):
>  0000  64 04 0e 00 81 50                                d....P
> MOT_GetPosition txbuf (6 bytes):
>  0000  11 04 01 00 50 01                                ....P.
> MOT_GetPosition rxbuf (12 bytes):
>  0000  12 04 06 00 81 50 01 00 00 00 00 00              .....P......
> Position=0.00
>
> Cleaning-up...
>
> Cheers,
> Egor
>
> ------------------------------------------------------------------------------
> _______________________________________________
> micro-manager-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/micro-manager-general


------------------------------------------------------------------------------
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: ThorLabs APT 64 bit driver

Egor Zindy
In reply to this post by Egor Zindy
Hi Derin,

> Thanks for the explanation re. APT.dll vs the APT software.

No worries!

>
> I have a KDC101 so I can try to run your code when I have a free moment, and let you know what I get.
>

I thought about this a bit more, the HW_TYPE is derived from the first
two digits of the controller's serial number. I had a look in the
manual, and the type for the KDC101 controller seems to be 27 See
https://www.thorlabs.com/drawings/113f92893b497f55-6CC6FDEC-5056-0103-79F2A517BB271B85/KDC101-KDC101ManualforAPT.pdf

So, if we add this value in the ThorlabsAPTStage device adapter, it
may just work with the KDC101.

Need to add to ThorlabsAPTStage.cpp

//not defined in APTAPI.h
#define HWTYPE_KDC101 27

const char* g_ThorlabsDeviceNameKDC101 = "KDC101";
const char* g_ThorlabsDeviceDescKDC101 = "please fill this";

Then in InitializeModuleData:

//KDC101
hola = GetNumHWUnitsEx(HWTYPE_KDC101, &plNumUnits);
//if (plNumUnits >= 1)
AddAvailableDeviceName(g_ThorlabsDeviceNameKDC101,
g_ThorlabsDeviceDescKDC101);
if (plNumUnits >= 1) RegisterDevice(g_ThorlabsDeviceNameTDC001,
MM::StageDevice, g_ThorlabsDeviceDescKDC101);

and in CreateDevice

else if (strcmp(deviceName, g_ThorlabsDeviceNameKDC101) == 0)
{
    hwType = HWTYPE_KDC101;
}

That's everything I think!

Detecting devices and initialising them should be easier with my
library and the type "HWTYPE_ANY" but for now, this will have to do.

>
> It would be cool to have a single adapter that supported all K-Cube devices.
>

Absolutely!

Cheers,
Egor


>
> Thanks,
> Derin
>
>
>
> > On Nov 16, 2016, at 7:39 PM, Egor Zindy <[hidden email]> wrote:
> >
> > Hello Derin,
> >
> > just to clear some confusion,
> >
> >> Unfortunately, the APT software is now legacy software and Thorlabs wants
> >> everyone to switch to [Kinesis] APT.
> >
> > As I understand, there are two separate things Thorlabs calls APT:
> > * The APT System Software, which you are right, is the legacy software
> > platform based on ActiveX (now superseded by Kinesis) and
> > * The APT Controllers Host-Controller Communications Protocol
> >
> > The APT DLL is an implementation of the latter, using a low-level
> > library (D2XX) to directly send commands to the USB controllers,
> > without the need for ActiveX or Kinesis.
> >
> > By the sound of it, what we're missing is the "type" value for the new
> > KDC001 controllers which isn't defined in APTAPI.h.
> >
> > I made some progress towards rewriting the DLL using the
> > cross-platform and open-source libftdi1 library. See
> > https://github.com/zindy/libapt
> >
> > If you do manage to compile and run the test app, this will give us
> > the APT Type value I need to recognise the KDC001 controller in the
> > ThorlabsAPT device adapter.
> >
> > For example, if I run test_main with two TDC001 controllers attached,
> > here is the output. It's quite messy (debug mode) but it will output
> > the APT Model Number and APT Type for any Thorlabs APT controller
> > plugged in via USB.
> >
> > Initialized libftdi 1.2 (major: 1, minor: 2, micro: 0, snapshot ver: unknown)
> > Checking device: 0
> > Manufacturer: 'Thorlabs', Description: 'APT DC Motor Controller',
> > Serial No: '83841000'
> > Checking device: 1
> > Manufacturer: 'Thorlabs', Description: 'APT DC Motor Controller',
> > Serial No: '83840847'
> > Number of Thorlabs devices found: 2
> >
> > Dev 0: 83841000
> > InitHWDevice txbuf (6 bytes):
> >  0000  05 00 00 00 50 01                                ....P.
> > InitHWDevice rxbuf (90 bytes):
> >  0000  06 00 54 00 81 50 c0 7a f2 04 54 44 43 30 30 31  ..T..P.z..TDC001
> >  0010  00 00 10 00 08 00 02 00 54 44 43 30 30 31 20 44  ........TDC001 D
> >  0020  43 20 53 65 72 76 6f 20 44 72 69 76 65 00 00 00  C Servo Drive...
> >  0030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
> >  0040  00 00 00 00 00 00 00 00 31 30 33 38 31 39 41 75  ........103819Au
> >  0050  67 00 08 00 02 00 00 00 01 00                    g.........
> > APT SerialNumber=83841000
> > APT Model Number='TDC001'
> > APT Type=31
> > APT HardwareType=16
> > APT FirmwareVersion='2.0.8'
> > APT Notes='TDC001 DC Servo Drive'
> > APT HardwareVersion=2
> > APT ModState=0
> > APT Number of Channels=1
> > MOT_Identify txbuf (6 bytes):
> >  0000  23 02 00 00 50 01                                #...P.
> > MOT_EnableHWChannel txbuf (6 bytes):
> >  0000  10 02 01 01 50 01                                ....P.
> > MOT_MoveHome txbuf (6 bytes):
> >  0000  43 04 01 00 50 01                                C...P.
> > MOT_MoveRelativeEx txbuf (12 bytes):
> >  0000  48 04 06 00 d0 01 01 00 00 00 00 00              H...........
> > MOT_MoveRelativeEx rxbuf (6 bytes):
> >  0000  64 04 0e 00 81 50                                d....P
> > MOT_GetPosition txbuf (6 bytes):
> >  0000  11 04 01 00 50 01                                ....P.
> > MOT_GetPosition rxbuf (12 bytes):
> >  0000  12 04 06 00 81 50 01 00 00 00 00 00              .....P......
> > Position=0.00
> >
> > Dev 1: 83840847
> > InitHWDevice txbuf (6 bytes):
> >  0000  05 00 00 00 50 01                                ....P.
> > InitHWDevice rxbuf (90 bytes):
> >  0000  06 00 54 00 81 50 c0 7a f2 04 54 44 43 30 30 31  ..T..P.z..TDC001
> >  0010  00 00 10 00 08 00 02 00 54 44 43 30 30 31 20 44  ........TDC001 D
> >  0020  43 20 53 65 72 76 6f 20 44 72 69 76 65 00 00 00  C Servo Drive...
> >  0030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
> >  0040  00 00 00 00 00 00 00 00 31 30 33 38 31 39 41 75  ........103819Au
> >  0050  67 00 06 00 02 00 00 00 01 00                    g.........
> > APT SerialNumber=83840847
> > APT Model Number='TDC001'
> > APT Type=31
> > APT HardwareType=16
> > APT FirmwareVersion='2.0.8'
> > APT Notes='TDC001 DC Servo Drive'
> > APT HardwareVersion=2
> > APT ModState=0
> > APT Number of Channels=1
> > MOT_Identify txbuf (6 bytes):
> >  0000  23 02 00 00 50 01                                #...P.
> > MOT_EnableHWChannel txbuf (6 bytes):
> >  0000  10 02 01 01 50 01                                ....P.
> > MOT_MoveHome txbuf (6 bytes):
> >  0000  43 04 01 00 50 01                                C...P.
> > MOT_MoveRelativeEx txbuf (12 bytes):
> >  0000  48 04 06 00 d0 01 01 00 00 00 00 00              H...........
> > MOT_MoveRelativeEx rxbuf (6 bytes):
> >  0000  64 04 0e 00 81 50                                d....P
> > MOT_GetPosition txbuf (6 bytes):
> >  0000  11 04 01 00 50 01                                ....P.
> > MOT_GetPosition rxbuf (12 bytes):
> >  0000  12 04 06 00 81 50 01 00 00 00 00 00              .....P......
> > Position=0.00
> >
> > Cleaning-up...
> >
> > Cheers,
> > Egor
> >
> > ------------------------------------------------------------------------------
> > _______________________________________________
> > micro-manager-general mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/micro-manager-general
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> micro-manager-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/micro-manager-general

------------------------------------------------------------------------------
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general