Microchip® Advanced Software Framework

oven.h File Reference

Class B Oven settings.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

Macros

#define oven_wdt_periodic_reset()
 Reset the WDT when OVEN_WDT_RESET_PERIOD has passed. More...
 
Timing configurations
#define OVEN_WDT_RESET_PERIOD   1250
 Number of RTC ticks between WDT resets. More...
 
#define OVEN_SIM_STEP_TIME   100
 How often a simulation step should be executed [ms]. More...
 
#define OVEN_CTL_STEP_TIME   20
 How often a control step should be executed [ms]. More...
 
Simulation control signal timers selection
#define OVEN_FREQ_TC   TCC0
 Timer used to output frequency signal controlling the induction element. More...
 
#define FREQ_TIMER_PERIOD_INIT   0x100
 Initial period for the frequency timer. More...
 
#define OVEN_FREQ_CAPT_TC   TCC1
 Timer used to capture the generated frequency signal. More...
 
Test timer selection
#define CLASSB_FREQTEST_TC   TCD1
 Timer used by the Class B frequency consistency test of the CPU clock. More...
 
#define OVEN_PERIODIC_TEMPTEST_TC   TCE1
 Timer used to execute periodic temperature sanity test. More...
 
#define OVEN_PERIODIC_CLASSB_TC   TCE0
 Timer used to execute periodic Class B tests. More...
 
Display configuration
#define OVEN_PLOT_OFFSET_X   5
 X offset for the plot window. More...
 
#define OVEN_PLOT_MAX_X   112
 Rightmost X coordinate of the plot window. More...
 
#define OVEN_PLOT_MAX_Y   29
 Lowest Y coordinate in the plot window. More...
 
#define OVEN_PLOT_MIN_Y   0
 Topmost Y coordinate in the plot window. More...
 
#define OVEN_DISP_MAX_Y   32
 Display height. More...
 
#define MAX_WATTAGE   15
 Maximum watt level. More...
 

Enumerations

Oven state enumerations
enum  ovenctl_plate_state {
  POWER_OFF,
  ON_NO_POT,
  ON_ACTUATING
}
 Current state of the oven. More...
 
enum  status_led {
  S_ORANGE,
  S_GREEN,
  S_RED,
  S_OFF
}
 Status LED color enumerations. More...
 
enum  pot_t {
  POT_OFF,
  POT_ON
}
 Pot status on or off plate enumeration. More...
 

Functions

void main_init_adc_dac (void)
 Initialize ADC and DAC used to simulate a temperature sensor. More...
 
void main_init_tc (void)
 Initialize Timer/Counters used to simulate oven actuation signal. More...
 

Variables

volatile uint32_t classb_last_wdt_reset
 Global container for last WDT reset time. More...
 

#define CLASSB_FREQTEST_TC   TCD1

Timer used by the Class B frequency consistency test of the CPU clock.

Referenced by oven_classb_init_tests().

#define FREQ_TIMER_PERIOD_INIT   0x100

Initial period for the frequency timer.

Referenced by main_init_tc().

#define MAX_WATTAGE   15

Maximum watt level.

Referenced by oven_ui_update_graphics().

#define OVEN_CTL_STEP_TIME   20

How often a control step should be executed [ms].

Referenced by main().

#define OVEN_DISP_MAX_Y   32

Display height.

Referenced by oven_ui_draw_plot_step().

#define OVEN_FREQ_CAPT_TC   TCC1

Timer used to capture the generated frequency signal.

Referenced by main_init_tc(), and oven_plant_read_signal_period().

#define OVEN_FREQ_TC   TCC0

Timer used to output frequency signal controlling the induction element.

Referenced by main_init_tc(), and ovenctl_actuate_induction_element().

#define OVEN_PERIODIC_CLASSB_TC   TCE0

Timer used to execute periodic Class B tests.

Referenced by main(), ovenctl_turn_off_plate(), and ovenctl_turn_on_plate().

#define OVEN_PERIODIC_TEMPTEST_TC   TCE1

Timer used to execute periodic temperature sanity test.

Referenced by main(), oven_classb_error_insertion(), ovenctl_turn_off_plate(), and ovenctl_turn_on_plate().

#define OVEN_PLOT_MAX_X   112

Rightmost X coordinate of the plot window.

Referenced by oven_ui_draw_plot_step().

#define OVEN_PLOT_MAX_Y   29

Lowest Y coordinate in the plot window.

Referenced by oven_ui_draw_plot_step().

#define OVEN_PLOT_MIN_Y   0

Topmost Y coordinate in the plot window.

Referenced by oven_ui_draw_plot_step().

#define OVEN_PLOT_OFFSET_X   5

X offset for the plot window.

Referenced by oven_ui_draw_plot_step().

#define OVEN_SIM_STEP_TIME   100

How often a simulation step should be executed [ms].

Referenced by main().

#define oven_wdt_periodic_reset ( )
Value:
do { \
} \
} while(0)
#define OVEN_WDT_RESET_PERIOD
Number of RTC ticks between WDT resets.
Definition: oven.h:51
volatile uint32_t classb_last_wdt_reset
Global holder for last WDT reset time.
Definition: main.c:193
#define wdt_reset()
This macro resets (clears/refreshes) the Watchdog Timer.
Definition: wdt.h:122
uint32_t rtc_get_time(void)
Get current time.
Definition: rtc32.c:142

Reset the WDT when OVEN_WDT_RESET_PERIOD has passed.

This macro depends on the ASF RTC driver and that the timer is running because it is used to get correct timing of watchdog resets in windowed mode.

Referenced by main(), oven_classb_error_insertion(), oven_classb_flash_corrupter(), show_button_splash(), and show_explain_splash().

#define OVEN_WDT_RESET_PERIOD   1250

Number of RTC ticks between WDT resets.

Should be in the middle of the open window period of the WDT, e.g. at 625 ticks if WPER is 500CLK and PER is 250CLK.

Current state of the oven.

Enumerator
POWER_OFF 

The power to the oven is turned off.

ON_NO_POT 

Actuation is desired, but there is nothing on the plate.

ON_ACTUATING 

Actuation is desired and is applied.

enum pot_t

Pot status on or off plate enumeration.

Enumerator
POT_OFF 
POT_ON 
enum status_led

Status LED color enumerations.

Enumerator
S_ORANGE 
S_GREEN 
S_RED 
S_OFF 

void main_init_adc_dac ( void  )

Initialize ADC and DAC used to simulate a temperature sensor.

DACB is used by the simulation plant to output a temperature reading of the oven plate. It is set up to output a voltage on pin B2 which is marked as ADC2 on header J2.

ADCA is used in the control step and graphical interface to show the current temperature of the oven plate. It is set up to read a voltage on pin A4 which is marked as ADC4 on header J2.

ADC2 and ADC4 should be connected together, so that the ADC samples the DAC directly.

References ADC_CH0, adc_enable(), adc_read_configuration(), ADC_REF_BANDGAP, ADC_RES_12, adc_set_clock_rate(), adc_set_conversion_parameters(), adc_set_conversion_trigger(), ADC_SIGN_ON, adc_start_conversion(), ADC_TRIG_MANUAL, adc_write_configuration(), ADCCH_NEG_NONE, ADCCH_POS_PIN4, adcch_read_configuration(), adcch_set_input(), adcch_write_configuration(), DAC_ADJ_RIGHT, DAC_CH0, dac_enable(), dac_read_configuration(), DAC_REF_BANDGAP, dac_set_active_channel(), dac_set_conversion_parameters(), dac_write_configuration(), IOPORT_DIR_INPUT, IOPORT_MODE_PULLDOWN, ioport_set_pin_dir(), ioport_set_pin_mode(), and J2_PIN4.

Referenced by main(), and ovenctl_turn_on_plate().

void main_init_tc ( void  )

Initialize Timer/Counters used to simulate oven actuation signal.

TCC0 is set up to generate a dual variable frequency signal with dead-time insertion using the AWEX module. This is similar to how heating elements are actuated in real induction ovens. Its output is on pin C2 which is marked as RXD on header J1.

TCC1 is set up to capture a frequency signal via a pin change event using the XMEGA Event System. Its input is pin C4 which is marked as SS on header J1.

References FREQ_TIMER_PERIOD_INIT, IOPORT_BOTHEDGES, ioport_configure_pin(), IOPORT_DIR_INPUT, IOPORT_DIR_OUTPUT, J1_PIN2, J1_PIN4, OVEN_FREQ_CAPT_TC, OVEN_FREQ_TC, tc_awex_enable_ccb_deadtime(), tc_awex_set_dti_high(), tc_awex_set_dti_low(), tc_awex_set_output_override(), TC_CCA, TC_CCAEN, tc_enable(), tc_enable_cc_channels(), tc_set_input_capture(), tc_set_wgm(), TC_WG_FRQ, tc_write_cc(), and tc_write_clock_source().

Referenced by main(), and ovenctl_turn_on_plate().

volatile uint32_t classb_last_wdt_reset

Global container for last WDT reset time.

Global container for last WDT reset time.

Referenced by main(), and main_init_rtc32().