Hi all, I am trying to run a co-simuliation between Simulink and Simplorer. In Simplorer, simulation is successfully completed but Simulink reports an error.
Frankly, this error is not clear. I think if your waveforms are coherent and the results of your simulation too, you can put it aside for now. Otherwise, you should try a simpler model to chek if it comes from the cosim setup or one of your models
I try to run this co-simulation on the simplest possible model - in Simulink is only a constant connected with the s-function. Simulink reports error, in Simplorer is the simulation succesfull but the output is zero.
Okay. Check out this procedure. There should be no error from Simulink if every step is verified:
You need administrator rights!! Make sure!!
You need a compiler running in Matlab. Check with mex –setup. If you don't have one already, install it.
Set the Matlab path in Simplorer: Tools –> Options -> General Options - > MiscellaneousOptions -> MATLAB Optimization set the MATLAB path.
Set the Ansys Path in MATLAB: In Environment -> Set Path -> Add C:\Program Files\AnsysEM\AnsysEM16.2\Win64\cpl\matlab\r2014
In Matlab create your model with an s-function called “AnsoftSFunction” , now you get that dialog from the manual.
In the link assignment area add as many Inputs and Outputs you need (the little button with the yellow flash). Select One SIMULINK IN and one SIMPLORER OUT then press link.
Press OK and an s-function with as many inputs and outputs you selected will be created. Build your Simulink model and save as *.mdl
Now go to Simplorer and create Simulink Subcircuit: Simplorer Circuit -> Subcircuit -> Add Simulink Component… Select Read link information from the file. Connect to the simulink model you just created. Little button with three dots. Wait until all inputs and outputs are loaded. Select the Pin option for all inputs and outputs then press OK.
Design your Simplorer circuit and save it. Then switch back to Simulink. In Simlink double click the s-function block. Select link information from file. Select the simplorer file you just created. Then press OK
Now both models are connected. There are a couple of more things you need to take care of, like simulation times and solvers. But you will figure that out yourself.
Sorry but you did not help me - I have already found this instruction in the mathworks forum before (as you probably found too using google). I am looking for someone with similar problem as I have.
Problem solved! I have contacted both Matlab and Ansys support. It was not helpful at first but then I recieved as simple cosimulation as I tried to run from Ansys support and it works. The problem is that this Sim2Sim cosimulation does not run if I try send data only from Simulink to Simplorer. If I am sending data only from Simplorer to Simulink or in both directions, the cosimulation works.
Maybe it is a standard situation but I have nowhere found this information and I did not try to change the data flow direction; therefore I was almost desperate because of this actually banal problem :-)
@Jan Laksar I am also doing the cosimulation using AnsoftSFunction in the same way. No error is thrown but something like this appears--> [info] [Sim2000App] Info - Simulation stopped by user. >> Calculate at t=2e-06 s (11:04:20 AM Feb 19, 2020). The Simulation stops at 2 microsecond. Time-step of 1 microsecond has been chosen in both simulink (powergui block and components) and simplorer. Also, Can you please explain--" The problem is that this Sim2Sim cosimulation does not run if I try send data only from Simulink to Simplorer. If I am sending data only from Simplorer to Simulink or in both directions, the cosimulation works. " a little more. How to configure the data flow? are you talking about data logging of simulink and creation of .sdb file in simplorer? How can I implement the Adaptive time-step?