high speed warning

This commit is contained in:
leo 2023-09-21 18:24:58 +02:00
parent e0781317a2
commit b16cdb0aec
Signed by: leo
GPG Key ID: 0DD993BFB2B307DB
2 changed files with 8 additions and 2 deletions

View File

@ -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);

View File

@ -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;
}