Stateflow User's Guide Previous page   Next Page

Exploring the Fixed-Point "Bang-Bang Control" Example

The Stateflow block performs almost all the logic of the bang-bang boiler model with the exception of the Boiler Plant model subsystem block.

  1. Double-click the Boiler Plant model subsystem block.

  1. The Boiler Plant model block simulates the temperature reaction of the boiler to periods of heating or cooling dictated by the Stateflow block. Depending on the Boolean value coming from the Controller, a temperature increment (+1 for heating, -0.1 for cooling) is added to the previous boiler temperature. The resulting boiler temperature is sent to the digital thermometer subsystem block.

  1. Double-click the digital thermometer subsystem block.

The digital thermometer subsystem produces an 8 bit fixed-point representation of the input temperature with the blocks described in the sections that follow.

temperature sensor Block

The temperature sensor block converts input boiler temperature to an intermediate analog voltage output with a first-order polynomial that results in the following output:

ADC Block

Double-click the ADC block to reveal the following contents:

The ADC subsystem digitizes the analog voltage from the temperature sensor block by multiplying the analog voltage by , rounding it to its integer floor, and limiting it to a maximum of (the largest unsigned 8 bit integer value). Using the value for the output from the temperature sensor block, the new digital coded temperature output by the ADC block, , is given by the following equation:

Gateway In Block

An examination of the Block Parameters dialog for the Gateway In block shows that it informs the rest of the model that is now a fixed-point number with a slope value of and an intercept value of . The Stateflow block Bang Bang Controller receives this output and interprets it as a fixed-point number through the Stateflow data temp, which is scoped as Input from Simulink and set as an unsigned 8 bit fixed-point data with the same values for and set in the Gateway In block.

The values for and are determined from the general expression for a fixed-point number, which is as follows:

Therefore,

Since is now a fixed-point number, it is now the quantized integer of a fixed-point type. This means that of its fixed-point type and results in the following identity:

Since T is the real-world value for the environment temperature, the above equation implies the following identifications:

and

and

By setting to be a fixed-point data both as the output of the Gateway In block in Simulink and the input of the Stateflow Bang Bang Controller block, Stateflow interprets and processes this data automatically in an 8 bit environment with no need for any explicit conversions.


Previous page  Opening the Fixed-Point "Bang-Bang Control" Example Operations with Fixed-Point Data Next page

© 1994-2005 The MathWorks, Inc.