Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nanotrack #1

Closed
mabl opened this issue Feb 11, 2016 · 3 comments
Closed

Nanotrack #1

mabl opened this issue Feb 11, 2016 · 3 comments

Comments

@mabl
Copy link

mabl commented Feb 11, 2016

Hi,

I'd like to add support for the Nanotrack controllers. However, I have not found any documentation of the ATP.dll. Is this available somewhere?

Very best,
Matthias

@mabl
Copy link
Author

mabl commented Feb 11, 2016

Ok, it looks like this is futile since it is not exported by apt.dll...

@mabl mabl closed this as completed Feb 11, 2016
@tobiasgehring
Copy link
Contributor

OK. APT.DLL seems to be quite limited and not documented at all. So you
either have to use the ActiveX controls :( or better, the underlying
ftdi protocol. For the latter there is a python library:
https://github.com/freespace/pyAPT
Haven't tried it myself though.

On 02/11/2016 05:55 PM, Matthias Blaicher wrote:

Ok, it looks like this is futile since it is not exported by apt.dll...


Reply to this email directly or view it on GitHub
#1 (comment).

@mabl
Copy link
Author

mabl commented Feb 11, 2016

I got it working with python .net:

import clr
import sys

sys.path.append(r'C:\Program Files\Thorlabs\Kinesis')

clr.AddReference("Thorlabs.MotionControl.DeviceManagerCLI")
clr.AddReference("Thorlabs.MotionControl.GenericNanoTrakCLI")
clr.AddReference("Thorlabs.MotionControl.TCube.NanoTrakCLI")

from Thorlabs.MotionControl.DeviceManagerCLI import DeviceManagerCLI
from Thorlabs.MotionControl.GenericNanoTrakCLI import NanoTrakStatus, TIAReading, TIARangeParameters
from Thorlabs.MotionControl.TCube.NanoTrakCLI import TCubeNanoTrak

class NanoTrak:
    def __init__(self, device_id):
        DeviceManagerCLI.BuildDeviceList()
        if not DeviceManagerCLI.GetDeviceList().Contains(device_id):
            raise RuntimeError('Unknown device id')

        device = TCubeNanoTrak.CreateTCubeNanoTrak(device_id)
        device.Connect(device_id)
        if not device.IsSettingsInitialized():
            device.WaitForSettingsInitialized(5000)

        device.StartPolling(250)

        #device.SetTIARangeMode(TIARangeParameters.TIARangeModes.AutoRangeAtSelected, TIARangeParameters.OddOrEven.All);

        #nanotrak_settings = device.GetNanoTrakConfiguration(device_id)
        self._device = device

    def close(self):
        if self._device:
            self._device.StopPolling()
            self._device.Disconnect()
            self._device = None

    def __del__(self):
        self.close()

    @property
    def tracking(self):
        return self._device.GetMode() != NanoTrakStatus.OperatingModes.Latch

    @tracking.setter
    def tracking(self, enabled):
        if enabled:
            self._device.SetMode(NanoTrakStatus.OperatingModes.Tracking)
        else:
            self._device.SetMode(NanoTrakStatus.OperatingModes.Latch)


    @property
    def power(self):
        tia_reading = self._device.GetReading()
        # if tia_reading.UnderOrOverRead != TIAReading.UnderOrOver.Within:
        #     raise ValueError('TIA out of range!')
        return tia_reading.AbsoluteReading


    @property
    def cycle_position(self):
        pos = self._device.GetCirclePosition()
        return pos.HPosition, pos.VPosition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants