This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Modeling a CD Player/Radio Using Enumerated Data Types

This example shows a simple model of a CD Player/Radio logic that uses enumerated data types in Simulink® and Stateflow® (new in R2008b).

The heart of the logic for controlling the CD Player/Radio is in the "CdPlayerModeManager" chart. This chart receives user inputs, such as whether a disk has been inserted and the choice for the radio mode (FM, AM, or CD). Then the chart determines the mechanical command to output. For example, this chart is responsible for making sure that a Rewind command is not issued in the absence of a disk in the player. Notice that the data types of input data "RadioReqMode" and "CdReqMode" as well as the output data "CurrentRadioMode" and "MechCmd" are defined as enumerated data types. These types are defined in the MATLAB® files CdRequestMode.m and RadioRequestMode.m. Notice that the enumeration strings such as "CD" or "FM" are accessed directly in the chart for comparisons and assignments.

The output command from the "CdPlayerModeManager" is processed by the chart "CdPlayerBehaviorModel" which models the behavior of the CD Player mechanism.

The inputs to "CdPlayerModeManager" are provided by the chart "UserRequestChart" which is woken up at a periodic rate by Simulink and calls an external MATLAB® file named sfcdplayerhelper.m. This MATLAB® file acts as an intermediary between the Handle Graphics® panel and Simulink.

Was this topic helpful?