|On this page…|
When you simulate the model, you get these results:
To explore the model, follow these steps:
The subsystem appears.
The Boiler Plant model subsystem 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.
The subsystem appears.
The digital thermometer subsystem produces an 8-bit fixed-point representation of the input temperature with the blocks described in the sections that follow.
The sensor block converts input boiler temperature (T) to an intermediate analog voltage output V with a first-order polynomial that gives this output:
V = 0.05 × T + 0.75
Double-click the ADC block to reveal these contents:
The ADC subsystem digitizes the analog voltage from the sensor block by multiplying the analog voltage by 256/5, rounding it to its integer floor, and limiting it to a maximum of 255 (the largest unsigned 8-bit integer value). Using the value for the output V from the sensor block, the new digital coded temperature output by the ADC block, Tdigital, is given by this equation:
Tdigital = (256/5) × V = (256 × 0.05/5) × T + (256/5) × 0.75
The Linear fixed point conversion block informs the rest of the model that Tdigital is a fixed-point number with a slope value of 5/256/0.05 and an intercept value of –0.75/0.05. 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 S and B set in the Linear fixed point conversion block.
The values for S and B are determined from the general expression for a fixed-point number:
V = SQ + B
Q = (V – B)/S = (1/S) × V + (–1/S) × B
Since Tdigital is now a fixed-point number, it is now the quantized integer Q of a fixed-point type. This means that Tdigital = Q of its fixed-point type, which gives this relation:
(1/S) × V + (–1/S) × B = (256 × 0.05/5) × T + (256/5) × 0.75
Since T is the real-world value for the environment temperature, the above equation implies these relations:
V = T
1/S = (256 × 0.05)/5
S = 5/(256 × 0.05) = 0.390625
(–1/S) × B = (256/5) × 0.75
B = –(256/5) × 0.75 × 5/(256 × 0.05) = –0.75/0.05 = 15
By setting Tdigital to be a fixed-point data as the output of the Linear fixed point conversion block and the input of the Stateflow block Bang-Bang Controller, the Stateflow chart interprets and processes this data automatically in an 8-bit environment with no need for any explicit conversions.