Compare commits
4 Commits
400c77f11c
...
1722ba7e5d
Author | SHA1 | Date | |
---|---|---|---|
1722ba7e5d | |||
7a44a383ff | |||
7a2c77a83e | |||
c8e3bf5de2 |
@ -1,39 +1,39 @@
|
|||||||
/* Reflow Oven Controller
|
/* Reflow Oven Controller
|
||||||
*
|
*
|
||||||
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
||||||
*
|
*
|
||||||
* This file is part of the Reflow Oven Controller Project.
|
* This file is part of the Reflow Oven Controller Project.
|
||||||
*
|
*
|
||||||
* The reflow oven controller is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
* 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
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with the reflow oven controller project.
|
* along with the reflow oven controller project.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <reflow-controller/main-cycle-counter.h>
|
#include <reflow-controller/main-cycle-counter.h>
|
||||||
#include <helper-macros/helper-macros.h>
|
#include <helper-macros/helper-macros.h>
|
||||||
|
|
||||||
static uint64_t IN_SECTION(.ccm.bss) main_cycle_counter;
|
static uint64_t IN_SECTION(.ccm.bss) main_cycle_counter;
|
||||||
|
|
||||||
void main_cycle_counter_init()
|
void main_cycle_counter_init(void)
|
||||||
{
|
{
|
||||||
main_cycle_counter = 0ULL;
|
main_cycle_counter = 0ULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void main_cycle_counter_inc()
|
void main_cycle_counter_inc(void)
|
||||||
{
|
{
|
||||||
main_cycle_counter++;
|
main_cycle_counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t main_cycle_counter_get()
|
uint64_t main_cycle_counter_get(void)
|
||||||
{
|
{
|
||||||
return main_cycle_counter;
|
return main_cycle_counter;
|
||||||
}
|
}
|
||||||
|
@ -140,9 +140,9 @@ static bool mount_sd_card_if_avail(bool mounted)
|
|||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
led_set(1, 1);
|
led_set(1, 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mounted;
|
return mounted;
|
||||||
@ -202,9 +202,8 @@ static inline void setup_system(void)
|
|||||||
settings_setup();
|
settings_setup();
|
||||||
|
|
||||||
/* Load the overtemperature limit from eeprom if available. Otherwise the default value will be used */
|
/* Load the overtemperature limit from eeprom if available. Otherwise the default value will be used */
|
||||||
if (settings_load_overtemp_limit(&tmp) == SETT_LOAD_SUCCESS) {
|
if (settings_load_overtemp_limit(&tmp) == SETT_LOAD_SUCCESS)
|
||||||
safety_controller_set_overtemp_limit(tmp);
|
safety_controller_set_overtemp_limit(tmp);
|
||||||
}
|
|
||||||
|
|
||||||
handle_boot_status();
|
handle_boot_status();
|
||||||
|
|
||||||
@ -241,9 +240,8 @@ int main(void)
|
|||||||
|
|
||||||
/* Try load the calibration. This will only succeed if there's an EEPROM */
|
/* Try load the calibration. This will only succeed if there's an EEPROM */
|
||||||
status = settings_load_calibration(&sens, &offset);
|
status = settings_load_calibration(&sens, &offset);
|
||||||
if (!status) {
|
if (!status)
|
||||||
adc_pt1000_set_resistance_calibration(offset, sens, true);
|
adc_pt1000_set_resistance_calibration(offset, sens, true);
|
||||||
}
|
|
||||||
|
|
||||||
shell_handle = shell_init(write_shell_callback);
|
shell_handle = shell_init(write_shell_callback);
|
||||||
shell_print_motd(shell_handle);
|
shell_print_motd(shell_handle);
|
||||||
@ -261,9 +259,8 @@ int main(void)
|
|||||||
adc_pt1000_get_resistance_calibration(NULL, NULL, &cal_active);
|
adc_pt1000_get_resistance_calibration(NULL, NULL, &cal_active);
|
||||||
if (!cal_active) {
|
if (!cal_active) {
|
||||||
status = settings_load_calibration(&sens, &offset);
|
status = settings_load_calibration(&sens, &offset);
|
||||||
if (!status) {
|
if (!status)
|
||||||
adc_pt1000_set_resistance_calibration(offset, sens, true);
|
adc_pt1000_set_resistance_calibration(offset, sens, true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,9 +274,9 @@ int main(void)
|
|||||||
temp_profile_executer_handle();
|
temp_profile_executer_handle();
|
||||||
|
|
||||||
safety_controller_handle();
|
safety_controller_handle();
|
||||||
if (oven_pid_get_status() == OVEN_PID_RUNNING) {
|
if (oven_pid_get_status() == OVEN_PID_RUNNING)
|
||||||
oven_pid_handle();
|
oven_pid_handle();
|
||||||
}
|
|
||||||
oven_driver_apply_power_level();
|
oven_driver_apply_power_level();
|
||||||
safety_controller_report_timing(ERR_TIMING_MAIN_LOOP);
|
safety_controller_report_timing(ERR_TIMING_MAIN_LOOP);
|
||||||
|
|
||||||
|
@ -89,7 +89,8 @@ float pid_sample(struct pid_controller *pid, float deviation)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate derivative part */
|
/* Calculate derivative part */
|
||||||
pid->derivate = pid->k_deriv_t * (deviation - pid->last_in) + pid->k_inv_deriv_t * pid->derivate;
|
pid->derivate = pid->k_deriv_t * (deviation - pid->last_in) +
|
||||||
|
pid->k_inv_deriv_t * pid->derivate;
|
||||||
|
|
||||||
output += pid->derivate;
|
output += pid->derivate;
|
||||||
output += pid->integral;
|
output += pid->integral;
|
||||||
|
@ -51,7 +51,6 @@
|
|||||||
#define GIT_VER "VERSION NOT SET"
|
#define GIT_VER "VERSION NOT SET"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern struct stm_uart shell_uart;
|
|
||||||
static shellmatta_instance_t shell;
|
static shellmatta_instance_t shell;
|
||||||
static char shell_buffer[512];
|
static char shell_buffer[512];
|
||||||
static char IN_SECTION(.ccm.bss) history_buffer[512];
|
static char IN_SECTION(.ccm.bss) history_buffer[512];
|
||||||
@ -71,7 +70,7 @@ static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
|
|||||||
unique_id_get(&high_id, &mid_id, &low_id);
|
unique_id_get(&high_id, &mid_id, &low_id);
|
||||||
|
|
||||||
shellmatta_printf(handle, "Reflow Oven Controller Firmware " xstr(GIT_VER) "\r\n"
|
shellmatta_printf(handle, "Reflow Oven Controller Firmware " xstr(GIT_VER) "\r\n"
|
||||||
"Compiled: " __DATE__ " at " __TIME__ "\r\n");
|
"Compiled: " __DATE__ " at " __TIME__ "\r\n");
|
||||||
shellmatta_printf(handle, "Serial: %08X-%08X-%08X\r\n", high_id, mid_id, low_id);
|
shellmatta_printf(handle, "Serial: %08X-%08X-%08X\r\n", high_id, mid_id, low_id);
|
||||||
|
|
||||||
pcb_rev = get_pcb_hardware_version();
|
pcb_rev = get_pcb_hardware_version();
|
||||||
@ -163,13 +162,12 @@ static shellmatta_retCode_t shell_cmd_pt1000_res(const shellmatta_handle_t han
|
|||||||
|
|
||||||
pt1000_status = adc_pt1000_get_current_resistance(&resistance);
|
pt1000_status = adc_pt1000_get_current_resistance(&resistance);
|
||||||
|
|
||||||
if (pt1000_status == 2) {
|
if (pt1000_status == 2)
|
||||||
strcat(display_status, "UNSTABLE");
|
strcat(display_status, "UNSTABLE");
|
||||||
} else if (pt1000_status) {
|
else if (pt1000_status)
|
||||||
strcpy(display_status, "ERROR");
|
strcpy(display_status, "ERROR");
|
||||||
} else {
|
else
|
||||||
strcpy(display_status, "VALID");
|
strcpy(display_status, "VALID");
|
||||||
}
|
|
||||||
|
|
||||||
temp_conv_status = temp_converter_convert_resistance_to_temp(resistance, &temp);
|
temp_conv_status = temp_converter_convert_resistance_to_temp(resistance, &temp);
|
||||||
switch (temp_conv_status) {
|
switch (temp_conv_status) {
|
||||||
@ -186,7 +184,8 @@ static shellmatta_retCode_t shell_cmd_pt1000_res(const shellmatta_handle_t han
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
shellmatta_printf(handle, "PT1000 resistance: %.2f Ohm (%s%.1f °C) [%s]\r\n", resistance, temp_prefix,temp, display_status);
|
shellmatta_printf(handle, "PT1000 resistance: %.2f Ohm (%s%.1f °C) [%s]\r\n",
|
||||||
|
resistance, temp_prefix, temp, display_status);
|
||||||
|
|
||||||
return SHELLMATTA_OK;
|
return SHELLMATTA_OK;
|
||||||
}
|
}
|
||||||
@ -342,9 +341,8 @@ static shellmatta_retCode_t shell_cmd_read_flags(const shellmatta_handle_t handl
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
opt_ret = shellmatta_opt_long(handle, options, &option, &argument, &len);
|
opt_ret = shellmatta_opt_long(handle, options, &option, &argument, &len);
|
||||||
if (opt_ret != SHELLMATTA_OK) {
|
if (opt_ret != SHELLMATTA_OK)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case 'a':
|
case 'a':
|
||||||
@ -353,7 +351,7 @@ static shellmatta_retCode_t shell_cmd_read_flags(const shellmatta_handle_t handl
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while(1);
|
} while (1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -377,7 +375,11 @@ static shellmatta_retCode_t shell_cmd_read_flags(const shellmatta_handle_t handl
|
|||||||
if (tryack)
|
if (tryack)
|
||||||
safety_controller_ack_flag(flag_enum);
|
safety_controller_ack_flag(flag_enum);
|
||||||
|
|
||||||
shellmatta_printf(handle, "\t%2lu) %-20s\t[%s]\r\n", i+1, name, (flag ? "\e[1;31mERR\e[m" : "\e[32mOK\e[m"));
|
shellmatta_printf(handle,
|
||||||
|
"\t%2lu) %-20s\t[%s]\r\n",
|
||||||
|
i+1,
|
||||||
|
name,
|
||||||
|
(flag ? "\e[1;31mERR\e[m" : "\e[32mOK\e[m"));
|
||||||
}
|
}
|
||||||
|
|
||||||
shellmatta_printf(handle, "\r\nAnalog Monitors\r\n"
|
shellmatta_printf(handle, "\r\nAnalog Monitors\r\n"
|
||||||
@ -421,7 +423,7 @@ static shellmatta_retCode_t shell_cmd_read_flags(const shellmatta_handle_t handl
|
|||||||
|
|
||||||
shellmatta_printf(handle, "\t%2lu) %-20s\t", i+1, name);
|
shellmatta_printf(handle, "\t%2lu) %-20s\t", i+1, name);
|
||||||
if (timing_info.enabled)
|
if (timing_info.enabled)
|
||||||
shellmatta_printf(handle, "last tick: %lu ms\r\n", (unsigned long int)timing_info.delta);
|
shellmatta_printf(handle, "last tick: %lu ms\r\n", (unsigned long)timing_info.delta);
|
||||||
else
|
else
|
||||||
shellmatta_printf(handle, "\e[1;31mDISABLED\e[m\r\n");
|
shellmatta_printf(handle, "\e[1;31mDISABLED\e[m\r\n");
|
||||||
}
|
}
|
||||||
@ -442,11 +444,10 @@ static shellmatta_retCode_t shell_cmd_save_cal(const shellmatta_handle_t handle,
|
|||||||
adc_pt1000_get_resistance_calibration(&offset, &sens_dev, &active);
|
adc_pt1000_get_resistance_calibration(&offset, &sens_dev, &active);
|
||||||
res = settings_save_calibration(sens_dev, offset, active);
|
res = settings_save_calibration(sens_dev, offset, active);
|
||||||
|
|
||||||
if (res) {
|
if (res)
|
||||||
shellmatta_printf(handle, "Error saving %d\r\n", res);
|
shellmatta_printf(handle, "Error saving %d\r\n", res);
|
||||||
} else {
|
else
|
||||||
shellmatta_printf(handle, "Saved!\r\n");
|
shellmatta_printf(handle, "Saved!\r\n");
|
||||||
}
|
|
||||||
|
|
||||||
return SHELLMATTA_OK;
|
return SHELLMATTA_OK;
|
||||||
}
|
}
|
||||||
@ -458,7 +459,8 @@ static shellmatta_retCode_t shell_cmd_hang(const shellmatta_handle_t handle, con
|
|||||||
(void)arguments;
|
(void)arguments;
|
||||||
(void)length;
|
(void)length;
|
||||||
|
|
||||||
while (1337);
|
while (1337)
|
||||||
|
;
|
||||||
|
|
||||||
return SHELLMATTA_OK;
|
return SHELLMATTA_OK;
|
||||||
}
|
}
|
||||||
@ -577,9 +579,9 @@ static shellmatta_retCode_t shell_cmd_dump_safety_mem(const shellmatta_handle_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
fres = f_write(&file, buffer, used_bytes - 1, &bw);
|
fres = f_write(&file, buffer, used_bytes - 1, &bw);
|
||||||
if (fres != FR_OK) {
|
if (fres != FR_OK)
|
||||||
shellmatta_printf(handle, "Error writing to file %s\r\n", token);
|
shellmatta_printf(handle, "Error writing to file %s\r\n", token);
|
||||||
}
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
f_close(&file);
|
f_close(&file);
|
||||||
return SHELLMATTA_OK;
|
return SHELLMATTA_OK;
|
||||||
@ -777,9 +779,9 @@ shellmatta_retCode_t shell_cmd_execute(const shellmatta_handle_t handle, const c
|
|||||||
if (state->status != TPE_RUNNING) {
|
if (state->status != TPE_RUNNING) {
|
||||||
shellmatta_printf(handle, "Profile executed.\r\n");
|
shellmatta_printf(handle, "Profile executed.\r\n");
|
||||||
running = false;
|
running = false;
|
||||||
if(state->status == TPE_ABORT) {
|
if (state->status == TPE_ABORT)
|
||||||
shellmatta_printf(handle, "Profile execution aborted!\r\n");
|
shellmatta_printf(handle, "Profile execution aborted!\r\n");
|
||||||
}
|
|
||||||
return SHELLMATTA_OK;
|
return SHELLMATTA_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -875,81 +877,6 @@ shellmatta_retCode_t shell_cmd_filter_alpha(const shellmatta_handle_t handle, co
|
|||||||
return SHELLMATTA_OK;
|
return SHELLMATTA_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
shellmatta_retCode_t shell_cmd_hf_stream(const shellmatta_handle_t handle, const char *args, uint32_t len)
|
|
||||||
{
|
|
||||||
float *data1;
|
|
||||||
volatile int flag;
|
|
||||||
FRESULT fres;
|
|
||||||
char *strbuff;
|
|
||||||
FIL f;
|
|
||||||
const size_t buff_size = 2000UL;
|
|
||||||
uint32_t idx;
|
|
||||||
uint32_t blocks;
|
|
||||||
uint32_t remainder;
|
|
||||||
int cnt;
|
|
||||||
UINT bw;
|
|
||||||
|
|
||||||
data1 = (float *)malloc(buff_size*sizeof(float));
|
|
||||||
strbuff = (char *)malloc(1024);
|
|
||||||
|
|
||||||
if (!data1 || !strbuff) {
|
|
||||||
shellmatta_printf(handle, "Allocating memory failed!\r\n");
|
|
||||||
goto free_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
fres = f_open(&f, "pt1000_hf.dat", FA_CREATE_ALWAYS | FA_WRITE);
|
|
||||||
if (fres != FR_OK) {
|
|
||||||
shellmatta_printf(handle, "Cannot open file.\r\n");
|
|
||||||
goto free_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
shellmatta_printf(handle, "Acquire data...\r\n");
|
|
||||||
flag = 0;
|
|
||||||
adc_pt1000_stream_raw_value_to_memory(data1, buff_size, &flag);
|
|
||||||
while (!flag) {
|
|
||||||
safety_controller_handle();
|
|
||||||
}
|
|
||||||
shellmatta_printf(handle, "Finished. Writing file...\r\n");
|
|
||||||
|
|
||||||
blocks = buff_size / 10UL;
|
|
||||||
remainder = buff_size % 10UL;
|
|
||||||
|
|
||||||
for (idx = 0; idx < blocks; idx++) {
|
|
||||||
cnt = snprintf(strbuff, 1024, "%.2f\n%.2f\n%.2f\n%.2f\n%.2f\n%.2f\n%.2f\n%.2f\n%.2f\n%.2f\n",
|
|
||||||
data1[idx * 10+0],
|
|
||||||
data1[idx * 10+1],
|
|
||||||
data1[idx * 10+2],
|
|
||||||
data1[idx * 10+3],
|
|
||||||
data1[idx * 10+4],
|
|
||||||
data1[idx * 10+5],
|
|
||||||
data1[idx * 10+6],
|
|
||||||
data1[idx * 10+7],
|
|
||||||
data1[idx * 10+8],
|
|
||||||
data1[idx * 10+9]);
|
|
||||||
f_write(&f, strbuff, (UINT)cnt, &bw);
|
|
||||||
safety_controller_handle();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (idx = 0; idx < remainder; idx++) {
|
|
||||||
cnt = snprintf(strbuff, 1024, "%.2f\n", data1[blocks * 10 + idx]);
|
|
||||||
f_write(&f, strbuff, (UINT)cnt, &bw);
|
|
||||||
}
|
|
||||||
|
|
||||||
f_close(&f);
|
|
||||||
|
|
||||||
shellmatta_printf(handle, "Completed!\r\n");
|
|
||||||
free_data:
|
|
||||||
if (data1)
|
|
||||||
free(data1);
|
|
||||||
if (strbuff)
|
|
||||||
free(strbuff);
|
|
||||||
|
|
||||||
return SHELLMATTA_OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//typedef struct shellmatta_cmd
|
//typedef struct shellmatta_cmd
|
||||||
//{
|
//{
|
||||||
// char *cmd; /**< command name */
|
// char *cmd; /**< command name */
|
||||||
@ -1152,8 +1079,15 @@ shellmatta_handle_t shell_init(shellmatta_write_t write_func)
|
|||||||
shellmatta_handle_t handle;
|
shellmatta_handle_t handle;
|
||||||
shellmatta_retCode_t ret;
|
shellmatta_retCode_t ret;
|
||||||
|
|
||||||
ret = shellmatta_doInit(&shell, &handle, shell_buffer, sizeof(shell_buffer), history_buffer, sizeof(history_buffer),
|
ret = shellmatta_doInit(&shell,
|
||||||
"\e[1;32mReflow Controller>\e[m ", cmd, write_func);
|
&handle,
|
||||||
|
shell_buffer,
|
||||||
|
sizeof(shell_buffer),
|
||||||
|
history_buffer,
|
||||||
|
sizeof(history_buffer),
|
||||||
|
"\e[1;32mReflow Controller>\e[m ",
|
||||||
|
cmd,
|
||||||
|
write_func);
|
||||||
if (ret != SHELLMATTA_OK)
|
if (ret != SHELLMATTA_OK)
|
||||||
handle = NULL;
|
handle = NULL;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user