Merged new $ params

This commit is contained in:
cprezzi 2017-05-18 12:47:37 +02:00
parent f7083b9491
commit 1f0ab33787
7 changed files with 125 additions and 130 deletions

View File

@ -111,10 +111,11 @@
// #define HOMING_CYCLE_2 // OPTIONAL: Uncomment and add axes mask to enable
// NOTE: The following are two examples to setup homing for 2-axis machines.
#define HOMING_CYCLE_0 ((1<<X_AXIS)|(1<<Y_AXIS)) // NOT COMPATIBLE WITH COREXY: Homes both X-Y in one cycle.
//#define HOMING_CYCLE_0 ((1<<X_AXIS)|(1<<Y_AXIS)) // NOT COMPATIBLE WITH COREXY: Homes both X-Y in one cycle.
// #define HOMING_CYCLE_0 (1<<X_AXIS) // COREXY COMPATIBLE: First home X
// #define HOMING_CYCLE_1 (1<<Y_AXIS) // COREXY COMPATIBLE: Then home Y
// Homing cycle pattern is defined in Machine defaults!!!
// Number of homing cycles performed after when the machine initially jogs to limit switches.
// This help in preventing overshoot and should improve repeatability. This value should be one or
@ -362,12 +363,6 @@
// pwm = scaled value. settings.rpm_min scales to SPINDLE_PWM_MIN_VALUE. settings.rpm_max
// scales to SPINDLE_PWM_MAX_VALUE.
// Not needed anymore, as spindle PWM frequency is set by $33 param
//#define SPINDLE_PWM_PERIOD (SystemCoreClock / 40000) // SystemCoreClock / frequency
#define SPINDLE_PWM_OFF_VALUE 0.0 // SPINDLE_PWM_PERIOD * fraction
//#define SPINDLE_PWM_MIN_VALUE (SPINDLE_PWM_PERIOD * 0.0) // SPINDLE_PWM_PERIOD * fraction
//#define SPINDLE_PWM_MAX_VALUE (SPINDLE_PWM_PERIOD * 1.0) // SPINDLE_PWM_PERIOD * fraction
// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.
// The PWM pin will still read 0V when the spindle is disabled. Most users will not need this option, but
// it may be useful in certain scenarios. This minimum PWM settings coincides with the spindle rpm minimum

View File

@ -269,10 +269,10 @@
// Stepper current control
#ifndef BOARD_C3D
#define CURRENT_I2C Driver_I2C1 // I2C driver for current control. Comment out to disable (for C3d boards!)
#endif
#define CURRENT_MCP44XX_ADDR 0b0101100 // Address of MCP44XX
#define CURRENT_WIPERS {0, 1, 6, 7}; // Wiper registers (X, Y, Z, A)
#define CURRENT_FACTOR 113.33 // Convert amps to digipot value
#endif
// Variable spindle configuration below. Do not change unless you know what you are doing.
// NOTE: Only used when variable spindle is enabled.

View File

@ -33,40 +33,33 @@
#define DEFAULT_Y_STEPS_PER_MM 250.0
#define DEFAULT_Z_STEPS_PER_MM 250.0
#define DEFAULT_A_STEPS_PER_MM 160.0
//#define DEFAULT_B_STEPS_PER_MM 160.0
//#define DEFAULT_C_STEPS_PER_MM 160.0
#define DEFAULT_X_MAX_RATE 500.0 // mm/min
#define DEFAULT_Y_MAX_RATE 500.0 // mm/min
#define DEFAULT_Z_MAX_RATE 500.0 // mm/min
#define DEFAULT_A_MAX_RATE 500.0 // mm/min
//#define DEFAULT_B_MAX_RATE 500.0 // mm/min
//#define DEFAULT_C_MAX_RATE 500.0 // mm/min
#define DEFAULT_X_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_Y_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_Z_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_A_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
//#define DEFAULT_B_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
//#define DEFAULT_C_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_X_CURRENT 0.6 // amps
#define DEFAULT_Y_CURRENT 0.6 // amps
#define DEFAULT_Z_CURRENT 0.0 // amps
#define DEFAULT_A_CURRENT 0.0 // amps
//#define DEFAULT_B_CURRENT 0.0 // amps
//#define DEFAULT_C_CURRENT 0.0 // amps
#define DEFAULT_X_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value.
#define DEFAULT_A_MAX_TRAVEL 1.0 // mm NOTE: Must be a positive value.
//#define DEFAULT_B_MAX_TRAVEL 1.0 // mm NOTE: Must be a positive value.
//#define DEFAULT_C_MAX_TRAVEL 1.0 // mm NOTE: Must be a positive value.
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz
#define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
#define DEFAULT_SPINDLE_PWM_OFF_VALUE 0 // %
#define DEFAULT_SPINDLE_PWM_MIN_VALUE 1 // %
#define DEFAULT_SPINDLE_PWM_MAX_VALUE 100 // %
#define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm (S-value)
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm (S-value)
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
#define DEFAULT_STEPPING_INVERT_MASK 0
#define DEFAULT_DIRECTION_INVERT_MASK 0
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-254, 255 keeps steppers enabled)
#define DEFAULT_STATUS_REPORT_MASK 1 // MPos enabled
#define DEFAULT_STATUS_REPORT_MASK 0 // WPos enabled
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
#define DEFAULT_REPORT_INCHES 0 // false
@ -82,63 +75,58 @@
#define DEFAULT_HOMING_SEEK_RATE 500.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
#define HOMING_CYCLE_0 ((1<<X_AXIS)|(1<<Y_AXIS))
#endif
#ifdef DEFAULTS_K40
// Description: K40 Lasercutter (typical chinese 40W CO2 laser cutter/engraver)
#define DEFAULT_X_STEPS_PER_MM 160.0
#define DEFAULT_X_STEPS_PER_MM 160.0 // 200 stepps/rev. * 32 microstepps / 40mm/rev
#define DEFAULT_Y_STEPS_PER_MM 160.0
#define DEFAULT_Z_STEPS_PER_MM 160.0
#define DEFAULT_A_STEPS_PER_MM 160.0
//#define DEFAULT_B_STEPS_PER_MM 160.0
//#define DEFAULT_C_STEPS_PER_MM 160.0
#define DEFAULT_X_MAX_RATE 24000.0 // mm/min
#define DEFAULT_Y_MAX_RATE 24000.0 // mm/min
#define DEFAULT_Z_MAX_RATE 24000.0 // mm/min
#define DEFAULT_A_MAX_RATE 24000.0 // mm/min
//#define DEFAULT_B_MAX_RATE 24000.0 // mm/min
//#define DEFAULT_C_MAX_RATE 24000.0 // mm/min
#define DEFAULT_X_ACCELERATION (2500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_Y_ACCELERATION (2500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_Z_ACCELERATION (2500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_A_ACCELERATION (2500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
//#define DEFAULT_B_ACCELERATION (2500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
//#define DEFAULT_C_ACCELERATION (2500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_X_ACCELERATION (2500.0*60*60) // 2500*60*60 mm/min^2 = 2500 mm/sec^2
#define DEFAULT_Y_ACCELERATION (2500.0*60*60) // 2500*60*60 mm/min^2 = 2500 mm/sec^2
#define DEFAULT_Z_ACCELERATION (2500.0*60*60) // 2500*60*60 mm/min^2 = 2500 mm/sec^2
#define DEFAULT_A_ACCELERATION (2500.0*60*60) // 2500*60*60 mm/min^2 = 2500 mm/sec^2
#define DEFAULT_X_CURRENT 0.6 // amps
#define DEFAULT_Y_CURRENT 0.6 // amps
#define DEFAULT_Z_CURRENT 0.0 // amps
#define DEFAULT_A_CURRENT 0.0 // amps
//#define DEFAULT_B_CURRENT 0.0 // amps
//#define DEFAULT_C_CURRENT 0.0 // amps
#define DEFAULT_X_MAX_TRAVEL 300.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 1.0 // mm NOTE: Must be a positive value.
#define DEFAULT_A_MAX_TRAVEL 1.0 // mm NOTE: Must be a positive value.
//#define DEFAULT_B_MAX_TRAVEL 1.0 // mm NOTE: Must be a positive value.
//#define DEFAULT_C_MAX_TRAVEL 1.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 50.0 // mm NOTE: Must be a positive value.
#define DEFAULT_A_MAX_TRAVEL 100.0 // mm NOTE: Must be a positive value.
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz
#define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
#define DEFAULT_SPINDLE_PWM_OFF_VALUE 0 // %
#define DEFAULT_SPINDLE_PWM_MIN_VALUE 1 // %
#define DEFAULT_SPINDLE_PWM_MAX_VALUE 100 // %
#define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm (S-value)
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm (S-value)
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
#define DEFAULT_STEPPING_INVERT_MASK 0
#define DEFAULT_DIRECTION_INVERT_MASK 0
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-254, 255 keeps steppers enabled)
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 255// msec (0-254, 255 keeps steppers enabled)
#define DEFAULT_STATUS_REPORT_MASK 0 // WPos enabled
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
#define DEFAULT_REPORT_INCHES 0 // false
#define DEFAULT_INVERT_ST_ENABLE 0 // false
#define DEFAULT_INVERT_LIMIT_PINS 1 // false
#define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
#define DEFAULT_INVERT_LIMIT_PINS 1 // true
#define DEFAULT_SOFT_LIMIT_ENABLE 1 // true
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
#define DEFAULT_INVERT_PROBE_PIN 0 // false
#define DEFAULT_LASER_MODE 1 // false
#define DEFAULT_HOMING_ENABLE 0 // false
#define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
#define DEFAULT_LASER_MODE 1 // true
#define DEFAULT_HOMING_ENABLE 1 // true
#define DEFAULT_HOMING_DIR_MASK 1 // move top/left
#define DEFAULT_HOMING_FEED_RATE 50.0 // mm/min
#define DEFAULT_HOMING_SEEK_RATE 6000.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
#define DEFAULT_HOMING_PULLOFF 2.0 // mm
#define HOMING_CYCLE_0 ((1<<X_AXIS)|(1<<Y_AXIS))
#endif
#ifdef DEFAULTS_FABKIT
@ -146,12 +134,15 @@
#define DEFAULT_X_STEPS_PER_MM 80.0
#define DEFAULT_Y_STEPS_PER_MM 80.0
#define DEFAULT_Z_STEPS_PER_MM 640.0
#define DEFAULT_A_STEPS_PER_MM 160.0
#define DEFAULT_X_MAX_RATE 30000 // mm/min
#define DEFAULT_Y_MAX_RATE 4500 // mm/min
#define DEFAULT_Z_MAX_RATE 1200 // mm/min
#define DEFAULT_X_ACCELERATION (4000.0*60*60) // 5000*60*60 mm/min^2 = 5000 mm/sec^2
#define DEFAULT_Y_ACCELERATION (250.0*60*60) // 5000*60*60 mm/min^2 = 5000 mm/sec^2
#define DEFAULT_Z_ACCELERATION (150.0*60*60) // 5000*60*60 mm/min^2 = 5000 mm/sec^2
#define DEFAULT_A_MAX_RATE 24000.0 // mm/min
#define DEFAULT_X_ACCELERATION (4000.0*60*60) // 4000*60*60 mm/min^2 = 4000 mm/sec^2
#define DEFAULT_Y_ACCELERATION (250.0*60*60) // 250*60*60 mm/min^2 = 250 mm/sec^2
#define DEFAULT_Z_ACCELERATION (150.0*60*60) // 150*60*60 mm/min^2 = 150 mm/sec^2
#define DEFAULT_A_ACCELERATION (150.0*60*60) // 150*60*60 mm/min^2 = 150 mm/sec^2
#define DEFAULT_X_CURRENT 1.5 // amps
#define DEFAULT_Y_CURRENT 1.5 // amps
#define DEFAULT_Z_CURRENT 1.5 // amps
@ -159,29 +150,35 @@
#define DEFAULT_X_MAX_TRAVEL 680.0 // mm
#define DEFAULT_Y_MAX_TRAVEL 460.0 // mm
#define DEFAULT_Z_MAX_TRAVEL 150.0 // mm
#define DEFAULT_A_MAX_TRAVEL 150.0 // mm
#define DEFAULT_SPINDLE_PWM_FREQ 50000 // Hz
#define DEFAULT_SPINDLE_RPM_MAX 0.7 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.08 // rpm
#define DEFAULT_SPINDLE_PWM_OFF_VALUE 0 // %
#define DEFAULT_SPINDLE_PWM_MIN_VALUE 0 // %
#define DEFAULT_SPINDLE_PWM_MAX_VALUE 100 // %
#define DEFAULT_SPINDLE_RPM_MAX 0.7 // rpm (S-value)
#define DEFAULT_SPINDLE_RPM_MIN 0.08 // rpm (S-value)
#define DEFAULT_STEP_PULSE_MICROSECONDS 1
#define DEFAULT_STEPPING_INVERT_MASK 0
#define DEFAULT_DIRECTION_INVERT_MASK 2
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 255 // msec (0-254, 255 keeps steppers enabled)
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 255// msec (0-254, 255 keeps steppers enabled)
#define DEFAULT_STATUS_REPORT_MASK 0 // WPos enabled
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
#define DEFAULT_REPORT_INCHES 0 // false
#define DEFAULT_INVERT_ST_ENABLE 0 // false
#define DEFAULT_INVERT_LIMIT_PINS 1 // false
#define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
#define DEFAULT_INVERT_LIMIT_PINS 1 // true
#define DEFAULT_SOFT_LIMIT_ENABLE 1 // true
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
#define DEFAULT_INVERT_PROBE_PIN 0 // false
#define DEFAULT_LASER_MODE 1 // true
#define DEFAULT_HOMING_ENABLE 1 // false
#define DEFAULT_HOMING_DIR_MASK 1 // move positive dir
#define DEFAULT_HOMING_ENABLE 1 // true
#define DEFAULT_HOMING_DIR_MASK 1 // move top/left
#define DEFAULT_HOMING_FEED_RATE 60.0 // mm/min
#define DEFAULT_HOMING_SEEK_RATE 6000.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
#define DEFAULT_HOMING_PULLOFF 2.0 // mm
#define HOMING_CYCLE_0 (1<<Z_AXIS)
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))
#endif
#ifdef DEFAULTS_SHERLINE_5400

View File

@ -87,6 +87,9 @@ void settings_restore(uint8_t restore_flag) {
settings.arc_tolerance = DEFAULT_ARC_TOLERANCE;
settings.spindle_pwm_freq = DEFAULT_SPINDLE_PWM_FREQ;
settings.spindle_pwm_off_value = DEFAULT_SPINDLE_PWM_OFF_VALUE;
settings.spindle_pwm_min_value = DEFAULT_SPINDLE_PWM_MIN_VALUE;
settings.spindle_pwm_max_value = DEFAULT_SPINDLE_PWM_MAX_VALUE;
settings.rpm_max = DEFAULT_SPINDLE_RPM_MAX;
settings.rpm_min = DEFAULT_SPINDLE_RPM_MIN;

View File

@ -92,7 +92,10 @@ typedef struct {
float junction_deviation;
float arc_tolerance;
uint16_t spindle_pwm_freq;
float spindle_pwm_freq;
float spindle_pwm_off_value; // Percent
float spindle_pwm_min_value; // Percent
float spindle_pwm_max_value; // Percent
float rpm_max;
float rpm_min;

View File

@ -25,10 +25,10 @@
#ifdef VARIABLE_SPINDLE
static float pwm_gradient; // Precalulated value to speed up rpm to PWM conversions.
static float spindle_pwm_period;
static float spindle_pwm_off_value;
static float spindle_pwm_min_value;
static float spindle_pwm_max_value;
float spindle_pwm_period;
float spindle_pwm_off_value;
float spindle_pwm_min_value;
float spindle_pwm_max_value;
#endif
@ -36,12 +36,10 @@ void spindle_init()
{
#ifdef VARIABLE_SPINDLE
spindle_pwm_period = (SystemCoreClock / settings.spindle_pwm_freq);
spindle_pwm_off_value = (spindle_pwm_period * 0.0); // SPINDLE_PWM_PERIOD * fraction
spindle_pwm_min_value = (spindle_pwm_period * 0.0); // SPINDLE_PWM_PERIOD * fraction
spindle_pwm_max_value = (spindle_pwm_period * 1.0); // SPINDLE_PWM_PERIOD * fraction
//pwm_init(&SPINDLE_PWM_CHANNEL, SPINDLE_PWM_USE_PRIMARY_PIN, SPINDLE_PWM_USE_SECONDARY_PIN, SPINDLE_PWM_PERIOD, 0);
pwm_init(&SPINDLE_PWM_CHANNEL, SPINDLE_PWM_USE_PRIMARY_PIN, SPINDLE_PWM_USE_SECONDARY_PIN, spindle_pwm_period, 0); //SPINDLE_PWM_PERIOD
spindle_pwm_off_value = (spindle_pwm_period * settings.spindle_pwm_off_value / 100);
spindle_pwm_min_value = (spindle_pwm_period * settings.spindle_pwm_min_value / 100);
spindle_pwm_max_value = (spindle_pwm_period * settings.spindle_pwm_max_value / 100);
pwm_init(&SPINDLE_PWM_CHANNEL, SPINDLE_PWM_USE_PRIMARY_PIN, SPINDLE_PWM_USE_SECONDARY_PIN, spindle_pwm_period, 0);
pwm_enable(&SPINDLE_PWM_CHANNEL);
/* not ported
@ -54,7 +52,6 @@ void spindle_init()
#endif
*/
//pwm_gradient = (SPINDLE_PWM_MAX_VALUE-SPINDLE_PWM_MIN_VALUE)/(settings.rpm_max-settings.rpm_min);
pwm_gradient = (spindle_pwm_max_value-spindle_pwm_min_value)/(settings.rpm_max-settings.rpm_min);
#else

View File

@ -391,7 +391,7 @@ extern "C" void TIMER1_IRQHandler()
st_go_idle();
#ifdef VARIABLE_SPINDLE
// Ensure pwm is set properly upon completion of rate-controlled motion.
if (st.exec_block->is_pwm_rate_adjusted) { spindle_set_speed(SPINDLE_PWM_OFF_VALUE); }
if (st.exec_block->is_pwm_rate_adjusted) { spindle_set_speed(spindle_pwm_off_value); }
#endif
system_set_exec_state_flag(EXEC_CYCLE_STOP); // Flag main program for cycle end
return; // Nothing to do but exit.
@ -948,7 +948,7 @@ void st_prep_buffer()
prep.current_spindle_pwm = spindle_compute_pwm_value(rpm);
} else {
sys.spindle_speed = 0.0;
prep.current_spindle_pwm = SPINDLE_PWM_OFF_VALUE;
prep.current_spindle_pwm = spindle_pwm_off_value;
}
bit_false(sys.step_control,STEP_CONTROL_UPDATE_SPINDLE_PWM);
}