From 899df433da755ae2b776c5683888e3d1a8627672 Mon Sep 17 00:00:00 2001 From: Stefan Hechenberger Date: Wed, 13 Feb 2013 01:59:55 +0100 Subject: [PATCH] playing with beam dynamics --- config.h | 6 +++--- stepper.c | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/config.h b/config.h index a49120e2a..ab342f1b1 100644 --- a/config.h +++ b/config.h @@ -53,9 +53,9 @@ // of actual to nominal speed and uses this to also reduce the nominal laser intensity. // The diminution profile can also be fine-tuned (as a linear mapping is too aggressive). // It uses this function: y=x^2*d+(1-d) where d is the diminution (0.0 to 1.0). -// 0.0 is no diminution and anything > 0.7 is more aggresive than linear. -#define CONFIG_BEAM_DIMINUTION 0 -// #define CONFIG_BEAM_DIMINUTION 0.3 +// 0 is no diminution and anything > 0.7 is more aggresive than linear. +#define CONFIG_BEAM_DIMINUTION 0.4 +#define CONFIG_LASER_MIN_INTENSITY 40 // min intensity at which the laser fires, 0-255 #define SENSE_DDR DDRD #define SENSE_PORT PORTD diff --git a/stepper.c b/stepper.c index 41a4843d0..a980370da 100644 --- a/stepper.c +++ b/stepper.c @@ -470,8 +470,10 @@ static void adjust_speed( uint32_t steps_per_minute ) { // We could use slowdown_pct directly but this tends to be too aggressive and leads // to corners getting too little power (opposite problem). To get a sense of the // dynamic factor simply graph y=x^2*d+(1-d) for d in [0.0, 1.0] - double dynamic_factor = slowdown_pct*slowdown_pct*(CONFIG_BEAM_DIMINUTION)+(1-CONFIG_BEAM_DIMINUTION); - control_laser_intensity(current_block->nominal_laser_intensity * dynamic_factor); + // double dynamic_factor = slowdown_pct*slowdown_pct*(CONFIG_BEAM_DIMINUTION)+(1-CONFIG_BEAM_DIMINUTION); + double dynamic_factor = slowdown_pct*(CONFIG_BEAM_DIMINUTION)+(1-CONFIG_BEAM_DIMINUTION); + int s_value = max(current_block->nominal_laser_intensity * dynamic_factor, CONFIG_LASER_MIN_INTENSITY); + control_laser_intensity(min(s_value, current_block->nominal_laser_intensity)); } else { // run at constant intensity control_laser_intensity(current_block->nominal_laser_intensity);