| 1 | = VXI11 のGPIBアドレス指定 = |
| 2 | |
| 3 | streamdeviceを使用して LAN/GPIBコンバータ E2050 or E5810 を使用してGPIB機器を制御する際に、GPIBアドレスの指定方法がわからずに苦労したので、例を記述しておく。 |
| 4 | |
| 5 | == 経緯 == |
| 6 | |
| 7 | PF-ARにてビームプロファイル計測のために、NDフィルタを制御するGPIB機器をstreamdeviceで制御しようとしたところから話は始まった。[[br]] |
| 8 | GPIB機器は シグマ光機 Mark-5A だったが、以前作成した シグマ光機 Mark-1 をLAN/Serialコンバータで制御していたので、ほぼそのままIOCを流用して、VXI11用に修正したものを使用した。[[br]] |
| 9 | IOCを起動し、定期的にステータスを取得するコマンドを実行すると、 |
| 10 | |
| 11 | {{{ |
| 12 | 2017/04/27 14:46:37.880981 PS1 TEST:OPT:NDfilter:getPOS1: asynError in write: PS1 write request failed |
| 13 | }}} |
| 14 | |
| 15 | と表示され、コマンドの書き込みができない状態だった。[[br]] |
| 16 | E2050->E5810とLAN/GPIBコンバータを変えたり、pythonのVXI11制御パッケージを使ってみたりして、機器が正常に動くことは確認できた。[[br]] |
| 17 | IOCでGPIBアドレス設定をする所がないのに気付いて、st.cmdのvxi11Configureをみたが設定項目がない。[[br]] |
| 18 | その後、色々と調べてみると、streamdeviceに設定することが分かり、動作することが確認できた。 |
| 19 | |
| 20 | == 設定例 == |
| 21 | |
| 22 | 一部を抜粋して例示する。 |
| 23 | |
| 24 | === protocol file === |
| 25 | |
| 26 | {{{ |
| 27 | Terminator = CR LF; |
| 28 | Timeout = 10000; |
| 29 | |
| 30 | : |
| 31 | |
| 32 | getPOS { |
| 33 | out "Q:"; |
| 34 | in "%*c%d:%(\$1)d:%*c%*c%*c"; |
| 35 | } |
| 36 | }}} |
| 37 | |
| 38 | === db file === |
| 39 | |
| 40 | |
| 41 | {{{ |
| 42 | record(longin, "$(user):getPOS1") |
| 43 | { |
| 44 | field(DESC, "Get relative position 1") |
| 45 | field(DTYP, "stream") |
| 46 | field(INP, "@Sigma_MK5A.proto getPOS($(user):getPOS2) $(dev) $(addr)") |
| 47 | field(SCAN, "$(scan)") |
| 48 | } |
| 49 | |
| 50 | record(longin, "$(user):getPOS2") |
| 51 | { |
| 52 | field(DESC, "Get relative position 2") |
| 53 | } |
| 54 | }}} |
| 55 | |
| 56 | |
| 57 | === st.cmd === |
| 58 | |
| 59 | {{{ |
| 60 | #!../../bin/linux-x86_64/Sigma_MK5A |
| 61 | |
| 62 | ## You may have to change Sigma_MK5A to something else |
| 63 | ## everywhere it appears in this file |
| 64 | |
| 65 | < envPaths |
| 66 | |
| 67 | cd ${TOP} |
| 68 | |
| 69 | epicsEnvSet("USER", "TEST:OPT:NDfilter") |
| 70 | |
| 71 | epicsEnvSet("DEV", "PS1") |
| 72 | epicsEnvSet("ADDR", "10") |
| 73 | epicsEnvSet("SCAN", "1 second") |
| 74 | |
| 75 | |
| 76 | ## Register all support components |
| 77 | dbLoadDatabase "dbd/Sigma_MK5A.dbd" |
| 78 | Sigma_MK5A_registerRecordDeviceDriver pdbbase |
| 79 | |
| 80 | epicsEnvSet("STREAM_PROTOCOL_PATH", ".:../../Sigma_MK5AApp/Db") |
| 81 | ## Load record instances |
| 82 | dbLoadRecords "db/Sigma_MK5A.db", "user=$(USER),scan=$(SCAN),dev=$(DEV),addr=$(ADDR)" |
| 83 | vxi11Configure($(DEV),"172.xxx.xxx.xxx",0,"0.0","gpib0",0,0) |
| 84 | |
| 85 | ## Set this to see messages from mySub |
| 86 | #var mySubDebug 1 |
| 87 | |
| 88 | ## Run this to trace the stages of iocInit |
| 89 | #traceIocInit |
| 90 | |
| 91 | cd ${TOP}/iocBoot/${IOC} |
| 92 | iocInit |
| 93 | |
| 94 | }}} |
| 95 | |
| 96 | |
| 97 | ここで一番重要なのは、'''VXI11の場合、GPIBアドレスを記述するのは、DBファイルのINP fieldであり、vxi11Configure ではない'''ことである。[[br]] |
| 98 | python等では、vxi11Configure の "gpib0" に "gpib0,10"というように記述するのが普通だが、streamdeviceでは違うらしい。[[br]] |
| 99 | |
| 100 | |
| 101 | == 参照HP == |
| 102 | |
| 103 | [http://epics.web.psi.ch/software/streamdevice/doc/setup.html User's Guide/Setup/6. Configure the Records] |