Class B Oven controller.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include "oven.h"
#include "oven_controller.h"
#include "oven_classb.h"
#include <error_handler.h>
#include <classb_cpu.h>
#include <classb_interrupt_monitor.h>
#include <classb_sram.h>
Functions | |
void | ovenctl_execute_control_step (uint32_t time, uint8_t *wattage, bool *power, enum pot_t potstate) |
Execute oven control step. More... | |
uint16_t | ovenctl_get_plate_temperature (void) |
Reads a 16-bit analog value on ADC channel 0 and returns it. More... | |
Internal test functions | |
static void | ovenctl_periodic_temperature_sanity_check (void) |
Perform a sanity check on the temperature measured by the ADC. More... | |
static void | ovenctl_periodic_classb_tests (void) |
Execute SRAM and CPU tests. More... | |
static void | ovenctl_turn_on_plate (void) |
Run tests and turn on power to simulated oven plate. More... | |
static void | ovenctl_turn_off_plate (uint8_t *wattage, bool *power) |
Turn off power to simulated oven plate, disable tests. More... | |
static void | ovenctl_actuate_induction_element (uint8_t wattage) |
Updates or turns off the signal to the induction element. More... | |
|
static |
Updates or turns off the signal to the induction element.
Converts a wattage value to a signal period. Higher wattage means shorter period, which means more induced power if this was a physical stove top.
wattage | value representing the desired power level. |
References OVEN_FREQ_TC, and tc_write_clock_source().
Referenced by ovenctl_execute_control_step().
void ovenctl_execute_control_step | ( | uint32_t | time, |
uint8_t * | wattage, | ||
bool * | power, | ||
enum pot_t | potstate | ||
) |
Execute oven control step.
This function takes information from the user interface, temperature sensor and plate (QTouch) sensing and controls the output to the induction elements via a frequency signal.
The oven has three states:
time | Current system time in milliseconds. |
*wattage | Pointer to the variable representing the desired effect |
*power | Pointer to the variable controlling whether the induction coils should be actuated. |
potstate | A variable representing the latest information on whether anything is present on the plate (QTouch sensor) |
References ON_ACTUATING, ON_NO_POT, ovenctl_actuate_induction_element(), ovenctl_turn_off_plate(), ovenctl_turn_on_plate(), POT_OFF, POT_ON, POWER_OFF, and rtc_get_time().
Referenced by main().
uint16_t ovenctl_get_plate_temperature | ( | void | ) |
Reads a 16-bit analog value on ADC channel 0 and returns it.
In this application CH0 is set up to read the analog voltage from a simulated thermometer.
References ADC_CH0, adc_get_unsigned_result(), adc_start_conversion(), and adc_wait_for_interrupt_flag().
Referenced by main_execute_simulation_step(), and ovenctl_periodic_temperature_sanity_check().
|
static |
Execute SRAM and CPU tests.
This is an example of how the Class B interrupt monitor is used. The tests performed in this function are not required to be run periodically for Class B certification.
References classb_intmon_increase(), classb_register_test(), classb_sram_test(), and PER_CLASSB_TESTS.
Referenced by ovenctl_turn_on_plate().
|
static |
Perform a sanity check on the temperature measured by the ADC.
This is an example of how the Class B interrupt monitor is used, and as such does not perform a rigorous check.
An error can be induced by removing the jumper between ADC2 and ADC4 on the J2 header on the XPLAINED board.
References classb_error, CLASSB_ERROR_OTHER, classb_intmon_increase(), ovenctl_get_plate_temperature(), temp, and TEMP_SANITY_TEST.
Referenced by ovenctl_turn_on_plate().
|
static |
Turn off power to simulated oven plate, disable tests.
This function modified the simulation input to zero (zero watts, no power input), then turns off the periodic tests and disables monitoring of them.
*wattage | Pointer to the value representing desired power level |
*power | Pointer to the value representing whether the desired power level should be applied to the induction element. |
References classb_intmon_set_state(), M_DISABLE, OVEN_PERIODIC_CLASSB_TC, OVEN_PERIODIC_TEMPTEST_TC, PER_CLASSB_TESTS, tc_reset(), tc_write_clock_source(), and TEMP_SANITY_TEST.
Referenced by ovenctl_execute_control_step().
|
static |
Run tests and turn on power to simulated oven plate.
This functions runs some class B tests, reinitializes Timer/Counters, ADC and DAC used by the oven, then turns on and starts monitoring of periodic tests.
References classb_intmon_set_state(), M_ENABLE, main_init_adc_dac(), main_init_tc(), oven_classb_run_tests(), OVEN_PERIODIC_CLASSB_TC, OVEN_PERIODIC_TEMPTEST_TC, ovenctl_periodic_classb_tests(), ovenctl_periodic_temperature_sanity_check(), PER_CLASSB_TESTS, tc_enable(), tc_set_overflow_interrupt_callback(), tc_set_overflow_interrupt_level(), tc_write_clock_source(), tc_write_period(), and TEMP_SANITY_TEST.
Referenced by ovenctl_execute_control_step().