COM Object needs to be initialized properly

I am connecting to a COM object (Bode Analyzer 100 from Omicron). However, since I am making a GUI, I need to initialize these variables to be empty so that I can pass them from function to function. However when I do, matlab complains that they are not the right type of variable. What type is this?
These are the 3 commands I use:
automationInterface = actxserver('OmicronLab.VectorNetworkAnalysis.AutomationInterface')
bode = automationInterface.Connect();
OnePortMeasurement=bode.Impedance.CreateOnePortMeasurement;
Thanks, Sarah

6 comentarios

Geoff Hayes
Geoff Hayes el 29 de Ag. de 2018
Sarah - can you show the line (or lines) of code that are responsible for generating the error? Are you creating your GUI with GUIDE and so are updating the handles structure with these three variables? Please clarify.
ADragon
ADragon el 29 de Ag. de 2018
Hi Sarah, as Geoff mentions it would be helpful to know how the error is generated. By the way, the setappdata and getappdata functions are very handy in passing data among GUI windows. Also, unless you are using an older version of Matlab, the actxserver function will try to connect to a running instance of the called application (OmicronLab... in your case). So technically, you could define automationInterface in each one of your functions and not pass anything. AD
The error that I am getting is below. It only happens when I run the collect data code more than once. It seems like when I press the 'x' button, it is not fully closing the COM and leaving some kind of connection open. Thanks, Sarah C.
Error using COM.OmicronLab_VectorNetworkAnalysis_AutomationInterface/Connect
Error in check_Adafruit_Bode_on (line 50)
bode = automationInterface.Connect();
Error in ArrayGUI>acquiredata_pushbutton_Callback (line 156)
[bode, automationInterface, OnePortMeasurement, bodeflag,
automationInterfaceflag,OnePortMeasurementflag] =
check_Adafruit_Bode_on(handles.bodeflag, handles.automationInterfaceflag,
handles.OnePortMeasurementflag, handles.bode, handles.automationInterface,
handles.OnePortMeasurement);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in ArrayGUI (line 43)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)ArrayGUI('acquiredata_pushbutton_Callback',hObject,eventdata,guidata(hObject))
Error using uiwait (line 81)
Error while evaluating UIControl Callback
Geoff Hayes
Geoff Hayes el 29 de Ag. de 2018
Sarah - do you have any code that explicitly closes the connection when you close the GUI (via the x button)? If not, then that could be what is missing and you will need to put some code that does this in the GUI close function.
sandeep singh
sandeep singh el 26 de Nov. de 2018
Hello
Even i am trying to connect, but i want to know whether it is connected using serial com port
Sarah Crimi
Sarah Crimi el 28 de En. de 2019
Hello,
I connected using COM port.
I actually had to make a button that properly turned off the COM port. So, when the x is used, it still throws an error. But when I use the button to turn off the GUI, I can turn it on again. If I stop a test early, I still have to reboot matlab.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Preguntada:

el 28 de Ag. de 2018

Comentada:

el 28 de En. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by