diff --git a/doc/log/commit_log_v1.0c.txt b/doc/log/commit_log_v1.0c.txt new file mode 100644 index 0000000..4d9b3ff --- /dev/null +++ b/doc/log/commit_log_v1.0c.txt @@ -0,0 +1,25 @@ +---------------- +Date: 2015-11-09 +Author: Sonny Jeon +Subject: Pin state reporting of all pins. Flash optimization. + +- New pin state realtime reporting feature. Instead of `Lim:000` for +limit state reports, the new feature shows `Pin:000|0|0000`, or +something similar. The `|` delimited fields indicate xyz limits, probe, +and control pin states, where 0 is always not triggered, and 1 is +triggered. Invert masks ARE accounted for. + Each field may be enabled or disabled via the `$10` status report +setting. The probe and control pin flags are bits 5 and 6, respectively. + +- Remove the now deprecated `REPORT_CONTROL_PIN_STATE` option in +config.h + +- The old limit pin reports `Lim:000` may be re-enabled by commenting +out `REPORT_ALL_PIN_STATES` in config.h. + +- Incremented the version letter (v1.0c) to indicate the change in +reporting style. + +- Replaced all bit_true_atomic and bit_false_atomic macros with +function calls. This saved a couple hundred bytes of flash. + diff --git a/grbl/config.h b/grbl/config.h index d91c16a..a3d6fd3 100644 --- a/grbl/config.h +++ b/grbl/config.h @@ -127,7 +127,7 @@ #define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable. // Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno -// analog pin 5. Only use this option if you require a second coolant control pin. +// analog pin 4. Only use this option if you require a second coolant control pin. // NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless. // #define ENABLE_M7 // Disabled by default. Uncomment to enable. @@ -157,6 +157,15 @@ // the CONTROL_INVERT_MASK definition in cpu_map.h files. // #define INVERT_ALL_CONTROL_PINS // Default disabled. Uncomment to enable. +// Inverts select limit pin states based on the following mask. This effects all limit pin functions, +// such as hard limits and homing. However, this is different from overall invert limits setting. +// This build option will invert only the limit pins defined here, and then the invert limits setting +// will be applied to all of them. This is useful when a user has a mixed set of limit pins with both +// normally-open(NO) and normally-closed(NC) switches installed on their machine. +// NOTE: PLEASE DO NOT USE THIS, unless you have a situation that needs it. +// #define INVERT_LIMIT_PIN_MASK ((1< diff --git a/grbl/limits.c b/grbl/limits.c index 8386178..5362352 100644 --- a/grbl/limits.c +++ b/grbl/limits.c @@ -70,6 +70,9 @@ uint8_t limits_get_state() { uint8_t limit_state = 0; uint8_t pin = (LIMIT_PIN & LIMIT_MASK); + #ifdef INVERT_LIMIT_PIN_MASK + pin ^= INVERT_LIMIT_PIN_MASK; + #endif if (bit_isfalse(settings.flags,BITFLAG_INVERT_LIMIT_PINS)) { pin ^= LIMIT_MASK; } if (pin) { uint8_t idx; diff --git a/grbl/main.c b/grbl/main.c index 250baaf..32b2e2b 100644 --- a/grbl/main.c +++ b/grbl/main.c @@ -34,7 +34,7 @@ int main(void) stepper_init(); // Configure stepper pins and interrupt timers system_init(); // Configure pinout pins and pin-change interrupt - memset(&sys, 0, sizeof(sys)); // Clear all system variables + memset(&sys, 0, sizeof(system_t)); // Clear all system variables sys.abort = true; // Set abort to complete initialization sei(); // Enable interrupts diff --git a/grbl/planner.c b/grbl/planner.c index 6bc32ee..d03abba 100644 --- a/grbl/planner.c +++ b/grbl/planner.c @@ -200,7 +200,7 @@ static void planner_recalculate() void plan_reset() { - memset(&pl, 0, sizeof(pl)); // Clear planner struct + memset(&pl, 0, sizeof(planner_t)); // Clear planner struct block_buffer_tail = 0; block_buffer_head = 0; // Empty = tail next_buffer_head = 1; // plan_next_block_index(block_buffer_head) @@ -394,11 +394,11 @@ uint8_t plan_check_full_buffer() change the overall maximum entry speed conditions of all blocks. */ // NOTE: Computed without any expensive trig, sin() or acos(), by trig half angle identity of cos(theta). - if (junction_cos_theta > 0.99) { + if (junction_cos_theta > 0.999999) { // For a 0 degree acute junction, just set minimum junction speed. block->max_junction_speed_sqr = MINIMUM_JUNCTION_SPEED*MINIMUM_JUNCTION_SPEED; } else { - junction_cos_theta = max(junction_cos_theta,-0.99); // Check for numerical round-off to avoid divide by zero. + junction_cos_theta = max(junction_cos_theta,-0.999999); // Check for numerical round-off to avoid divide by zero. float sin_theta_d2 = sqrt(0.5*(1.0-junction_cos_theta)); // Trig half angle identity. Always positive. // TODO: Technically, the acceleration used in calculation needs to be limited by the minimum of the diff --git a/grbl/spindle_control.c b/grbl/spindle_control.c index 3356709..fbe04ce 100644 --- a/grbl/spindle_control.c +++ b/grbl/spindle_control.c @@ -106,41 +106,47 @@ void spindle_set_state(uint8_t state, float rpm) #endif // Calculate PWM register value based on rpm max/min settings and programmed rpm. - if (settings.rpm_max <= settings.rpm_min) { - // No PWM range possible. Set simple on/off spindle control pin state. - current_pwm = PWM_MAX_VALUE; - } else { - if (rpm > settings.rpm_max) { rpm = settings.rpm_max; } - if (rpm < settings.rpm_min) { rpm = settings.rpm_min; } - #ifdef SPINDLE_MINIMUM_PWM - float pwm_gradient = (PWM_MAX_VALUE-SPINDLE_MINIMUM_PWM)/(settings.rpm_max-settings.rpm_min); - current_pwm = floor( (rpm-settings.rpm_min)*pwm_gradient + (SPINDLE_MINIMUM_PWM+0.5)); - #else - float pwm_gradient = (PWM_MAX_VALUE)/(settings.rpm_max-settings.rpm_min); - current_pwm = floor( (rpm-settings.rpm_min)*pwm_gradient + 0.5); + if (rpm <= 0.0) { spindle_stop(); } // RPM should never be negative, but check anyway. + else { + if (settings.rpm_max <= settings.rpm_min) { + // No PWM range possible. Set simple on/off spindle control pin state. + current_pwm = PWM_MAX_VALUE; + } else { + if (rpm > settings.rpm_max) { rpm = settings.rpm_max; } + if (rpm < settings.rpm_min) { rpm = settings.rpm_min; } + #ifdef SPINDLE_MINIMUM_PWM + float pwm_gradient = (PWM_MAX_VALUE-SPINDLE_MINIMUM_PWM)/(settings.rpm_max-settings.rpm_min); + current_pwm = floor( (rpm-settings.rpm_min)*pwm_gradient + (SPINDLE_MINIMUM_PWM+0.5)); + #else + float pwm_gradient = (PWM_MAX_VALUE)/(settings.rpm_max-settings.rpm_min); + current_pwm = floor( (rpm-settings.rpm_min)*pwm_gradient + 0.5); + #endif + } + + OCR_REGISTER = current_pwm; // Set PWM output level. + TCCRA_REGISTER |= (1<