Class B Oven Simulation plant.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
Physical properties of the model | |
#define | C_POT 20.0 |
Pot heat capacity. More... | |
#define | C_PLATE 2.0 |
Plate heat capacity. More... | |
#define | K_POT 7 |
Pot heat conductivity. More... | |
#define | K_PLATE 2 |
Plate heat conductivity. More... | |
#define | ENV_TEMP 25 |
Environment temperature. More... | |
Functions | |
float | oven_plant_get_state_temp (uint8_t no) |
Read the internal simulation states. More... | |
void | oven_plant_init (void) |
Initialize the oven's physical state. More... | |
void | oven_plant_sim_step (enum pot_t pot) |
Perform a simulation step. More... | |
Internal functions | |
static uint16_t | oven_plant_read_signal_period (void) |
Read the period of the frequency signal capture. More... | |
static float | oven_plant_calculate_u_from_period (uint16_t p) |
Map the signal period to a power level for the simulation plant. More... | |
Variables | |
static float | state [2] = {20 * C_PLATE, 20 * C_POT} |
State variables for the simulation: Plate and Pot temperature. More... | |
#define C_PLATE 2.0 |
Plate heat capacity.
Referenced by oven_plant_get_state_temp(), oven_plant_init(), and oven_plant_sim_step().
#define C_POT 20.0 |
Pot heat capacity.
Referenced by oven_plant_get_state_temp(), oven_plant_init(), and oven_plant_sim_step().
#define ENV_TEMP 25 |
Environment temperature.
Referenced by oven_plant_sim_step().
#define K_PLATE 2 |
Plate heat conductivity.
Referenced by oven_plant_sim_step().
#define K_POT 7 |
Pot heat conductivity.
Referenced by oven_plant_sim_step().
|
static |
Map the signal period to a power level for the simulation plant.
In effect, this function acts as the induction coil in the oven.
Its return value reflects wattage
as used in the controller and the user interface.
p | Period of frequency signal, from oven_plant_read_signal_period() |
Referenced by oven_plant_sim_step().
float oven_plant_get_state_temp | ( | uint8_t | no | ) |
Read the internal simulation states.
no | The state variable to get, 0 for plate and 1 for pot |
References C_PLATE, C_POT, and state.
Referenced by main_execute_simulation_step().
void oven_plant_init | ( | void | ) |
|
static |
Read the period of the frequency signal capture.
References OVEN_FREQ_CAPT_TC, TC_CCA, tc_clear_cc_interrupt(), tc_is_cc_interrupt(), and tc_read_cc_buffer().
Referenced by oven_plant_sim_step().
void oven_plant_sim_step | ( | enum pot_t | pot | ) |
Perform a simulation step.
This function first reads the received frequency signal representing the power level the plate element is actuated with, then performs a simulation step and outputs the simulated temperature of the plate element as an analog value via DACB on the pin marked ADC2.
The simulation plant is a discretized version of the continuous system: \( \dot{x} = \mathbf{F}*\vec{x} + \mathbf{B}*\vec{u} \), where:
\[ \begin{array}{c} \mathbf{F} = \left[ \begin{array}{c c} \frac{-1}{C_\textnormal{plate} * K_\textnormal{plate}} & 0 \\ \\ 0 & \frac{-1}{C_\textnormal{pot} * K_\textnormal{pot}} \end{array} \right] \\ \vec{x} = \left[ \begin{array}{c} E_\textnormal{plate} \\ \\ E_\textnormal{pot} \end{array} \right] \\ \mathbf{B} = \left[ \begin{array}{c c} 1 & 0 \\ \\ 0 & 1 \end{array} \right] \\ \vec{u} = \left[ \begin{array}{c} \frac{T_\textnormal{environment}}{K_\textnormal{plate}} \\ \\ \frac{T_\textnormal{environment}}{K_\textnormal{pot}} \end{array} \right] \end{array} \\ \]
in the case when the pot is OFF the plate.
This corresponds to the plate and the pot cooling separately by Newton's law of cooling because no power can be induced when the pot is not on the plate.
When the pot is ON the stove, the system is similar, but F is modified by adding heat transfer between the plate and the contents of the pot, and disregarding heat loss from the plate to the environment. Likewise u is modified by adding energy induction into the bottom of the pot, simplified here as being the same point as the plate:
\[ \begin{array}{c} \mathbf{F} = \left[ \begin{array}{c c} \frac{-1}{C_\textnormal{plate}* K_\textnormal{plate}} & \frac{1}{C_\textnormal{pot}* K_\textnormal{plate}} \\ \\ \frac{1}{C_\textnormal{plate}* K_\textnormal{plate}} & \frac{-1}{C_\textnormal{pot}* K_\textnormal{plate}} - \frac{1}{C_\textnormal{pot} * K_\textnormal{pot}} \end{array} \right] \\ \vec{u} = \left[ \begin{array}{c} \delta E_\textnormal{induced} \\ \\ \frac{T_\textnormal{environment}}{K_\textnormal{pot}} \end{array} \right] \end{array} \]
pot | Whether the pot is on or off the plate. |
References C_PLATE, C_POT, DAC_CH0, dac_set_channel_value(), dac_wait_for_channel_ready(), ENV_TEMP, K_PLATE, K_POT, oven_plant_calculate_u_from_period(), oven_plant_read_signal_period(), POT_OFF, POT_ON, and state.
Referenced by main_execute_simulation_step().
State variables for the simulation: Plate and Pot temperature.
Referenced by classb_intmon_callback(), classb_intmon_increase(), classb_intmon_set_state(), oven_plant_get_state_temp(), oven_plant_init(), and oven_plant_sim_step().