Zgrkpnr
Zgrkpnr

Reputation: 1231

How can I change a Block parameter in Simulink with Serial Port?

I am loading my Simulink Model to a microprocessor. After that I want to change a value of a Block parameter.

In the picture below the data comes to Matlab Function block is coming from Serial Port. Now, appearently th incoming data is assigned to input u of Matlab Function block. In that Matlab Function block I want to write a code that changes , for example, coefficient of s in the Transfer Fcn block. Or it can change any other parameter you can give in code hypothetically.

If anybody can give me any solution that would be ver much appreaciated!. Thank you in advance.

enter image description here

Upvotes: 0

Views: 1763

Answers (1)

Drake
Drake

Reputation: 857

Substitute a custom-made subsystem for the transfer function whose parameters have to change, and create the subsystem from basic blocks so that coefficients can be read from signal sources. You might be interested in this

http://blogs.mathworks.com/seth/2011/03/08/how-do-i-change-a-block-parameter-based-on-the-output-of-another-block/

Even if you don't want to change parameters at every time step, the restriction

"[...] calls to set_param also preclude the model from ever being compiled into a real-time application."

seems relevant to your case.

Anyway, as far as I know the post linked above still applies in 2014.

Hope that helps.

Upvotes: 1

Related Questions