From: babil Bampilis on
Hi all,
I have a serial communication in a s-Function written in cpp. In the mdlStart, I initialize the connection, in mdlOutputs, I get the data from the Input ports and trasnfer them via serial connection to a device. It seems that the mdlOutput runs in a loop, cause it prints the word "success" with ssPrintf many times, which is most propably why it causes matlab to crash.

I want to transfer the data only once. How can I achieve this?
Thanks in advance
babil
From: Guy Rouleau on
"babil Bampilis" <vbampilis(a)iset.uni-kassel.de> wrote in message <hqhoqr$4cp$1(a)fred.mathworks.com>...
> Hi all,
> I have a serial communication in a s-Function written in cpp. In the mdlStart, I initialize the connection, in mdlOutputs, I get the data from the Input ports and trasnfer them via serial connection to a device. It seems that the mdlOutput runs in a loop, cause it prints the word "success" with ssPrintf many times, which is most propably why it causes matlab to crash.
>
> I want to transfer the data only once. How can I achieve this?
> Thanks in advance
> babil

Hi,

Depending on the solver chosen for your model, mdlOutputs is run one or multiple times per simulation time step.

If you have nothing else than that in your model, make sure you use Fixed-Step Discrete. Then if you want mdlOutputs to execute only once, make the model base rate 1sec and the stop time 1sec,

If you need to to run your model longer for some reason, you might want to implement a trigger mechanism in your s-function. Based on an input signal you will then be able to execute the transfer only once.

HTH

Guy
From: babil Bampilis on
thanks, I will try it.

"Guy Rouleau" <guy.rouleau.nospam(a)mathworks.com> wrote in message <hqikjc$qjh$1(a)fred.mathworks.com>...
> "babil Bampilis" <vbampilis(a)iset.uni-kassel.de> wrote in message <hqhoqr$4cp$1(a)fred.mathworks.com>...
> > Hi all,
> > I have a serial communication in a s-Function written in cpp. In the mdlStart, I initialize the connection, in mdlOutputs, I get the data from the Input ports and trasnfer them via serial connection to a device. It seems that the mdlOutput runs in a loop, cause it prints the word "success" with ssPrintf many times, which is most propably why it causes matlab to crash.
> >
> > I want to transfer the data only once. How can I achieve this?
> > Thanks in advance
> > babil
>
> Hi,
>
> Depending on the solver chosen for your model, mdlOutputs is run one or multiple times per simulation time step.
>
> If you have nothing else than that in your model, make sure you use Fixed-Step Discrete. Then if you want mdlOutputs to execute only once, make the model base rate 1sec and the stop time 1sec,
>
> If you need to to run your model longer for some reason, you might want to implement a trigger mechanism in your s-function. Based on an input signal you will then be able to execute the transfer only once.
>
> HTH
>
> Guy