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

5 Ansichten (letzte 30 Tage)
zeytun
zeytun am 30 Nov. 2016
Bearbeitet: zeytun am 1 Dez. 2016
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?

Akzeptierte Antwort

dpb
dpb am 30 Nov. 2016
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 Kommentar
zeytun
zeytun am 1 Dez. 2016
Bearbeitet: zeytun am 1 Dez. 2016
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!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Instrument Control Toolbox Supported Hardware finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by