Add preliminary safety ADC which measures the Controller temperature and checks the reference voltage against the STM's internal reference voltage
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
#include <helper-macros/helper-macros.h>
|
||||
#include <reflow-controller/button.h>
|
||||
#include <reflow-controller/oven-driver.h>
|
||||
#include <reflow-controller/safety-adc.h>
|
||||
#include <fatfs/ff.h>
|
||||
|
||||
static void setup_nvic_priorities()
|
||||
@@ -142,12 +143,10 @@ static bool mount_sd_card_if_avail(bool mounted)
|
||||
}
|
||||
|
||||
static inline int32_t handle_pid_controller(struct pid_controller *pid, float target_temperature,
|
||||
float current_pt1000_resistance)
|
||||
float current_temperature)
|
||||
{
|
||||
float current_temperature;
|
||||
int32_t pid_out;
|
||||
|
||||
(void)temp_converter_convert_resistance_to_temp(current_pt1000_resistance, (float *)¤t_temperature);
|
||||
pid_out = (int32_t)pid_sample(pid, target_temperature - current_temperature);
|
||||
|
||||
/* Blink green LED */
|
||||
@@ -179,6 +178,7 @@ static inline void setup_system()
|
||||
rotary_encoder_setup();
|
||||
button_init();
|
||||
lcd_init();
|
||||
safety_adc_init();
|
||||
|
||||
uart_gpio_config();
|
||||
setup_sell_uart(&shell_uart);
|
||||
@@ -198,6 +198,8 @@ static void handle_shell_uart_input(shellmatta_handle_t shell_handle)
|
||||
shell_handle_input(shell_handle, uart_input, uart_input_len);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
bool sd_card_mounted = false;
|
||||
@@ -209,6 +211,8 @@ int main()
|
||||
uint64_t display_timestamp = 0ULL;
|
||||
char disp[4][21] = {0};
|
||||
enum lcd_fsm_ret lcd_ret = LCD_FSM_NOP;
|
||||
int temp_status;
|
||||
float current_temp;
|
||||
|
||||
target_temperature = 25.0f;
|
||||
|
||||
@@ -228,15 +232,25 @@ int main()
|
||||
pt1000_value_status = adc_pt1000_get_current_resistance(&pt1000_value);
|
||||
|
||||
if (systick_ticks_have_passed(pid_timestamp, 250)) {
|
||||
|
||||
(void)handle_safety_adc();
|
||||
|
||||
pid_timestamp = systick_get_global_tick();
|
||||
|
||||
temp_status = temp_converter_convert_resistance_to_temp(pt1000_value,
|
||||
¤t_temp);
|
||||
|
||||
if (pt1000_value_status >= 0 && pid_controller_active)
|
||||
pid_controller_output = handle_pid_controller(&pid, target_temperature, pt1000_value);
|
||||
pid_controller_output = handle_pid_controller(&pid, target_temperature, current_temp);
|
||||
|
||||
/* Blink red led in case of temp error */
|
||||
if (pt1000_value_status < 0)
|
||||
led_set(0, !led_get(0));
|
||||
else
|
||||
led_set(0, 0);
|
||||
|
||||
snprintf(&disp[3][0], 17, "Temp: %s%.1f C", (temp_status == 0 ? "" : temp_status < 0 ? "<" : ">")
|
||||
, current_temp);
|
||||
}
|
||||
|
||||
/* Handle error in case PID controller should be active, but temperature measurement failed */
|
||||
|
Reference in New Issue
Block a user