## 5 Microcontroller
### Flowchart  
Although the selected transistor has a breaking threshold of 1200 volts, \(\Delta t\) cannot be incremented too much because of the 600 V practical limit on the capacitor's working voltage. Additionally, when the switching takes place, the coil's drawn current escalates quickly, and it is important to validate the power source's ability to provide the demanded current. Therefore, we have designed the system in such a way that \(\Delta t\) increases gradually so that in case of error detection, the system can catch up and act properly. The flowchart includes the following:  
(1) Standby: When the device is turned on, the initialization block performs the initial settings of program variables and HAL-related handlers. The IGBT switching block disables PWM generation (transistor shutdown); then, a routine updates the LEDs and the display module, putting the device in red flashing mode. Consequently, the program waits for the user to press the power key (PWR_KEY). (2) Load check: The IGBT switching block is used to detect the presence of cookware on the coil [38; 39; 40; 41]. If it does not perceive any magnetic engagement due to the presence of the load within 60 s, the program will return to its previous state. Additionally, in this mode, the LED will be changed to blue. (3) PWM configuration: After detecting the load, it is time to determine the switching parameters. At this stage, \(V_{CE\_max}\), \(T_{resonance}\), and \(\Delta t_{on}\) will be determined by triggering pulses at low frequencies to excite the coil. (4) Switching: In this step, the PWM pulse generation process is started by the IGBT switching unit. At the same time, a routine continuously checks the safety parameters such as the IGBT temperature, current, power, etc. To ensure the presence of the load (container), the system returns to load detection (module 2) every 250 milliseconds. This time, the system will not require confirmation from the user. The display LED will be white in this state. (5) User interface: Normally, when the device is in the operating state, it will loop around module 4. However, pressing any of the following keys, PWR, UP, and DWN, will execute module 5. Pressing the UP_KEY button will increment \(\Delta t\), which will increase the total output power. On the contrary, pressing the DWN_KEY button will decrease \(\Delta t\), which will decrease the total output power. The PWR_KEY button also shuts down the system. After this step, the program will go to step 3 and then return to the main module (switching state) after determining the new PWM specifications. The fire control block is implemented to monitor the state of the transistor during switching and estimate the output power. This block keeps track of the IGBT temperature and system current by sampling the ADC_IGBT_TEMP and ADC_IGBT_CURR signals (in the ADC1 unit). Then, by comparing the values to pre-defined limits, it controls the heatsink fan (IGBT_FAN) and shuts down the system if the temperature exceeds the critical level. Also, with the help of the measured current, the real-time power value is stored in the SYSTEM_POWER variable to be displayed on the screen using the interface block. In the microcontroller, timer 3 is responsible for generating the PWM needed to switch the IGBT. This block transfers the pulse to the corresponding IGBT_PWM port, which is then used to drive the IGBT using TLP250. The switching parameters can be managed as follows:  
\[ \begin{array}{l}TIM3\_ARR=\Delta t_{on}+T_{off}\\ TIM3\_CCR1=T_{off}\end{array}  \tag{11}\]  
For example, Figure 10 shows a PWM pulse with a \(\Delta t\) period of 5 microseconds and a period of 35 microseconds. Consequently, if we need to increase the power, we will modify the registers accordingly. By intermittently exciting the coil, we can detect the presence of the load by counting the periods of the PULSE_DET signal.