Minor prescalar optimization. Changed up some defines.
This commit is contained in:
parent
420c7c2584
commit
4224ab4999
15
config.h
15
config.h
@ -58,14 +58,13 @@
|
||||
#define COOLANT_FLOOD_PORT PORTC
|
||||
#define COOLANT_FLOOD_BIT 0 // Uno Analog Pin 0
|
||||
|
||||
#define ENABLE_M7 0 // DISABLED BY DEFAULT: To enable, change to '1' and recompile.
|
||||
#if ENABLE_M7
|
||||
// #define ENABLE_M7 // Mist coolant disabled by default. Uncomment to enable.
|
||||
#ifdef ENABLE_M7
|
||||
#define COOLANT_MIST_DDR DDRC
|
||||
#define COOLANT_MIST_PORT PORTC
|
||||
#define COOLANT_MIST_BIT 1 // Uno Analog Pin 1
|
||||
#endif
|
||||
|
||||
|
||||
// Define runtime command special characters. These characters are 'picked-off' directly from the
|
||||
// serial read data stream and are not passed to the grbl line execution parser. Select characters
|
||||
// that do not and must not exist in the streamed g-code program. ASCII control characters may be
|
||||
@ -87,7 +86,7 @@
|
||||
// entering g-code into grbl, i.e. locating part zero or simple manual machining. If the axes drift,
|
||||
// grbl has no way to know this has happened, since stepper motors are open-loop control. Depending
|
||||
// on the machine, this parameter may need to be larger or smaller than the default time.
|
||||
// NOTE: If set to zero, the delay will not be compiled.
|
||||
// NOTE: If the define commented, the delay will not be compiled.
|
||||
#define STEPPER_IDLE_LOCK_TIME 25 // (milliseconds) - Integer > 0
|
||||
|
||||
// The temporal resolution of the acceleration management subsystem. Higher number give smoother
|
||||
@ -137,7 +136,7 @@
|
||||
// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard
|
||||
// terminal programs since their firmware correctly manage these XON/XOFF characters. In any
|
||||
// case, please report any successes to grbl administrators!
|
||||
#define ENABLE_XONXOFF 0 // Boolean. Default disabled.
|
||||
// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.
|
||||
|
||||
// Creates a delay between the direction pin setting and corresponding step pulse by creating
|
||||
// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare)
|
||||
@ -151,9 +150,9 @@
|
||||
// of your successes or difficulties, as we will monitor this and possibly integrate this as a
|
||||
// standard feature for future releases. However, we suggest to first try our direction delay
|
||||
// hack/solution posted in the Wiki involving inverting the stepper pin mask.
|
||||
// NOTE: If set greater than zero, step pulse delay will be compiled and enabled. Also, the
|
||||
// total delay added with the Grbl settings pulse microseconds must not exceed 127 ms.
|
||||
#define STEP_PULSE_DELAY 0 // Step pulse delay in microseconds. Default disabled.
|
||||
// NOTE: Uncomment to enable. The recommended delay should be > 3us but not exceed a total
|
||||
// time of 127us when added with the Grbl settings pulse microsecond.
|
||||
// #define STEP_PULSE_DELAY 5 // Step pulse delay in microseconds. Default disabled.
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -39,7 +39,7 @@ void coolant_init()
|
||||
|
||||
void coolant_stop()
|
||||
{
|
||||
#if ENABLE_M7
|
||||
#ifdef ENABLE_M7
|
||||
COOLANT_MIST_PORT &= ~(1 << COOLANT_MIST_BIT);
|
||||
#endif
|
||||
COOLANT_FLOOD_PORT &= ~(1 << COOLANT_FLOOD_BIT);
|
||||
@ -53,7 +53,7 @@ void coolant_run(uint8_t mode)
|
||||
plan_synchronize(); // Ensure coolant turns on when specified in program.
|
||||
if (mode == COOLANT_FLOOD_ENABLE) {
|
||||
COOLANT_FLOOD_PORT |= (1 << COOLANT_FLOOD_BIT);
|
||||
#if ENABLE_M7
|
||||
#ifdef ENABLE_M7
|
||||
} else if (mode == COOLANT_MIST_ENABLE) {
|
||||
COOLANT_MIST_PORT |= (1 << COOLANT_MIST_BIT);
|
||||
#endif
|
||||
|
10
gcode.c
10
gcode.c
@ -216,7 +216,7 @@ uint8_t gc_execute_line(char *line)
|
||||
case 3: gc.spindle_direction = 1; break;
|
||||
case 4: gc.spindle_direction = -1; break;
|
||||
case 5: gc.spindle_direction = 0; break;
|
||||
#if ENABLE_M7
|
||||
#ifdef ENABLE_M7
|
||||
case 7: gc.coolant_mode = COOLANT_MIST_ENABLE; break;
|
||||
#endif
|
||||
case 8: gc.coolant_mode = COOLANT_FLOOD_ENABLE; break;
|
||||
@ -578,16 +578,16 @@ static int next_statement(char *letter, double *double_ptr, char *line, uint8_t
|
||||
- Evaluation of expressions
|
||||
- Variables
|
||||
- Multiple home locations
|
||||
- Multiple coordinate systems (Up to 6 may be added via config.h)
|
||||
- Probing
|
||||
- Override control
|
||||
- Tool changes
|
||||
|
||||
|
||||
(*) Indicates optional parameter, enabled through config.h and re-compile
|
||||
group 0 = {G92.2, G92.3} (Non modal: Cancel and re-enable G92 offsets)
|
||||
group 1 = {G38.2, G81 - G89} (Motion modes: straight probe, canned cycles)
|
||||
group 6 = {M6} (Tool change)
|
||||
group 8 = {M7} coolant (M7 mist may be enabled via config.h)
|
||||
group 8 = {*M7} enable mist coolant
|
||||
group 9 = {M48, M49} enable/disable feed and speed override switches
|
||||
group 12 = {G55, G56, G57, G58, G59, G59.1, G59.2, G59.3} coordinate system selection
|
||||
group 12 = {*G55, *G56, *G57, *G58, *G59, G59.1, G59.2, G59.3} coordinate system selection
|
||||
group 13 = {G61, G61.1, G64} path control mode
|
||||
*/
|
||||
|
26
stepper.c
26
stepper.c
@ -91,7 +91,7 @@ static void st_wake_up()
|
||||
// Initialize stepper output bits
|
||||
out_bits = (0) ^ (settings.invert_mask);
|
||||
// Initialize step pulse timing from settings. Here to ensure updating after re-writing.
|
||||
#if STEP_PULSE_DELAY > 0
|
||||
#ifdef STEP_PULSE_DELAY
|
||||
// Set total step pulse time after direction pin set. Ad hoc computation from oscilloscope.
|
||||
step_pulse_time = -(((settings.pulse_microseconds+STEP_PULSE_DELAY-2)*TICKS_PER_MICROSECOND) >> 3);
|
||||
// Set delay between direction pin write and step command.
|
||||
@ -113,7 +113,7 @@ void st_go_idle()
|
||||
TIMSK1 &= ~(1<<OCIE1A);
|
||||
// Force stepper dwell to lock axes for a defined amount of time to ensure the axes come to a complete
|
||||
// stop and not drift from residual inertial forces at the end of the last movement.
|
||||
#if STEPPER_IDLE_LOCK_TIME > 0
|
||||
#ifdef STEPPER_IDLE_LOCK_TIME
|
||||
_delay_ms(STEPPER_IDLE_LOCK_TIME);
|
||||
#endif
|
||||
// Disable steppers by setting stepper disable
|
||||
@ -145,7 +145,7 @@ ISR(TIMER1_COMPA_vect)
|
||||
// Set the direction pins a couple of nanoseconds before we step the steppers
|
||||
STEPPING_PORT = (STEPPING_PORT & ~DIRECTION_MASK) | (out_bits & DIRECTION_MASK);
|
||||
// Then pulse the stepping pins
|
||||
#if STEP_PULSE_DELAY > 0
|
||||
#ifdef STEP_PULSE_DELAY
|
||||
step_bits = (STEPPING_PORT & ~STEP_MASK) | out_bits; // Store out_bits to prevent overwriting.
|
||||
#else // Normal operation
|
||||
STEPPING_PORT = (STEPPING_PORT & ~STEP_MASK) | out_bits;
|
||||
@ -314,7 +314,7 @@ ISR(TIMER2_OVF_vect)
|
||||
TCCR2B = 0; // Disable Timer2 to prevent re-entering this interrupt when it's not needed.
|
||||
}
|
||||
|
||||
#if STEP_PULSE_DELAY > 0
|
||||
#ifdef STEP_PULSE_DELAY
|
||||
// This interrupt is used only when STEP_PULSE_DELAY is enabled. Here, the step pulse is
|
||||
// initiated after the STEP_PULSE_DELAY time period has elapsed. The ISR TIMER2_OVF interrupt
|
||||
// will then trigger after the appropriate settings.pulse_microseconds, as in normal operation.
|
||||
@ -358,7 +358,7 @@ void st_init()
|
||||
TCCR2B = 0; // Disable timer until needed.
|
||||
TIMSK2 |= (1<<TOIE2);
|
||||
|
||||
#if STEP_PULSE_DELAY > 0
|
||||
#ifdef STEP_PULSE_DELAY
|
||||
TIMSK2 |= (1<<OCIE2A); // Enable Timer2 Compare Match A interrupt
|
||||
#endif
|
||||
|
||||
@ -371,36 +371,36 @@ void st_init()
|
||||
static uint32_t config_step_timer(uint32_t cycles)
|
||||
{
|
||||
uint16_t ceiling;
|
||||
uint16_t prescaler;
|
||||
uint8_t prescaler;
|
||||
uint32_t actual_cycles;
|
||||
if (cycles <= 0xffffL) {
|
||||
ceiling = cycles;
|
||||
prescaler = 0; // prescaler: 0
|
||||
prescaler = 1; // prescaler: 0
|
||||
actual_cycles = ceiling;
|
||||
} else if (cycles <= 0x7ffffL) {
|
||||
ceiling = cycles >> 3;
|
||||
prescaler = 1; // prescaler: 8
|
||||
prescaler = 2; // prescaler: 8
|
||||
actual_cycles = ceiling * 8L;
|
||||
} else if (cycles <= 0x3fffffL) {
|
||||
ceiling = cycles >> 6;
|
||||
prescaler = 2; // prescaler: 64
|
||||
prescaler = 3; // prescaler: 64
|
||||
actual_cycles = ceiling * 64L;
|
||||
} else if (cycles <= 0xffffffL) {
|
||||
ceiling = (cycles >> 8);
|
||||
prescaler = 3; // prescaler: 256
|
||||
prescaler = 4; // prescaler: 256
|
||||
actual_cycles = ceiling * 256L;
|
||||
} else if (cycles <= 0x3ffffffL) {
|
||||
ceiling = (cycles >> 10);
|
||||
prescaler = 4; // prescaler: 1024
|
||||
prescaler = 5; // prescaler: 1024
|
||||
actual_cycles = ceiling * 1024L;
|
||||
} else {
|
||||
// Okay, that was slower than we actually go. Just set the slowest speed
|
||||
ceiling = 0xffff;
|
||||
prescaler = 4;
|
||||
prescaler = 6;
|
||||
actual_cycles = 0xffff * 1024;
|
||||
}
|
||||
// Set prescaler
|
||||
TCCR1B = (TCCR1B & ~(0x07<<CS10)) | ((prescaler+1)<<CS10);
|
||||
TCCR1B = (TCCR1B & ~(0x07<<CS10)) | (prescaler<<CS10);
|
||||
// Set ceiling
|
||||
OCR1A = ceiling;
|
||||
return(actual_cycles);
|
||||
|
Loading…
Reference in New Issue
Block a user