|On this page…|
This example modifies the Simulink® example, sldemo_bounce, by displaying the position and velocity signals on Gauges Blockset™ blocks contained in another model window.
To open the original example model, enter sldemo_bouncesldemo_bounce in the MATLAB® Command Window. To open the modified version, enter gauges_bouncegauges_bounce. The modified version includes two ActiveX® Control blocks on the signals that feed into the Scope block:
Create a new model called gauges_bounce_gui and copy the following Gauges Blockset blocks into it:
The Generic Linear Gauge block from the Linear Gauges library. Change the block's name to Position.
The Amp Meter block from the Angular Gauges library. Change the block's name to Velocity.
If you want to customize the gauges, particularly the range of values that they can display, then use this optional procedure:
From the Needles panel, set Value to 0. This moves the needle so that it points to zero.
From the Scales panel, set Min to -30, set Max to 30, select Backward, set Start to 10, and set Stop to 170. This causes the block to display values between -30 and 30 along the right half of a circle.
You might also want to enlarge the blocks. They should now look like this.
Open the original sldemo_bounce model and save it in your working folder as gauges_bounce. Insert two ActiveX Control blocks on the signals that feed into the Scope block. To connect the ActiveX Control blocks to the controls, make these changes in the Block Parameters dialog box in each of the ActiveX Control blocks:
Clear the In-block control check box, because the signal is being communicated between ActiveX Control blocks in one window and ActiveX Control blocks in another window. When you clear the In-block control check box, the number of fields on the dialog box changes.
In the Input property field, specify NeedleValue for the velocity block and PointerValue property for the position block. This property controls the current values of these gauges. Doing this passes the value of the input signal to this property.
Specify the path of each gauge in the Handle location field. The new model is named gauges_bounce_gui, so the path is gauges_bounce_gui/Velocity for the velocity block and gauges_bounce_gui/Position for the position block.
The dialog boxes look like this:
ActiveX Control Connected to Amp Meter (Velocity)
ActiveX Control Connected to Generic Linear Gauge (Position)
Now, when you simulate the main model window, the gauges in the auxiliary model window reflect the velocity and position of the bouncing ball.