diff --git a/config.h b/config.h index e46aa81..daa6268 100644 --- a/config.h +++ b/config.h @@ -2,7 +2,7 @@ config.h - compile time configuration Part of Grbl - Copyright (c) 2011-2013 Sungeun K. Jeon + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud Grbl is free software: you can redistribute it and/or modify @@ -88,7 +88,7 @@ // set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more. #define ACCELERATION_TICKS_PER_SECOND 100 -#define ACTIVE_MULTI_AXIS_STEP_SMOOTHING +#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING #define ENABLE_SOFTWARE_DEBOUNCE // Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at diff --git a/coolant_control.c b/coolant_control.c index 8abd674..b866aef 100644 --- a/coolant_control.c +++ b/coolant_control.c @@ -2,7 +2,7 @@ coolant_control.c - coolant control methods Part of Grbl - Copyright (c) 2012 Sungeun K. Jeon + Copyright (c) 2012-2014 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/coolant_control.h b/coolant_control.h index fd2d549..38f3b43 100644 --- a/coolant_control.h +++ b/coolant_control.h @@ -2,7 +2,7 @@ coolant_control.h - spindle control methods Part of Grbl - Copyright (c) 2012 Sungeun K. Jeon + Copyright (c) 2012-2014 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/cpu_map.h b/cpu_map.h index 0d21fe3..ed97275 100644 --- a/cpu_map.h +++ b/cpu_map.h @@ -2,7 +2,7 @@ cpu_map.h - CPU and pin mapping configuration file Part of Grbl - Copyright (c) 2013 Sungeun K. Jeon + Copyright (c) 2013-2014 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/defaults.h b/defaults.h index 4048511..cbee821 100644 --- a/defaults.h +++ b/defaults.h @@ -2,7 +2,7 @@ defaults.h - defaults settings configuration file Part of Grbl - Copyright (c) 2012-2013 Sungeun K. Jeon + Copyright (c) 2012-2014 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gcode.c b/gcode.c index 0900dec..d8abaf6 100644 --- a/gcode.c +++ b/gcode.c @@ -2,8 +2,8 @@ gcode.c - rs274/ngc parser. Part of Grbl + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2013 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gcode.h b/gcode.h index 6b8949a..8c20957 100644 --- a/gcode.h +++ b/gcode.h @@ -2,8 +2,8 @@ gcode.h - rs274/ngc parser. Part of Grbl + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2012 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/limits.c b/limits.c index 43134e2..a9e15f2 100644 --- a/limits.c +++ b/limits.c @@ -2,8 +2,8 @@ limits.c - code pertaining to limit-switches and performing the homing cycle Part of Grbl + Copyright (c) 2012-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2012-2013 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -132,12 +132,13 @@ void limits_go_home(uint8_t cycle_mask, bool approach, float homing_rate) else { invert_pin = !approach; } // Determine travel distance to the furthest homing switch based on user max travel settings. + // NOTE: settings.max_travel[] is stored as a negative value. float max_travel = settings.max_travel[X_AXIS]; - if (max_travel < settings.max_travel[Y_AXIS]) { max_travel = settings.max_travel[Y_AXIS]; } - if (max_travel < settings.max_travel[Z_AXIS]) { max_travel = settings.max_travel[Z_AXIS]; } - max_travel *= 1.25; // Ensure homing switches engaged by over-estimating max travel. - if (approach) { max_travel = -max_travel; } - + if (max_travel > settings.max_travel[Y_AXIS]) { max_travel = settings.max_travel[Y_AXIS]; } + if (max_travel > settings.max_travel[Z_AXIS]) { max_travel = settings.max_travel[Z_AXIS]; } + max_travel *= -1.25; // Ensure homing switches engaged by over-estimating max travel. + if (!approach) { max_travel = -max_travel; } + // Set target location and rate for active axes. float target[N_AXIS]; uint8_t n_active_axis = 0; diff --git a/limits.h b/limits.h index 9c414a4..9e6fdb9 100644 --- a/limits.h +++ b/limits.h @@ -2,8 +2,8 @@ limits.h - code pertaining to limit-switches and performing the homing cycle Part of Grbl + Copyright (c) 2013-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2013 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/main.c b/main.c index 3e279e0..d347438 100644 --- a/main.c +++ b/main.c @@ -1,9 +1,9 @@ /* main.c - An embedded CNC Controller with rs274/ngc (g-code) support Part of Grbl - + + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2013 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/motion_control.c b/motion_control.c index 94398b7..e30274a 100644 --- a/motion_control.c +++ b/motion_control.c @@ -2,8 +2,8 @@ motion_control.c - high level interface for issuing motion commands Part of Grbl + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2013 Sungeun K. Jeon Copyright (c) 2011 Jens Geisler Grbl is free software: you can redistribute it and/or modify @@ -301,13 +301,7 @@ void mc_homing_cycle() // NOTE: This function is called from the main loop and mc_line() only and executes when one of // two conditions exist respectively: There are no more blocks sent (i.e. streaming is finished, // single commands), or the planner buffer is full and ready to go. -void mc_auto_cycle_start() -{ - if (sys.auto_start) { - st_cycle_start(); - if (bit_isfalse(settings.flags,BITFLAG_AUTO_START)) { sys.auto_start = false; } // Reset auto start per settings. - } -} +void mc_auto_cycle_start() { if (sys.auto_start) { st_cycle_start(); } } // Method to ready the system to reset by setting the runtime reset command and killing any diff --git a/motion_control.h b/motion_control.h index 3ca8d30..a5e0371 100644 --- a/motion_control.h +++ b/motion_control.h @@ -2,8 +2,8 @@ motion_control.h - high level interface for issuing motion commands Part of Grbl + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2013 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/nuts_bolts.c b/nuts_bolts.c index 703c1db..6914052 100644 --- a/nuts_bolts.c +++ b/nuts_bolts.c @@ -2,8 +2,8 @@ nuts_bolts.c - Shared functions Part of Grbl + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2012 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,6 @@ #include "planner.h" #define MAX_INT_DIGITS 8 // Maximum number of digits in int32 (and float) -extern float __floatunsisf (unsigned long); // Extracts a floating point value from a string. The following code is based loosely on // the avr-libc strtod() function by Michael Stumpf and Dmitry Xmelkov and many freely @@ -79,7 +78,7 @@ int read_float(char *line, uint8_t *char_counter, float *float_ptr) // Convert integer into floating point. float fval; - fval = __floatunsisf(intval); + fval = (float)intval; // Apply decimal. Should perform no more than two floating point multiplications for the // expected range of E0 to E-4. diff --git a/nuts_bolts.h b/nuts_bolts.h index ab19485..5140575 100644 --- a/nuts_bolts.h +++ b/nuts_bolts.h @@ -2,8 +2,8 @@ nuts_bolts.h - Header file for shared definitions, variables, and functions Part of Grbl + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2013 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/planner.c b/planner.c index 09a2c44..143837a 100644 --- a/planner.c +++ b/planner.c @@ -2,7 +2,7 @@ planner.c - buffers movement commands and manages the acceleration profile plan Part of Grbl - Copyright (c) 2011-2013 Sungeun K. Jeon + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud Copyright (c) 2011 Jens Geisler @@ -255,7 +255,8 @@ uint8_t plan_check_full_buffer() // during a synchronize call, if it should happen. Also, waits for clean cycle end. void plan_synchronize() { - sys.auto_start = true; // Set auto start to resume cycle after synchronize and caller completes. + // Check and set auto start to resume cycle after synchronize and caller completes. + if (sys.state == STATE_CYCLE) { sys.auto_start = true; } while (plan_get_current_block() || (sys.state == STATE_CYCLE)) { protocol_execute_runtime(); // Check and execute run-time commands if (sys.abort) { return; } // Check for system abort diff --git a/planner.h b/planner.h index 3ec3bea..1cc4309 100644 --- a/planner.h +++ b/planner.h @@ -2,7 +2,7 @@ planner.h - buffers movement commands and manages the acceleration profile plan Part of Grbl - Copyright (c) 2011-2013 Sungeun K. Jeon + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud Grbl is free software: you can redistribute it and/or modify diff --git a/print.c b/print.c index 7a7686b..0e2f9b8 100644 --- a/print.c +++ b/print.c @@ -2,8 +2,8 @@ print.c - Functions for formatting output strings Part of Grbl + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2012 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/print.h b/print.h index 8a161c1..ecd4238 100644 --- a/print.h +++ b/print.h @@ -2,8 +2,8 @@ print.h - Functions for formatting output strings Part of Grbl + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2012 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/protocol.c b/protocol.c index 1e8e9cb..29d81e6 100644 --- a/protocol.c +++ b/protocol.c @@ -2,8 +2,8 @@ protocol.c - the serial protocol master control unit Part of Grbl + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2013 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/protocol.h b/protocol.h index 4d90c1c..b6267d4 100644 --- a/protocol.h +++ b/protocol.h @@ -2,8 +2,8 @@ protocol.h - the serial protocol master control unit Part of Grbl + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2012 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/report.c b/report.c index 49e6501..7e32ef1 100644 --- a/report.c +++ b/report.c @@ -2,7 +2,7 @@ report.c - reporting and messaging methods Part of Grbl - Copyright (c) 2012-2013 Sungeun K. Jeon + Copyright (c) 2012-2014 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/report.h b/report.h index d9fd5b7..53c97dc 100644 --- a/report.h +++ b/report.h @@ -2,7 +2,7 @@ report.h - reporting and messaging methods Part of Grbl - Copyright (c) 2012-2013 Sungeun K. Jeon + Copyright (c) 2012-2014 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/serial.c b/serial.c index c07e64b..382ee41 100644 --- a/serial.c +++ b/serial.c @@ -2,8 +2,8 @@ serial.c - Low level functions for sending and recieving bytes via the serial port Part of Grbl + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2012 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/serial.h b/serial.h index 723d48f..e768b44 100644 --- a/serial.h +++ b/serial.h @@ -2,8 +2,8 @@ serial.c - Low level functions for sending and recieving bytes via the serial port Part of Grbl + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2012 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/settings.c b/settings.c index 1ba0629..ae36abf 100644 --- a/settings.c +++ b/settings.c @@ -2,8 +2,8 @@ settings.c - eeprom configuration handling Part of Grbl + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2013 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/settings.h b/settings.h index 7d435d9..04883b9 100644 --- a/settings.h +++ b/settings.h @@ -2,8 +2,8 @@ settings.h - eeprom configuration handling Part of Grbl + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2013 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/spindle_control.c b/spindle_control.c index 5bfe621..5786762 100644 --- a/spindle_control.c +++ b/spindle_control.c @@ -2,8 +2,8 @@ spindle_control.c - spindle control methods Part of Grbl + Copyright (c) 2012-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2012 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/spindle_control.h b/spindle_control.h index d3fca1e..ba8f051 100644 --- a/spindle_control.h +++ b/spindle_control.h @@ -2,8 +2,8 @@ spindle_control.h - spindle control methods Part of Grbl + Copyright (c) 2012-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2012 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/stepper.c b/stepper.c index b9a80f9..128646c 100644 --- a/stepper.c +++ b/stepper.c @@ -2,7 +2,7 @@ stepper.c - stepper motor driver: executes motion plans using stepper motors Part of Grbl - Copyright (c) 2011-2013 Sungeun K. Jeon + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud Grbl is free software: you can redistribute it and/or modify @@ -63,7 +63,11 @@ typedef struct { uint16_t n_step; // Number of step events to be executed for this segment uint8_t st_block_index; // Stepper block data index. Uses this information to execute this segment. uint16_t cycles_per_tick; // Step distance traveled per ISR tick, aka step rate. - uint8_t amass_level; + #ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING + uint8_t amass_level; + #else + uint8_t prescaler; + #endif } segment_t; static segment_t segment_buffer[SEGMENT_BUFFER_SIZE]; @@ -83,7 +87,9 @@ typedef struct { uint8_t step_pulse_time; // Step pulse reset time after step rise uint8_t step_outbits; // The next stepping-bits to be output uint8_t dir_outbits; - uint32_t steps[N_AXIS]; + #ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING + uint32_t steps[N_AXIS]; + #endif uint16_t step_count; // Steps remaining in line segment motion uint8_t exec_block_index; // Tracks the current st_block index. Change indicates new block. @@ -278,7 +284,9 @@ ISR(TIMER1_COMPA_vect) // Initialize new step segment and load number of steps to execute st.exec_segment = &segment_buffer[segment_buffer_tail]; // Initialize step segment timing per step and load number of steps to execute. - // TCCR1B = (TCCR1B & ~(0x07<prescaler<prescaler<cycles_per_tick; st.step_count = st.exec_segment->n_step; // NOTE: Can sometimes be zero when moving slow. // If the new segment starts a new planner block, initialize stepper variables and counters. @@ -292,9 +300,11 @@ ISR(TIMER1_COMPA_vect) st.counter_y = st.counter_x; st.counter_z = st.counter_x; } - st.steps[X_AXIS] = st.exec_block->steps[X_AXIS] >> st.exec_segment->amass_level; - st.steps[Y_AXIS] = st.exec_block->steps[Y_AXIS] >> st.exec_segment->amass_level; - st.steps[Z_AXIS] = st.exec_block->steps[Z_AXIS] >> st.exec_segment->amass_level; + #ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING + st.steps[X_AXIS] = st.exec_block->steps[X_AXIS] >> st.exec_segment->amass_level; + st.steps[Y_AXIS] = st.exec_block->steps[Y_AXIS] >> st.exec_segment->amass_level; + st.steps[Z_AXIS] = st.exec_block->steps[Z_AXIS] >> st.exec_segment->amass_level; + #endif } else { // Segment buffer empty. Shutdown. st_go_idle(); @@ -307,21 +317,33 @@ ISR(TIMER1_COMPA_vect) st.step_outbits = 0; // Execute step displacement profile by Bresenham line algorithm - st.counter_x += st.steps[X_AXIS]; + #ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING + st.counter_x += st.steps[X_AXIS]; + #else + st.counter_x += st.exec_block->steps[X_AXIS]; + #endif if (st.counter_x > st.exec_block->step_event_count) { st.step_outbits |= (1<step_event_count; if (st.exec_block->direction_bits & (1<steps[Y_AXIS]; + #endif if (st.counter_y > st.exec_block->step_event_count) { st.step_outbits |= (1<step_event_count; if (st.exec_block->direction_bits & (1<steps[Z_AXIS]; + #endif if (st.counter_z > st.exec_block->step_event_count) { st.step_outbits |= (1<step_event_count; @@ -433,6 +455,7 @@ void st_cycle_start() sys.state = STATE_CYCLE; st_prep_buffer(); // Initialize step segment buffer before beginning cycle. st_wake_up(); + if (bit_isfalse(settings.flags,BITFLAG_AUTO_START)) { sys.auto_start = false; } // Reset auto start per settings. } } @@ -500,9 +523,9 @@ void st_update_plan_block_parameters() */ void st_prep_buffer() { - if (sys.state == STATE_QUEUED) { return; } // Block until a motion state is issued while (segment_buffer_tail != segment_next_head) { // Check if we need to fill the buffer. - + if (sys.state == STATE_QUEUED) { return; } // Block until a motion state is issued + // Determine if we need to load a new planner block or if the block remainder is replanned. if (pl_block == NULL) { pl_block = plan_get_current_block(); // Query planner for a queued block @@ -520,16 +543,16 @@ void st_prep_buffer() // when the segment buffer completes the planner block, it may be discarded immediately. st_prep_block = &st_block_buffer[prep.st_block_index]; st_prep_block->direction_bits = pl_block->direction_bits; - #ifdef ACTIVE_MULTI_AXIS_STEP_SMOOTHING - st_prep_block->steps[X_AXIS] = pl_block->steps[X_AXIS] << MAX_AMASS_LEVEL; - st_prep_block->steps[Y_AXIS] = pl_block->steps[Y_AXIS] << MAX_AMASS_LEVEL; - st_prep_block->steps[Z_AXIS] = pl_block->steps[Z_AXIS] << MAX_AMASS_LEVEL; - st_prep_block->step_event_count = pl_block->step_event_count << MAX_AMASS_LEVEL; - #else + #ifndef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING st_prep_block->steps[X_AXIS] = pl_block->steps[X_AXIS]; st_prep_block->steps[Y_AXIS] = pl_block->steps[Y_AXIS]; st_prep_block->steps[Z_AXIS] = pl_block->steps[Z_AXIS]; st_prep_block->step_event_count = pl_block->step_event_count; + #else + st_prep_block->steps[X_AXIS] = pl_block->steps[X_AXIS] << MAX_AMASS_LEVEL; + st_prep_block->steps[Y_AXIS] = pl_block->steps[Y_AXIS] << MAX_AMASS_LEVEL; + st_prep_block->steps[Z_AXIS] = pl_block->steps[Z_AXIS] << MAX_AMASS_LEVEL; + st_prep_block->step_event_count = pl_block->step_event_count << MAX_AMASS_LEVEL; #endif // Initialize segment buffer data for generating the segments. @@ -701,8 +724,8 @@ void st_prep_buffer() float inv_rate = dt/(prep.steps_remaining-steps_remaining); cycles = ceil( (TICKS_PER_MICROSECOND*1000000*60)*inv_rate ); // (cycles/step) - #ifdef ACTIVE_MULTI_AXIS_STEP_SMOOTHING - // Compute step timing and multi-axis smoothing level. + #ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING + // Compute step timing and multi-axis smoothing level. // NOTE: Only one prescalar is required with AMASS enabled. if (cycles > AMASS_LEVEL1) { if (cycles > AMASS_LEVEL2) { @@ -712,8 +735,24 @@ void st_prep_buffer() cycles >>= prep_segment->amass_level; prep_segment->n_step <<= prep_segment->amass_level; } else { prep_segment->amass_level = 0; } - if (cycles < (1UL << 16)) { prep_segment->cycles_per_tick = cycles; } - else { prep_segment->cycles_per_tick = 0xffff; } // Just set the slowest speed possible. (4.1ms @ 16MHz) + if (cycles < (1UL << 16)) { prep_segment->cycles_per_tick = cycles; } // < 65536 (4.1ms @ 16MHz) + else { prep_segment->cycles_per_tick = 0xffff; } // Just set the slowest speed possible. + #else + // Compute step timing and timer prescalar for normal step generation. + if (cycles < (1UL << 16)) { // < 65536 (4.1ms @ 16MHz) + prep_segment->prescaler = 1; // prescaler: 0 + prep_segment->cycles_per_tick = cycles; + } else if (cycles < (1UL << 19)) { // < 524288 (32.8ms@16MHz) + prep_segment->prescaler = 2; // prescaler: 8 + prep_segment->cycles_per_tick = cycles >> 3; + } else { + prep_segment->prescaler = 3; // prescaler: 64 + if (cycles < (1UL << 22)) { // < 4194304 (262ms@16MHz) + prep_segment->cycles_per_tick = cycles >> 6; + } else { // Just set the slowest speed possible. + prep_segment->cycles_per_tick = 0xffff; + } + } #endif // Determine end of segment conditions. Setup initial conditions for next segment. @@ -754,8 +793,6 @@ void st_prep_buffer() // int32_t blength = segment_buffer_head - segment_buffer_tail; // if (blength < 0) { blength += SEGMENT_BUFFER_SIZE; } // printInteger(blength); - - if (sys.state & (STATE_QUEUED | STATE_HOMING)) { return; } // Force exit or one prepped segment. } } @@ -785,31 +822,3 @@ void st_prep_buffer() we know when the plan is feasible in the context of what's already in the code and not require too much more code? */ - -// static void st_config_step_timer(uint32_t cycles) -// { -// if (cycles < (1UL << 16)) { // < 65536 (4.1ms @ 16MHz) -// prep_segment->prescaler = 1; // prescaler: 0 -// prep_segment->cycles_per_tick = cycles; -// } else { -// prep_segment->prescaler = 2; // prescaler: 8 -// if (cycles < (1UL << 19)) { // < 524288 (32.8ms@16MHz) -// prep_segment->cycles_per_tick = cycles >> 3; -// -// // } else if (cycles < (1UL << 22)) { // < 4194304 (262ms@16MHz) -// // prep_segment->prescaler = 3; // prescaler: 64 -// // prep_segment->cycles_per_tick = cycles >> 6; -// // } else if (cycles < (1UL << 24)) { // < 16777216 (1.05sec@16MHz) -// // prep_segment->prescaler = 4; // prescaler: 256 -// // prep_segment->cycles_per_tick = (cycles >> 8); -// // } else { -// // prep_segment->prescaler = 5; // prescaler: 1024 -// // if (cycles < (1UL << 26)) { // < 67108864 (4.19sec@16MHz) -// // prep_segment->cycles_per_tick = (cycles >> 10); -// -// } else { // Just set the slowest speed possible. -// prep_segment->cycles_per_tick = 0xffff; -// } -// printString("X"); -// } -// } \ No newline at end of file diff --git a/stepper.h b/stepper.h index 9fc2c73..a72a565 100644 --- a/stepper.h +++ b/stepper.h @@ -2,8 +2,8 @@ stepper.h - stepper motor driver: executes motion plans of planner.c using the stepper motors Part of Grbl + Copyright (c) 2011-2014 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud - Copyright (c) 2011-2013 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by