Enable Linear Advance. Safe-guard against old K values by disabling LA if K > 10.0

This commit is contained in:
Ted Hess 2018-02-27 13:33:43 -05:00
parent fd9caa1f54
commit ed4b3ea101
5 changed files with 14 additions and 8 deletions

View File

@ -28,7 +28,7 @@ install:
script: script:
- GIT_VERSION=$(git rev-parse --short HEAD) - GIT_VERSION=$(git rev-parse --short HEAD)
- VARIANTS=$(ls Firmware/variants/1_75_MK2*) - VARIANTS=$(find Firmware/variants -name "1_75mm_MK2*" -printf "%f\n")
- for VARIANT in $VARIANTS; do - for VARIANT in $VARIANTS; do
cp Firmware/variants/${VARIANT} Firmware/Configuration_prusa.h ; cp Firmware/variants/${VARIANT} Firmware/Configuration_prusa.h ;
arduino --pref build.path=. --verify --verbose-build --board rambo:avr:rambo $PWD/Firmware/Firmware.ino ; arduino --pref build.path=. --verify --verbose-build --board rambo:avr:rambo $PWD/Firmware/Firmware.ino ;

View File

@ -10,7 +10,7 @@
// Firmware version // Firmware version
#define FW_version "3.1.0" #define FW_version "3.1.0"
#define FW_local_variant 8 #define FW_local_variant 9
#define FW_report_version FW_version " r" STR(FW_local_variant) #define FW_report_version FW_version " r" STR(FW_local_variant)
#define FW_PRUSA3D_MAGIC "PRUSA3DFW" #define FW_PRUSA3D_MAGIC "PRUSA3DFW"

View File

@ -334,7 +334,7 @@
* See http://marlinfw.org/docs/features/lin_advance.html for full instructions. * See http://marlinfw.org/docs/features/lin_advance.html for full instructions.
* Mention @Sebastianv650 on GitHub to alert the author of any issues. * Mention @Sebastianv650 on GitHub to alert the author of any issues.
*/ */
//#define LIN_ADVANCE #define LIN_ADVANCE
#ifdef LIN_ADVANCE #ifdef LIN_ADVANCE
#define LIN_ADVANCE_K 0 // Unit: mm compression per 1mm/s extruder speed #define LIN_ADVANCE_K 0 // Unit: mm compression per 1mm/s extruder speed
//#define LA_DEBUG // If enabled, this will generate debug information output over USB. //#define LA_DEBUG // If enabled, this will generate debug information output over USB.

View File

@ -2096,7 +2096,9 @@ void gcode_M768() {
inline void gcode_M900() { inline void gcode_M900() {
st_synchronize(); st_synchronize();
const float newK = code_seen('K') ? code_value_float() : -1; float newK = code_seen('K') ? code_value_float() : -1;
// [Filter older style K-factor - Don't do anything dumb]
if (newK > 10.0) newK = LIN_ADVANCE_K;
if (newK >= 0) extruder_advance_K = newK; if (newK >= 0) extruder_advance_K = newK;
SERIAL_ECHO_START; SERIAL_ECHO_START;

View File

@ -39,7 +39,6 @@
//=========================================================================== //===========================================================================
block_t *current_block; // A pointer to the block currently being traced block_t *current_block; // A pointer to the block currently being traced
//=========================================================================== //===========================================================================
//=============================private variables ============================ //=============================private variables ============================
//=========================================================================== //===========================================================================
@ -345,7 +344,7 @@ ISR(TIMER1_COMPA_vect) {
void isr() { void isr() {
#ifndef LIN_ADVANCE #ifndef LIN_ADVANCE
// Disable Timer0 ISRs and enable global ISR again to capture UART events (incoming chars) // Disable Timer1 ISRs and enable global ISR again to capture UART events (incoming chars)
DISABLE_TEMPERATURE_INTERRUPT(); // Temperature ISR DISABLE_TEMPERATURE_INTERRUPT(); // Temperature ISR
DISABLE_STEPPER_DRIVER_INTERRUPT(); DISABLE_STEPPER_DRIVER_INTERRUPT();
sei(); sei();
@ -726,6 +725,10 @@ void isr() {
} }
#ifndef LIN_ADVANCE #ifndef LIN_ADVANCE
// Don't run the ISR faster than possible
if (OCR1A < TCNT1 + 16)
OCR1A = TCNT1 + 16;
ENABLE_ISRs(); // Re-enable ISRs ENABLE_ISRs(); // Re-enable ISRs
#endif #endif
} }
@ -775,7 +778,7 @@ void isr() {
} }
void advance_isr_scheduler() { void advance_isr_scheduler() {
// Disable Timer0 ISRs and enable global ISR again to capture UART events (incoming chars) // Disable Timer1 ISRs and enable global ISR again to capture UART events (incoming chars)
DISABLE_TEMPERATURE_INTERRUPT(); // Temperature ISR DISABLE_TEMPERATURE_INTERRUPT(); // Temperature ISR
DISABLE_STEPPER_DRIVER_INTERRUPT(); DISABLE_STEPPER_DRIVER_INTERRUPT();
sei(); sei();
@ -806,7 +809,8 @@ void isr() {
} }
// Don't run the ISR faster than possible // Don't run the ISR faster than possible
if (OCR1A < TCNT1 + 16) OCR1A = TCNT1 + 16; if (OCR1A < TCNT1 + 16)
OCR1A = TCNT1 + 16;
// Restore original ISR settings // Restore original ISR settings
ENABLE_ISRs(); ENABLE_ISRs();