파이썬으로 THORLABS 자동 무대 이동 [연구용]
[2회] Python으로 카메라를 제어[연구용]
입문
파이썬으로 자동 무대를 제어하는 방법을 공유하고 싶습니다.Python에서 Thorlabs Inc.의 자동 단계를 제어하는 방법에 대한 글을 찾지 못했습니다.그래서 나는 반복적으로 얻은 경험의 정수를 기사로 쓰고 싶다.
이번에 사용한 자동 무대는 Thorlabs Inc.의 무대입니다.이 무대는 이 회사의 현미경에 편입될 수 있다.
자제 현미경은 확장성이 있기 때문에 자유도가 커진다.집중 측정과 분석을 통해 아날로그 현미경 관찰을 자동화하고 다변량 데이터 분석을 틈새 없이 가져올 수 있다.
Thorlabs 자동 단계 동작
개발 환경
사용 기재
소형 스텝 모터 ZFS25B(Thorlabs Inc.)
설치
Thorlabs 자동 무대를 이동하기 위해서는 다음 두 가지가 필요합니다.
여기에서 kinesis를 설치합니다.
kinesis는 로컬 PC 환경에서 실행되는 GUI 기반 소프트웨어 그룹과 DLL(동적 링크 라이브러리) 파일을 포함하는 라이브러리입니다.
컴퓨터 환경에 따라 버전을 선택하십시오.GUI 기반 응용 프로그램이 첨부되어 있지만 이번에 사용하지 않으면
Thorlabs.MotionControl.KCube.StepperMotor.dll
다음 디렉터리에 저장할 수 없습니다.C:/Program Files/Thorlabs/Kinesis
이번에는 Windows 10의 x64이기 때문에 선택Kinesis 64-Bit Software for 64-Bit Windows
.다운로드를 엽니다.설치 중...
완성
S L-Equipment 모듈
Thorlabas 자동 단계를 제어하는 모듈 MSL-Equipment를 설치합니다.
이 라이브러리는 뉴질랜드 연구기관 Measurement Standards Laboratory of New Zealand에서 무상으로 발표했다.
먼저 다음 명령을 복사하고 실행합니다.
conda 명령에서 가상 환경thorlabs_데모를 만들다.
conda create -n thorlabs_demo python=3.6
다음 명령을 사용하여 MSL-Equipment를 설치합니다.pip install https://github.com/MSLNZ/msl-equipment/archive/master.zip
예를 들어, Anaconda prompt 에서 다음 작업을 수행합니다.설치가 완료되었습니다.준비됐네.
설치 설명 (원문)
https://msl-equipment.readthedocs.io/en/latest/install.html
동작 확인
예제 프로그램은 다음 디렉토리에서 찾습니다
kst101.py
.C:\Users\あなたのユーザーネーム\anaconda3\Lib\site-packages\msl\examples\equipment\resources\thorlabs
너는 아래의 프로그램을 복사할 수 있잖아.그럼 샘플 절차를 볼게요.
serial='26001809'
의 부분은 자신이 사용하는 설비의 서열 번호로 바꾸면 움직일 수 있다.kst101.py
"""
This example shows how to communicate with Thorlabs KST101, KCube Stepper Motor.
"""
# this "if" statement is used so that Sphinx does not execute this script when the docs are being built
if __name__ == '__main__':
import os
from pprint import pprint
from msl.equipment import EquipmentRecord, ConnectionRecord, Backend
from msl.equipment.resources.thorlabs import MotionControl
# ensure that the Kinesis folder is available on PATH
os.environ['PATH'] += os.pathsep + 'C:/Program Files/Thorlabs/Kinesis'
# rather than reading the EquipmentRecord from a database we can create it manually
record = EquipmentRecord(
manufacturer='Thorlabs',
model='KST101',
serial='26002319', # update the serial number for your KST101
connection=ConnectionRecord(
backend=Backend.MSL,
address='SDK::Thorlabs.MotionControl.KCube.StepperMotor.dll',
),
)
def wait():
motor.clear_message_queue()
while True:
status = motor.convert_message(*motor.wait_for_message())['id']
if status == 'Homed' or status == 'Moved':
break
position = motor.get_position()
real = motor.get_real_value_from_device_unit(position, 'DISTANCE')
print(' at position {} [device units] {:.3f} [real-world units]'.format(position, real))
# avoid the FT_DeviceNotFound error
MotionControl.build_device_list()
# connect to the KCube Stepper Motor
motor = record.connect()
print('Connected to {}'.format(motor))
# load the configuration settings (so that we can use the get_real_value_from_device_unit() method)
motor.load_settings()
# start polling at 200 ms
motor.start_polling(200)
# home the device
print('Homing...')
motor.home()
wait()
print('Homing done. At position {} [device units]'.format(motor.get_position()))
# move to position 100000
print('Moving to 100000...')
motor.move_to_position(100000)
wait()
print('Moving done. At position {} [device units]'.format(motor.get_position()))
# move by a relative amount of -5000
print('Moving by -5000...')
motor.move_relative(-5000)
wait()
print('Moving done. At position {} [device units]'.format(motor.get_position()))
# jog forwards
print('Jogging forwards by {} [device units]'.format(motor.get_jog_step_size()))
motor.move_jog('Forwards')
wait()
print('Jogging done. At position {} [device units]'.format(motor.get_position()))
# stop polling and close the connection
motor.stop_polling()
motor.disconnect()
# you can access the default settings for the motor to pass to the set_*() methods
print('\nThe default motor settings are:')
pprint(motor.settings)
kst101의 뒷면에는 8자리 시퀀스 번호가 있습니다.위 프로그램의
serial='26001809'
을 serial='26002319'
로 변경합니다.실행 프로그램이 실행되면 완성됩니다.
다른 알 수 없는 곳에 대한 문의는 아래 표에서 쉽게 연락하십시오.
Reference
이 문제에 관하여(파이썬으로 THORLABS 자동 무대 이동 [연구용]), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/opto-line/items/68e144b2ee2e5b733f3d텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)