Control Merging Signals with the Push Button Block
This example model is a modified version of the Merging Signals example. The
mergedemo model illustrates how to use Simulink® to merge two different signals using source blocks and triggered subsystems. In the
mergedemo model, a square wave enables and disables the triggered subsystems that provide input to the Merge block. In this model, you can control the enable signal for the triggered subsystems using the Signal Select Push Button block.
To create this model from the
1. Delete the Discrete Pulse Generator block controlling the triggered subsystem and the Scope block.
2. Add a Push Button block, an Outport block, a Constant block, and a Dashboard Scope block.
3. Connect the Outport block to the output of the Merge block.
4. Display the output signal of the Merge block on the Dashboard Scope.
5. Connect the Constant block to the input of the Data Type Conversion block and specify a variable name as its value. This model uses the variable name
signal_select. Click the
Unrecognized functions or variables error, and create the variable in the Model Workspace.
Now, the variable
signal_select controls the triggered subsystems.
6. Press Ctrl+D to update the diagram so the variable you just created is available for connection.
7. Connect the Push Button block to the
In this example, the On Value for the Push Button block is set to
0. When you press the Push Button block, the value of
signal_select changes to
0, enabling the triggered subsystem connected to the sawtooth wave. If you want pressing the Push Button block to enable the triggered subsystem connected to the sine wave, set the On Value for the Push Button block to
This model uses simulation pacing to slow model execution so you can interact with the model during simulation. For more information about simulation pacing, see Simulation Pacing Options.
Run the simulation. As the model simulates, press and hold the Signal Selection Push Button block. You can observe the effect of pressing the Push Button block on the Dashboard Scope block.