Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.
/ autopolarizer Public archive

Control the automatic polarizer holder with Python (PWA-100 & GSC-01)

License

Notifications You must be signed in to change notification settings

elerac/autopolarizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Automatic Polarizer

ツクモ工学の自動偏光子ホルダー(PWA-100)をシグマ光機の1軸ステージコントローラ(GSC-01)を通して,Pythonで制御します.研究室用に作成.

https://youtu.be/dfmbfFGqxJw

Requirement

Run on command line

python automaticpolarizer.py <degree>

偏光板を指定した角度degreeに回転させます.シリアルポート名は/dev/tty.usbserial-FTRWB1RNがデフォルトになっています.変更する場合は,--portオプションで指定してください.

Use as a module

インスタンスの作成

インスタンスの作成時に接続要求が行われます.

from automaticpolarizer import AutomaticPolarizer
polarizer = AutomaticPolarizer("/dev/tty.usbserial-FTRWB1RN")

リセット

ステージを機械原点に復帰させます.

polarizer.reset()

偏光板の角度

クラスのメンバdegreeは偏光板の角度と連動しています.

print(polarizer.degree) #現在の偏光板の角度を取得
polarizer.degree = 90   #偏光板の角度が90[deg]になるように回転
polarizer.degree += 60  #偏光板の角度が現在の角度から+60[deg]になるように回転

速度の設定

ステージの移動時の最小速度[PPS],最大速度[PPS],加減速時間[mS](最小速度→最大速度or最大速度→最小速度に切り替わるまでの時間)を設定します.最小速度・最大速度の設定範囲は100-20000です.加減速時間の設定範囲は0-1000です.最大速度は最小速度以上の値に設定する必要があります.速度の設定は100[PPS]単位で行う必要があります.

spd_min = 500 #最小速度[PPS]
spd_max = 5000 #最大速度[PPS]
acceleration_time = 200 #加減速時間[mS]
polarizer.set_speed(spd_min, spd_max, acceleration_time)

ジョグ運転

ステージを連続で回転させることができます.

polarizer.jog() #+方向に回転
time.sleep(1) #1秒待つ
polarizer.stop() #ステージ停止

polarizer.jog(reverse=True) #-方向に回転
time.sleep(1) #1秒待つ
polarizer.stop() #ステージ停止

移動中に別の動作を行う

resetdegreeでのステージの移動において,デフォルトでは移動が完了するまで待つ処理を行っています.移動中にも別の処理を行いたい場合は,メンバ変数is_sleep_until_stopFalseに設定してください.

polarizer.is_sleep_until_stop = False #移動完了を待つフラグをFalseにする
polarizer.degree += 180 #移動開始(移動完了を待たずに次の処理に行く)
"""ここに移動中に行う処理を書く"""
polarizer.sleep_until_stop() #明示的に移動完了を待つ

About

Control the automatic polarizer holder with Python (PWA-100 & GSC-01)

Topics

Resources

License

Stars

Watchers

Forks

Languages