Add safety management in PID handler and main loop
This commit is contained in:
		@@ -25,9 +25,28 @@
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <reflow-controller/pid-controller.h>
 | 
			
		||||
 | 
			
		||||
enum oven_pid_error_report {
 | 
			
		||||
	OVEN_PID_NO_ERROR = 0,
 | 
			
		||||
	OVEN_PID_ERR_PT1000_ADC_WATCHDOG = (1<<0),
 | 
			
		||||
	OVEN_PID_ERR_PT1000_ADC_OFF = (1<<1),
 | 
			
		||||
	OVEN_PID_ERR_PT1000_OTHER = (1<<2),
 | 
			
		||||
	OVEN_PID_ERR_VREF_TOL = (1<<3),
 | 
			
		||||
	OVEN_PID_ERR_OVERTEMP = (1<<4),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct oven_pid_errors {
 | 
			
		||||
	bool generic_error;
 | 
			
		||||
	bool pt1000_adc_watchdog;
 | 
			
		||||
	bool pt1000_adc_off;
 | 
			
		||||
	bool pt1000_other;
 | 
			
		||||
	bool vref_tol;
 | 
			
		||||
	bool controller_overtemp;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct oven_pid_status {
 | 
			
		||||
	bool active;
 | 
			
		||||
	bool aborted;
 | 
			
		||||
	struct oven_pid_errors error_flags;
 | 
			
		||||
	float target_temp;
 | 
			
		||||
	float current_temp;
 | 
			
		||||
	uint64_t timestamp_last_run;
 | 
			
		||||
@@ -41,11 +60,11 @@ void oven_driver_disable(void);
 | 
			
		||||
 | 
			
		||||
void oven_pid_init(struct pid_controller *controller_to_copy);
 | 
			
		||||
 | 
			
		||||
void oven_pid_handle(float target_temp, float current_temp);
 | 
			
		||||
void oven_pid_handle(float target_temp);
 | 
			
		||||
 | 
			
		||||
void oven_pid_stop();
 | 
			
		||||
 | 
			
		||||
void oven_pid_report_error(void);
 | 
			
		||||
void oven_pid_report_error(enum oven_pid_error_report report);
 | 
			
		||||
 | 
			
		||||
const struct oven_pid_status *oven_pid_get_status(void);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,11 +24,10 @@
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
 | 
			
		||||
#define SAFETY_ADC_FRAC_BITS (8)
 | 
			
		||||
#define SAFETY_ADC_VREF_VOLT (2.5)
 | 
			
		||||
#define SAFETY_ADC_VREF_TOL (0.25)
 | 
			
		||||
#define SAFETY_ADC_VREF_INT ()
 | 
			
		||||
 | 
			
		||||
#define SAFETY_ADC_VREF_MVOLT (2500.0f)
 | 
			
		||||
#define SAFETY_ADC_VREF_TOL_MVOLT (100.0f)
 | 
			
		||||
#define SAFETY_ADC_TEMP_LOW_LIM (0.0f)
 | 
			
		||||
#define SAFETY_ADC_TEMP_HIGH_LIM (65.0f)
 | 
			
		||||
 | 
			
		||||
enum safety_adc_meas_channel {SAFETY_ADC_MEAS_VREF, SAFETY_ADC_MEAS_TEMP};
 | 
			
		||||
enum safety_adc_check_result {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user