Sine modulator example - Step 5

To demonstrate parameter setting and linking mechanisms, let us set the model instance parameter values of our example. Different methods for achieving the same result are demonstrated here such as linking and export.

Set an actual parameter of the Ramp instance

First, you must set the actual parameters of the Ramp instance in the Sine Generator module.

  1. Select the Model Editor Window containing the Sine Generator module.
  2. Click on the Ramp model instance.
  3. Click on the value field of the parameter step.
  4. Set the value to 2*PI*$Frequency/$SampleRate.
  5. Save the model using the tool button Save Model (Ignore the construction errors).

You have now set the actual parameter step of the Ramp instance to an expression that contains the formal model parameter names. This realizes indirect linking between the Ramp parameter and the Sine Generator parameter.

(a) Sine Generator module properties (b) Ramp instance properties

Export actual parameters of the Sine Generator instance

The next step is to set the actual parameter of the Sine Generator instance in the Sine Modulator model. The Sine Generator has two actual parameters Frequency and SampleRate. Since the sample rate should be constant in the whole system model hierarchy it should be settable on the system model level. The Frequency of the sine modulator should be a parameter on the system model level. Therefore, it is necessary to export the SampleRate and Frequency parameters to the next higher model level. Follow the steps below to export these two parameters.

  1. Select the Model Editor Window that contains the Sine Modulator module.
  2. Click on the Sine Generator model instance in the Model Editor Window.
  3. Right-click on the parameter Frequency, and click Export.
  4. Right-click on the parameter SampleRate, and click Export.
  5. Save the model using the tool button Save Model (Ignore the construction error messages).

The green arrows in both fields indicate that these parameters are successfully exported.

By exporting the actual parameters Frequency and SampleRate of the Sine Generator instance, you have automatically created the two formal model parameters of the Sine Modulator module.

(a) Sine Modulator module properties (b) Sine Generator instance properties

Create system model parameters

The last step is to create the system model parameters. You need two different frequencies; one for the signal frequency, and a carrier frequency for the sine modulator as well as a system model parameter for the sample rate.

Export actual parameters of the second Sine Generator instance

  1. Select the Model Editor Window that contains the Sine Modulator System model.
  2. Click on the Sine Generator model instance.
  3. Right-click on the parameter Frequency, and click Export As.
  4. Set the name of exported parameter to SignalFrequency and click OK.
  5. Right-click on the parameter SampleRate, and click Export.

Export and link actual parameters of the Sine Modulator instance

  1. Click on the Sine Modulator model instance.
  2. Right-click on the parameter Frequency, and click Export As.
  3. Set the name of exported parameter to CarrierFrequency and click OK.
  4. Right-click on the parameter SampleRate, point to Link to, and click on SampleRate.

Set Sine Modulator System parameters

  1. Click on the Sine Modulator System model background.
  2. Click on the value field of the parameter SignalFrequency and enter the value PI/100
  3. Click on the value field of the parameter CarrierFrequency and enter the value 0.2*PI.
  4. Save the model using the tool button Save Model, ignore the construction error messages.

You have created the system parameters SignalFrequency, CarrierFrequency, and SampleRate by exporting the model instance parameter. However, the setting of the actual parameter SampleRate of the Sine Modulator model instance was realized by linking the parameter to the existing system model parameter SampleRate. Now you can control the whole model using system parameters. By setting their Scope to External in the System Properties window, you can control them directly in the Simulation Properties window (see Simulation with MLDesigner).

The next step is to connect the model instances.