フィルターのクリア

How can I control a GPIB device's parameters from GUI?

4 ビュー (過去 30 日間)
zeytun
zeytun 2016 年 11 月 30 日
編集済み: zeytun 2016 年 12 月 1 日
Hi,
I wrote a GUI to get the trace from an optical spectrum analyzer (OSA) Ando AQ6317 and to do some processing on that spectrum. My GUI is based on this awesome code: https://www.mathworks.com/matlabcentral/fileexchange/32721-getosatrace.
Anyway, everything works, with a pushbutton I can get the spectrum, analyze it and plot whatever I need. Now I want not only to do this, but also to control the OSA parameters (central wavelength, span, etc.) from my GUI. The communication between the laptop and the OSA is done via a GPIB interface, and obviously the OSA has its commands / program codes for that. For example, the command to change the central wavelength is "CTRWL****.**", so in the Matlab command window I can just write
"query(g1,'CTRWL800')"
and it will do the job. Now the problem is that if I want to change this parameter from my GUI, I need to create an Edit Text and tag it with let's say CWL. So I thought that the command line in the relevant m-file would have been
"query(g1,'CTRWL handles.CWL')"
but unfortunately this is not working. The symbols **.** after CTRWL should be numbers.
Do you think it is possible to solve this problem?

採用された回答

dpb
dpb 2016 年 11 月 30 日
Sure, just build a command string to send...but in
query(g1,'CTRWL handles.CWL')
the 'CTRWL handles.CWL' is a literal string, not the result of the control appended to the other string.
cmd=['CTRWL' handles.CWL.String]; % retrieve value; append to command string
query(g1,cmd)
Do you want query to set a control parameter? (Don't know, haven't done GPIB w/ Matlab, only directly w/ NI Fortran libraries so don't know the toolbox)
  1 件のコメント
zeytun
zeytun 2016 年 12 月 1 日
編集済み: zeytun 2016 年 12 月 1 日
Thank you very much! I made just one correction and it worked perfectly. The correction was "cmd = ['CTRWL' num2str(handles.CWL)];" instead of "cmd = ['CTRWL' handles.CWL.String];"
In the latter case it was giving the following error: "Struct contents reference from a non-struct array object." Not sure what this means :) Thanks again!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInstrument Control Toolbox Supported Hardware についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by