From b16cdb0aec8b96ce8f3201d0ff3782a363aa2d19 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 21 Sep 2023 18:24:58 +0200 Subject: [PATCH] high speed warning --- Core/Inc/pse_stepper_planer.h | 1 + Core/Src/pse_stepper_planer.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Core/Inc/pse_stepper_planer.h b/Core/Inc/pse_stepper_planer.h index 60162bc..392e12d 100644 --- a/Core/Inc/pse_stepper_planer.h +++ b/Core/Inc/pse_stepper_planer.h @@ -15,6 +15,7 @@ #define PSE_STEPPER_STEPS_PER_ROTATION 3200 // NEMA17 200 steps/rotation with 16x microstepping #define PSE_STEPPER_JOG_PRESC 64 // jog step frequency 50kHz #define PSE_STEPPER_JOG_PERIOD 25 // 64Mhz / 64 / 10 / 2 +#define PSE_STEPPER_WARN_MAX_KSPS 10 // maximum (kilo) steps per second before we issue a warning void pse_sp_start_axis(pse_stepper_conf* conf, pse_stepper_status* status); void pse_sp_stop_axis(pse_stepper_conf* conf); diff --git a/Core/Src/pse_stepper_planer.c b/Core/Src/pse_stepper_planer.c index c178876..1c553f1 100644 --- a/Core/Src/pse_stepper_planer.c +++ b/Core/Src/pse_stepper_planer.c @@ -68,8 +68,13 @@ void pse_stepper_planer_compute_sps(pse_unit* unit){ uint64_t numerator = (uint64_t)14323 * unit->syringe->diameter * unit->syringe->diameter * PSE_STEPPER_TIMER_CLOCK * PSE_STEPPER_SCREW_PITCH; uint64_t denominator = (uint64_t)607887 * unit->flow * PSE_STEPPER_STEPS_PER_ROTATION; uint64_t res = numerator / denominator; - if(res == 0){ - lv_obj_t * mbox1 = lv_msgbox_create(NULL, "Error", "Invalid configuration entered (period = 0)", NULL, true); + + uint64_t min_scale = PSE_STEPPER_TIMER_CLOCK * 1000 / (2 * PSE_STEPPER_WARN_MAX_KSPS); + printf("min scale %lu\n", min_scale); + if(res < min_scale){ + lv_obj_t * mbox1 = lv_msgbox_create(NULL, "WARNING", "aaa", NULL, true); + lv_obj_t* text = lv_msgbox_get_text(mbox1); + lv_label_set_text_fmt(text, "Fast movement selected, this may lead to undefined behavior (%lu ksps)", PSE_STEPPER_TIMER_CLOCK * 1000 / res); lv_obj_center(mbox1); return; }