Multisim and Ultiboard

cancel
Showing results for 
Search instead for 
Did you mean: 

Multisim API with Matlab

I am trying to use matlab to run a bunch of simulations in Multisim. I managed to get it to talk to multisim and run the simulations and return the data. Now, the whole point of this is to use matlab to automatically change parameters in the circuit which is where my problem starts. I can use the command

 

circuit.CircuitParameterValue('R1')

 

which correctly returns the value of R1 which is a parameter. So how to I change that parameter say from 10 to 11? I tried a lot of combinations of "=11" with the above to no avial. If you look in the manual it does not have an example it just says this:

 

Syntax

Property CircuitParameterValue ( _
       ByVal
CircuitParameterName As String) _
       As Double

Parameters

CircuitParameterName—The name of the circuit parameter to get/set.

Remarks

This read/write property allows the user to get/set the value of a circuit parameter.

If the circuit parameter does not exist in the circuit, an error occurs.

Attempting to change circuit parameter values while a simulation is running causes an error. The simulator must be in the stopped state.

If a circuit parameter contains an expression, it will be evaluated first. For example if x=1, x+1 will return 2, not “x+1”. If an error occurs, 0 will be returned.

When setting a circuit parameter value, only numeric values are supported, not expressions.

To access parameters inside sub-sheets, use:

<HB/SC refdes>.<parameter name>

For example, SC1.Vin

 

 

 

Anything helps, especially an autmoation example from something other than labview.

 

 

 

 

 

0 Kudos
Message 1 of 7
(7,964 Views)

Hello,

 

Are you creating this API, or are you using an existing one?

Randy @Rscd27@
0 Kudos
Message 2 of 7
(7,883 Views)
I'm using the API COM toolkit that comes with multisim. It connects fine and runs if I use the .RunSimulation command but I don't know how to change parameters.
0 Kudos
Message 3 of 7
(7,869 Views)

Can you tell me where in the multisim enviorment do you find the COM toolkit, I have not been able to found any info related to it.

Randy @Rscd27@
0 Kudos
Message 4 of 7
(7,814 Views)
You have to use 32bit matlab because the activex driver or whatever for multisim is 32bit. If you lookin the help section under automation Api that is the extent of what I have found. I used the same code as this to do the connection http://www.mathworks.com/matlabcentral/newsreader/view_thread/170411

I'm now using the docommandline and alter commands to change parameters which is less convenient but still seems to work.
0 Kudos
Message 5 of 7
(7,802 Views)

Did you do that post?

 

I have to be honest I have never see that API before. I will try to do some research.

Randy @Rscd27@
0 Kudos
Message 6 of 7
(7,779 Views)

I would still like to get this to work, I posted this on the matlab forum recently:

 

I am working with NI multisim and have an issue with a few of the commands using a COM interface. I can get it to connect and run certain commands but I have not been able to change values via matlab. This part of the code seems to work:

 % Open interface to multisim
 msim = actxserver('MultisimInterface.MultisimApp');
 %conect
 msim.Connect;
 %set circuit 
 Circuit = msim.OpenFile('filename.ms13');
 %request inputs from multisim
 inputs = Circuit.EnumInputs('SimulationIOAll');

I can successfully request the value of resistor R1 from the circuit using this command:

 Circuit.RLCValue('R1')

But I cannot change the value of R1 from matlab. For reference, within VB I can change the resistor value with this command

 Circuit.RLCValue("R1") = 2

in matlab when I try the same command I get the following response:

 No public field RLCValue exists for class
Interface.NI_Circuit_Design_Suite_Multisim_13.0.IMultisimCircuit.

I think this is because it is trying set an equality in matlab whereas in VB it seems to be sending this command to multisim somehow.

Any help is appreciated. The helpfile for this command is here http://zone.ni.com/reference/en-XX/help/375482A-01/multisim/rlcvalue/#wp270431 and the helpfile for the API is here http://zone.ni.com/reference/en-XX/help/375482A-01/TOC275.htm

0 Kudos
Message 7 of 7
(6,712 Views)