Deprecated: Array and string offset access syntax with curly braces is deprecated in /mnt/hep_web/hep_web/member/n-kota/dokuwiki/inc/init.php on line 542
ja:iseghv [GiriWiki]

ユーザ用ツール

サイト用ツール


ja:iseghv

以前のリビジョンの文書です



Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /mnt/hep_web/hep_web/member/n-kota/dokuwiki/inc/parser/handler.php on line 1458

Warning: Declaration of syntax_plugin_note::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /mnt/hep_web/hep_web/member/n-kota/dokuwiki/lib/plugins/note/syntax.php on line 79

Warning: Declaration of syntax_plugin_note::render($mode, &$renderer, $indata) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /mnt/hep_web/hep_web/member/n-kota/dokuwiki/lib/plugins/note/syntax.php on line 101

Warning: preg_match(): Compilation failed: invalid range in character class at offset 3120 in /mnt/hep_web/hep_web/member/n-kota/dokuwiki/inc/parser/lexer.php on line 118
A PCRE internal error occured. This might be caused by a faulty plugin

====== iseg HV module(NHS)の備忘録 ====== ---- ===== 基本資料 ===== * {{:ja:ds_nhs_standard_en-20140605.pdf|仕様書}} * {{:ja:nhs_scpi_eng.pdf|説明書}} ===== USBを通してのコントロール ===== Linux(macでも同様)からUSBのシリアル通信でコントロールしようとした時にはまったところをメモ。 コントロールは"Standard Commands for Programmable Instruments(SCPI)"という言語?を用いて行う。 自動ステージなんかもSCPIを用いてコントロールできるらしい。 コマンドを送って設定を与えたり、クエリを送って返答を読み出すことで設定、値を読み出すことができる(説明書を参照)。 pythonのmoduleである"pyserial"を用いて通信を行った。 ==== pyserial ==== pythonを用いてシリアル通信を行うためのpython module。 参考になるサイトは[[http://pyserial.sourceforge.net/|ここ]]とか[[http://pythonjp.sourceforge.jp/contrib/pySerial/README_JP.txt|ここ]]とか。 pyserialのインストールは[[https://pypi.python.org/pypi/pyserial|ここ]]からsourceをダウンロードして解凍、ディレクトリに入った後、 python setup.py install で完了。 簡単な以下のようなコードHVtest.pyを <code python> #coding utf-8 import serial import time from time import localtime ser = serial.Serial("/dev/ttyUSB0",9600,timeout=1)## macでやろうとした時は/dev/ttyUSB0->/dev/tty.usbserial-A1030KW5 print "device open status : " + str(ser.isOpen()) ser.write("*IDN?") ser.readline() </code> python HVtest.py で実行。 結果は、ser.isOpen()はTrueを返しており、通信自体は確立している様子。 しかし、"*IDN?"の返答が返ってこない。 結局、鍵は”改行コード”。 module側がWindows型の改行コードであるCR+LF型であるため、それに合わせるようにコマンドを送る際には ser.write("*IDN?\r\n") のようにしなくてはならなかった。 さらに、読み出しも1行目には空行が入るため、readline()を二度行う必要がある。 以上を踏まえて、3 channel のHV,Currentを読み出し、日付ごとにファイルを分けて書き出すモニタリングプログラムを下に示す。 <code python> #coding utf-8 import serial import time from time import localtime ser = serial.Serial("/dev/ttyUSB0",9600,timeout=1) print "device open status : " + str(ser.isOpen()) print "serial name : " + str(ser.name) ser.write("*IDN?\r\n") ser.readline() print ser.readline().replace("\r\n","\n") timestamp = time.strftime("%Y%m%d",localtime()) print " now data taking... " f = open("data{0}.dat".format(timestamp),"w") while True: mtime = time.time() if timestamp != time.strftime("%Y%m%d",localtime(mtime)): f.close timestamp = time.strftime("%Y%m%d",localtime(mtime)) f = open("data{0}.dat".format(timestamp),"w") ser.write(":MEAS:VOLT? (@0-2); CURR? (@0-2)\r\n") ser.readline() dataBuf = ser.readline().replace("\r\n","\n").replace(","," ").replace("V","").replace("A","") f.write(str(mtime)+" "+dataBuf.replace(";"," ")) f.flush() f.close ser.close </code> 出力ファイルには各行にUNIX Time, 3ch のHV, 3ch のCurrentがスペースで区切られて出力される。 ---- ==== VOLT, CURRENT設定項目 ==== :READ で読み出せる項目には、無印, NOMinal, LIMit, BOUnd がある。 それぞれの意味は、 * 無印:software limit * NOM : 最大定格 * LIM : hardware limit (module前面の調整ネジ?で調節可能) * BOU : software limit +- bound の範囲であれば許容。0だと無効になる。

ja/iseghv.1435911915.txt.gz · 最終更新: 2015/07/03 08:25 by kota