Multisim and Ultiboard

cancel
Showing results for 
Search instead for 
Did you mean: 

Automation API MATLAB

Hi. I am writing an automation application with MATLAB as client and Multisim as server. When i run the  script, MATLAB  returns the following error message:
??? Error: Object returned error code: 0x17AC5840

Error in ==> COM_server_multisim at 29
msimcirc.DoACSweep('SweepDecade',npoints,strfrec,stpfrec,outputs);

The error code varies each time. The script i wrote is as follows:

%interfase COM  Multisim
%MultisimInterface.MultisimApp  ProgID  multisim

% First, open the multisim Server.
msim = actxserver('MultisimInterface.MultisimApp');

%conect
msim.Connect;

%class .Circuit ( IMultisimCircuit )
msimcirc = msim.OpenFile('C:\Users\Juan Pablo\Documents\National Instruments\Circuit Design Suite 10.0\prueba_circ_analogico.ms10');

inputs = msimcirc.EnumInputs('SimulationIOAll');
outputs = msimcirc.EnumOutputs('SimulationIOAll');

npoints=int32(50);
strfrec=double(1);
stpfrec=double(10000);
outputs=char(outputs);

msimcirc.SetOutputRequest('V(Probe1)','SimulationInterpolationForceStep',1000,500,0);
msimcirc.DoACSweep('SweepDecade',npoints,strfrec,stpfrec,outputs);

%msimcirc.RunSimulation(0.5,0); %simula 0.5 segundos, pausa = falso
msimcirc.WaitForNextOutput;

while (msimcirc.OutputReady('V(Probe1)') == 0)
end
result=msimcirc.GetOutputData('V(Probe1)');
msim.Disconnect;

I cant figure what i am doing wrong whith the DoACSweep method. Thanks in advance.


0 Kudos
Message 1 of 10
(5,253 Views)
Juan, attach your circuit file. I don't have Matlab but I can make a LV program following your Matlab code and see if I can catch where the error is happening.
Nestor
0 Kudos
Message 2 of 10
(5,222 Views)
Hi. The circuit is quite simple, i am only using it to test the automation API features and then i will move to more complex circuits. Thanks.  
0 Kudos
Message 3 of 10
(5,215 Views)

Hi Juan,

OK, I got it running in LV... first thing you need to try... you cannot call DoACSweep and also RunSimulation... they conflict with each other... DoACSweep by itself is running a simulation already... so discard the RunSimulation step you have in your code...

RunSimulation is equivalent to a Transient Analysis. So you are trying to do a Transient while doing an AC Analysis. If you were looking into doing that you would have to wait for the first analysis to finish (SimulationState) and then call the second analysis.

So, start by getting rid of RunSimulation and see how that goes.

Nestor
0 Kudos
Message 4 of 10
(5,190 Views)
Hi. I already know that, if you read the MATLAB code i copyed above you will notice that the RunSimilation method is commented (%). It has to be something else i guess. Thanks.
0 Kudos
Message 5 of 10
(5,178 Views)

I'm sorry, I don't know Matlab programming so I was not aware that % is a comment...

Where exactly do you get the error then?... are you doing some debugging with breakpoints and step by step to learn where this happens? are you declaring the variable result to be a double array...

Nestor
0 Kudos
Message 6 of 10
(5,175 Views)
The problem is, only, the DoACSweep method. I think this because if, for example, you comment the DoACSweep method and uncomment the RunSimulation method the program runs ok. I think the problem might be in the arguments of that method... In MATLAB you dont have to declare variables.
0 Kudos
Message 7 of 10
(5,169 Views)
Juan,
 
What about the "outputs" variable?... I see that you are doing a:
outputs = char(outputs);
 
What if you comment that line?... when I do it in LabVIEW I get a Variant datatype out of the enumOutputs method, I have to pass the same Variant datatype back into the DoACSweep method.
 
Inside my program I then convert from Variant to a text array, but as far as the method goes I pass the Variant back in...
Nestor
0 Kudos
Message 8 of 10
(5,167 Views)
Nestor,

I wrote char(ouputs) because i thought that variant argument could be the problem, but it is not. You can erase char(outputs) and the error remains the same. All clues point to MATLAB, there is something wrong with it. The Automation API works fine in Visula Basic,  but it wouldnt be the best solution because i have to use MATLAB anyway. Thanks.
0 Kudos
Message 9 of 10
(5,165 Views)
Hi. I cant solve the problem yet but i found a way around it. I do the AC sweep manually with the set input data raw method. It is fairly easy to do it with MATLAB and it works pretty decent. Thanks for the help anyway.
0 Kudos
Message 10 of 10
(5,106 Views)