reflow-oven-control-sw/stm-firmware/include/reflow-controller/oven-driver.h

114 lines
3.5 KiB
C

/* Reflow Oven Controller
*
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
*
* This file is part of the Reflow Oven Controller Project.
*
* The reflow oven controller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the reflow oven controller project.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __OVEN_DRIVER_H__
#define __OVEN_DRIVER_H__
/**
* @defgroup oven-driver Oven SSR Driver and PID Controller
* @{
*/
#include <stdint.h>
#include <stdbool.h>
#include <reflow-controller/pid-controller.h>
/**
* @brief Status of the PID controlling the oven
*/
enum oven_pid_status {
OVEN_PID_DEACTIVATED, /**< @brief The PID of the oven is deactivated. */
OVEN_PID_RUNNING, /**< @brief The PID of the oven is currently active and running. */
OVEN_PID_ABORTED, /**< @brief The PID of the oven has been aborted due to an error and is not running. */
};
/**
* @brief Initialize the oven driver.
*
* This will initialize the Timer for the PWM output to the SSR.
* If the hardware revision is >= v1.3 the SSR safety enable line will also be initialized.
*/
void oven_driver_init(void);
/**
* @brief Set a power level on the oven control output
* @param power Power level between 0 to 100
* @note This will not actually set the output. For this, @ref oven_driver_apply_power_level() has to be called.
* It will be called in the main loop.
*/
void oven_driver_set_power(uint8_t power);
/**
* @brief Disable the oven driver.
*
* This shuts down the oven driver timer and the corresponding clocks.
*/
void oven_driver_disable(void);
/**
* @brief Initialize the PID controller for the oven output
* @param PID controller holding the settings
*/
void oven_pid_init(struct pid_controller *controller_to_copy);
/**
* @brief Handle the PID controller.
* This must be called cyclically. When the sampling period has passed, the function will process the PT1000
* resistance and do a PID cycluilation for this sample.
* @note This function must be called with a frequency greater or equal to the PID's sampling frequency
*/
void oven_pid_handle(void);
/**
* @brief Stop the oven PID controller
*/
void oven_pid_stop(void);
/**
* @brief Abort the oven PID controller. This is the same as oven_pid_stop() but will set the abort flag.
* @note this function is called by the safety controller to disable the PID controller in case of an error.
*/
void oven_pid_abort(void);
/**
* @brief Set the target temperature of the PID controller.
* @param temp
*/
void oven_pid_set_target_temperature(float temp);
/**
* @brief Output the power level currently configured to the SSR.
*
* This function is separated from oven_driver_set_power() because it is called in the main loop after the
* safety controller has run. This ensures, that if the safety controller decides to stop the PID no glitch makes it
* out to the SSR.
*/
void oven_driver_apply_power_level(void);
/**
* @brief Get the current status of the oven's PID controller
* @return
*/
enum oven_pid_status oven_pid_get_status(void);
/** @} */
#endif /* __OVEN_DRIVER_H__ */