Commit 3d58f75e authored by Nick Sauerwein's avatar Nick Sauerwein
Browse files

running on linux (KDC not compatible yet)

parent b794e0bf
...@@ -2,116 +2,143 @@ ...@@ -2,116 +2,143 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"from instruments.thorlabs import APTMotorController as apt" "import sys\n",
"%load_ext autoreload\n",
"%autoreload 2"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"metadata": {}, "metadata": {
"outputs": [ "collapsed": true
{ },
"ename": "TypeError", "outputs": [],
"evalue": "__init__() missing 1 required positional argument: 'idx_chan'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-2-ccad56ac2510>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmz\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mapt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mMotorChannel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m123\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m: __init__() missing 1 required positional argument: 'idx_chan'"
]
}
],
"source": [ "source": [
"mz = apt.MotorChannel(123)" "sys.path.append('../pyAPT/')"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pyAPT"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"ename": "SerialException",
"evalue": "[Errno 13] could not open port /dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83829619-if00-port0: [Errno 13] Permission denied: '/dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83829619-if00-port0'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mPermissionError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/home/data/anaconda3/lib/python3.6/site-packages/serial/serialposix.py\u001b[0m in \u001b[0;36mopen\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 264\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 265\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfd\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mportstr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mO_RDWR\u001b[0m \u001b[0;34m|\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mO_NOCTTY\u001b[0m \u001b[0;34m|\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mO_NONBLOCK\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 266\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mOSError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mmsg\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mPermissionError\u001b[0m: [Errno 13] Permission denied: '/dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83829619-if00-port0'",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[0;31mSerialException\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-9-7266db32826e>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mapt1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mapt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen_serial\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'/dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83829619-if00-port0'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/home/data/anaconda3/lib/python3.6/site-packages/instruments/abstract_instruments/instrument.py\u001b[0m in \u001b[0;36mopen_serial\u001b[0;34m(cls, port, baud, vid, pid, serial_number, timeout, write_timeout)\u001b[0m\n\u001b[1;32m 521\u001b[0m \u001b[0mbaud\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mbaud\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 522\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 523\u001b[0;31m \u001b[0mwrite_timeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mwrite_timeout\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 524\u001b[0m )\n\u001b[1;32m 525\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mcls\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mser\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/anaconda3/lib/python3.6/site-packages/instruments/abstract_instruments/comm/serial_manager.py\u001b[0m in \u001b[0;36mnew_serial_connection\u001b[0;34m(port, baud, timeout, write_timeout)\u001b[0m\n\u001b[1;32m 62\u001b[0m \u001b[0mbaudrate\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mbaud\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 63\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 64\u001b[0;31m \u001b[0mwriteTimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mwrite_timeout\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 65\u001b[0m ))\n\u001b[1;32m 66\u001b[0m \u001b[0mserialObjDict\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mport\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mconn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/anaconda3/lib/python3.6/site-packages/serial/serialutil.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, port, baudrate, bytesize, parity, stopbits, timeout, xonxoff, rtscts, write_timeout, dsrdtr, inter_byte_timeout, exclusive, **kwargs)\u001b[0m\n\u001b[1;32m 238\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 239\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mport\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 240\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 241\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 242\u001b[0m \u001b[0;31m# - - - - - - - - - - - - - - - - - - - - - - - -\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/anaconda3/lib/python3.6/site-packages/serial/serialposix.py\u001b[0m in \u001b[0;36mopen\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 266\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mOSError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mmsg\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 267\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfd\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 268\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mSerialException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0merrno\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"could not open port {}: {}\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_port\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 269\u001b[0m \u001b[0;31m#~ fcntl.fcntl(self.fd, fcntl.F_SETFL, 0) # set blocking\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 270\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mSerialException\u001b[0m: [Errno 13] could not open port /dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83829619-if00-port0: [Errno 13] Permission denied: '/dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83829619-if00-port0'"
]
}
],
"source": [ "source": [
"apt1 = apt.open_serial('/dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83829619-if00-port0')" "c = pyAPT.Z825B(serial_number=83835879)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true "scrolled": true
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"from thorpy.comm.discovery import discover_stages" "c = pyAPT.Z825B(serial_number=27250866)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"c = pyAPT.Z825B(serial_number=27001714)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"c.identify()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": { "metadata": {
"collapsed": true "scrolled": false
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"import thorpy" "c.info()"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"[]\n"
]
}
],
"source": [ "source": [
"discover_stages()\n", "c.home()"
"\n",
"stages = list(discover_stages())\n",
"print (stages)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"import sys" "c.goto(15)"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"int(b'x00P')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"b = b'\\x05\\x00\\x00\\x00P\\x01'.decode('utf-16')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for c in b:\n",
" print(ord(c))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
......
...@@ -18,7 +18,7 @@ import numpy as np ...@@ -18,7 +18,7 @@ import numpy as np
print_feedback=False #Smaract MCS Feedback print_feedback=False #Smaract MCS Feedback
ser = serial.Serial( ser = serial.Serial(
port='COM1', port='/dev/ttyUSB0',
baudrate=9600 baudrate=9600
) )
......
...@@ -30,6 +30,7 @@ xmin: minimal x in mm ...@@ -30,6 +30,7 @@ xmin: minimal x in mm
ymax: maximal y in mm ymax: maximal y in mm
ymin: minimal y in mm ymin: minimal y in mm
ExposureTimeAbs: exposure time in us ExposureTimeAbs: exposure time in us
TriggerMode: On/Off
measurement file: measurement file:
time: time (datetime object) time: time (datetime object)
...@@ -54,7 +55,7 @@ class Interferometer: ...@@ -54,7 +55,7 @@ class Interferometer:
def set_config(self,config): def set_config(self,config):
self.cam.properties['ExposureTimeAbs']=config['ExposureTimeAbs'] self.cam.properties['ExposureTimeAbs']=config['ExposureTimeAbs']
self.cam.properties['TriggerMode']=config['TriggerMode']
self.xmin, self.xmax, self.ymin, self.ymax = (config['xmin'], config['xmax'], self.xmin, self.xmax, self.ymin, self.ymax = (config['xmin'], config['xmax'],
config['ymin'], config['ymax']) config['ymin'], config['ymax'])
...@@ -63,7 +64,7 @@ class Interferometer: ...@@ -63,7 +64,7 @@ class Interferometer:
def get_config(self): def get_config(self):
config = {} config = {}
config['ExposureTimeAbs'] = self.cam.properties['ExposureTimeAbs'] config['ExposureTimeAbs'] = self.cam.properties['ExposureTimeAbs']
config['TriggerMode'] = self.cam.properties['TriggerMode']
config['xmin'], config['xmax'],config['ymin'], config['ymax']= (self.xmin, self.xmax, self.ymin, self.ymax) config['xmin'], config['xmax'],config['ymin'], config['ymax']= (self.xmin, self.xmax, self.ymin, self.ymax)
return config return config
def measure(self): def measure(self):
...@@ -134,8 +135,7 @@ class Interferometer: ...@@ -134,8 +135,7 @@ class Interferometer:
assert('camera not found') assert('camera not found')
#cam.properties['GevSCPSPacketSize']=8000 #cam.properties['GevSCPSPacketSize']=9014
cam.properties['TriggerMode']='Off'
cam.properties['AcquisitionFrameRateEnable']=False cam.properties['AcquisitionFrameRateEnable']=False
cam.properties['AcquisitionFrameRateAbs']=100 cam.properties['AcquisitionFrameRateAbs']=100
cam.properties['GainRaw']=150 cam.properties['GainRaw']=150
......
This diff is collapsed.
from IPython.display import HTML
def hide():
print ('hu')
HTML('''<script>
code_show=false;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<h1><a href="javascript:code_toggle()">Hide Code</a></h1>''')
\ No newline at end of file
py_elog @ 9e7ad854
Subproject commit 9e7ad854d005d682628ab887cff00aa1c30da248
...@@ -2,211 +2,142 @@ ...@@ -2,211 +2,142 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"from instruments.thorlabs import APTMotorController as apt" "import sys\n",
"%load_ext autoreload\n",
"%autoreload 2"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"metadata": {}, "metadata": {
"outputs": [ "collapsed": true
{ },
"ename": "TypeError", "outputs": [],
"evalue": "__init__() missing 1 required positional argument: 'idx_chan'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-2-ccad56ac2510>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmz\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mapt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mMotorChannel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m123\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m: __init__() missing 1 required positional argument: 'idx_chan'"
]
}
],
"source": [ "source": [
"mz = apt.MotorChannel(123)" "sys.path.append('../pyAPT/')"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pyAPT"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"ename": "SerialException",
"evalue": "[Errno 13] could not open port /dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83829619-if00-port0: [Errno 13] Permission denied: '/dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83829619-if00-port0'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mPermissionError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/home/data/anaconda3/lib/python3.6/site-packages/serial/serialposix.py\u001b[0m in \u001b[0;36mopen\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 264\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 265\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfd\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mportstr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mO_RDWR\u001b[0m \u001b[0;34m|\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mO_NOCTTY\u001b[0m \u001b[0;34m|\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mO_NONBLOCK\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 266\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mOSError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mmsg\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mPermissionError\u001b[0m: [Errno 13] Permission denied: '/dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83829619-if00-port0'",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[0;31mSerialException\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-9-7266db32826e>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mapt1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mapt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen_serial\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'/dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83829619-if00-port0'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/home/data/anaconda3/lib/python3.6/site-packages/instruments/abstract_instruments/instrument.py\u001b[0m in \u001b[0;36mopen_serial\u001b[0;34m(cls, port, baud, vid, pid, serial_number, timeout, write_timeout)\u001b[0m\n\u001b[1;32m 521\u001b[0m \u001b[0mbaud\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mbaud\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 522\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 523\u001b[0;31m \u001b[0mwrite_timeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mwrite_timeout\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 524\u001b[0m )\n\u001b[1;32m 525\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mcls\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mser\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/anaconda3/lib/python3.6/site-packages/instruments/abstract_instruments/comm/serial_manager.py\u001b[0m in \u001b[0;36mnew_serial_connection\u001b[0;34m(port, baud, timeout, write_timeout)\u001b[0m\n\u001b[1;32m 62\u001b[0m \u001b[0mbaudrate\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mbaud\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 63\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 64\u001b[0;31m \u001b[0mwriteTimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mwrite_timeout\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 65\u001b[0m ))\n\u001b[1;32m 66\u001b[0m \u001b[0mserialObjDict\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mport\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mconn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/anaconda3/lib/python3.6/site-packages/serial/serialutil.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, port, baudrate, bytesize, parity, stopbits, timeout, xonxoff, rtscts, write_timeout, dsrdtr, inter_byte_timeout, exclusive, **kwargs)\u001b[0m\n\u001b[1;32m 238\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 239\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mport\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 240\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 241\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 242\u001b[0m \u001b[0;31m# - - - - - - - - - - - - - - - - - - - - - - - -\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/anaconda3/lib/python3.6/site-packages/serial/serialposix.py\u001b[0m in \u001b[0;36mopen\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 266\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mOSError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mmsg\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 267\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfd\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 268\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mSerialException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0merrno\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"could not open port {}: {}\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_port\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 269\u001b[0m \u001b[0;31m#~ fcntl.fcntl(self.fd, fcntl.F_SETFL, 0) # set blocking\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 270\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mSerialException\u001b[0m: [Errno 13] could not open port /dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83829619-if00-port0: [Errno 13] Permission denied: '/dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83829619-if00-port0'"
]
}
],
"source": [ "source": [
"apt1 = apt.open_serial('/dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83829619-if00-port0')" "c = pyAPT.Z825B(serial_number=83835879)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true "scrolled": true
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"from thorpy.comm.discovery import discover_stages" "c = pyAPT.Z825B(serial_number=27250866)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"import thorpy" "c = pyAPT.Z825B(serial_number=27001714)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"stages = list(discover_stages())\n", "c.identify()"
"print (stages)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true "scrolled": false
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"import sys" "c.info()"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"sys.path.append('../pyAPT/')" "c.home()"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"import pyAPT" "c.goto(15)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": null,
"metadata": { "metadata": {},
"scrolled": true "outputs": [],
},
"outputs": [
{
"ename": "FtdiError",
"evalue": "b'usb_open() failed' (-4)",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mFtdiError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-13-d61ede51469f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpyAPT\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcontroller\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mController\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mserial_number\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m83835879\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/home/data/pyAPT/pyAPT/controller.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, serial_number, label)\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 26\u001b[0m \u001b[0;31m# this takes up to 2-3s:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 27\u001b[0;31m \u001b[0mdev\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpylibftdi\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDevice\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmode\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'b'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdevice_id\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mserial_number\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 28\u001b[0m \u001b[0mdev\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbaudrate\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m115200\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 29\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/anaconda3/lib/python3.6/site-packages/pylibftdi/device.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, device_id, mode, encoding, lazy_open, chunk_size, interface_select, device_index, **kwargs)\u001b[0m\n\u001b[1;32m 94\u001b[0m \u001b[0;31m# lazy_open tells us not to open immediately.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 95\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mlazy_open\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 96\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 97\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 98\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__del__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/anaconda3/lib/python3.6/site-packages/pylibftdi/device.py\u001b[0m in \u001b[0;36mopen\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 134\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfdll\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mftdi_deinit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbyref\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mctx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 135\u001b[0m \u001b[0;32mdel\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mctx\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 136\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mFtdiError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 137\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 138\u001b[0m \u001b[0;31m# explicitly reset the device to serial mode with standard settings\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mFtdiError\u001b[0m: b'usb_open() failed' (-4)"
]
}
],
"source": [ "source": [
"c = pyAPT.controller.Controller(serial_number=83835879)" "int(b'x00P')"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"c.identify()" "b = b'\\x05\\x00\\x00\\x00P\\x01'.decode('utf-16')"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"745458"
]
},