# HG changeset patch # User mbayer # Date 1446899086 -3600 # Node ID b584642d4f584cf6de12e9f0050c3bcc081118f1 # Parent 2c8ba1964db78983f651465676edcf7f9e9cd864 several modifications to support laser enable - still needs cleanup diff -r 2c8ba1964db7 -r b584642d4f58 Marlin.ino --- a/Marlin.ino Sat Nov 07 13:23:07 2015 +0100 +++ b/Marlin.ino Sat Nov 07 13:24:46 2015 +0100 @@ -625,18 +625,18 @@ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); \ destination[LETTER##_AXIS] = 1.1 * max_length[LETTER##_AXIS] * LETTER##_HOME_DIR; \ feedrate = fast_home_feedrate[LETTER##_AXIS]; \ - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \ + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder, false); \ st_synchronize();\ \ current_position[LETTER##_AXIS] = 0;\ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\ destination[LETTER##_AXIS] = -LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\ - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \ + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder, false); \ st_synchronize();\ \ destination[LETTER##_AXIS] = 2*LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\ feedrate = homing_feedrate[LETTER##_AXIS] ; \ - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \ + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder, false); \ st_synchronize();\ \ current_position[LETTER##_AXIS] = LETTER##_HOME_POS;\ @@ -714,10 +714,16 @@ switch((int)code_value()) { case 0: // G0 -> G1 + if(Stopped == false) { + get_coordinates(); // For X Y Z E F + prepare_move(false); + //ClearToSend(); + return; + } case 1: // G1 if(Stopped == false) { get_coordinates(); // For X Y Z E F - prepare_move(); + prepare_move(true); //ClearToSend(); return; } @@ -1562,20 +1568,20 @@ { destination[Z_AXIS] += z_off_d; feedrate = fast_home_feedrate[Z_AXIS]; - prepare_move(); + prepare_move(false); destination[X_AXIS] = temp_position[X_AXIS] + x_off_d; destination[Y_AXIS] = temp_position[Y_AXIS] + y_off_d; feedrate = fast_home_feedrate[X_AXIS]; - prepare_move(); + prepare_move(false); } else { destination[X_AXIS] += x_off_d; destination[Y_AXIS] += y_off_d; feedrate = fast_home_feedrate[X_AXIS]; - prepare_move(); + prepare_move(false); destination[Z_AXIS] = temp_position[Z_AXIS] + z_off_d; feedrate = fast_home_feedrate[Z_AXIS]; - prepare_move(); + prepare_move(false); } for(int8_t i=0; i < NUM_AXIS; i++) @@ -1656,7 +1662,7 @@ } } -void prepare_move() +void prepare_move(bool laser_on) { // transform destination ********************************************* @@ -1675,7 +1681,7 @@ if (modified_destination[Z_AXIS] > max_length[Z_AXIS]) modified_destination[Z_AXIS] = max_length[Z_AXIS]; } previous_millis_cmd = millis(); - plan_buffer_line(modified_destination[X_AXIS], modified_destination[Y_AXIS], modified_destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); + plan_buffer_line(modified_destination[X_AXIS], modified_destination[Y_AXIS], modified_destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder, laser_on); for(int8_t i=0; i < NUM_AXIS; i++) { current_position[i] = destination[i]; } diff -r 2c8ba1964db7 -r b584642d4f58 motion_control.cpp --- a/motion_control.cpp Sat Nov 07 13:23:07 2015 +0100 +++ b/motion_control.cpp Sat Nov 07 13:24:46 2015 +0100 @@ -136,11 +136,11 @@ if (arc_target[Y_AXIS] > max_length[Y_AXIS]) arc_target[Y_AXIS] = max_length[Y_AXIS]; if (arc_target[Z_AXIS] > max_length[Z_AXIS]) arc_target[Z_AXIS] = max_length[Z_AXIS]; } - plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], arc_target[E_AXIS], feed_rate, extruder); + plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], arc_target[E_AXIS], feed_rate, extruder, false); } // Ensure last segment arrives at target location. - plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feed_rate, extruder); + plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feed_rate, extruder, false); // plan_set_acceleration_manager_enabled(acceleration_manager_was_enabled); } diff -r 2c8ba1964db7 -r b584642d4f58 planner.cpp --- a/planner.cpp Sat Nov 07 13:23:07 2015 +0100 +++ b/planner.cpp Sat Nov 07 13:24:46 2015 +0100 @@ -458,7 +458,7 @@ // Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in // mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration // calculation the caller must also provide the physical length of the line in millimeters. -void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder) +void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder, bool laser_on) { // Calculate the buffer head after we push this byte int next_buffer_head = next_block_index(block_buffer_head); @@ -503,6 +503,9 @@ // Mark block as not busy (Not executed by the stepper interrupt) block->busy = false; + // set the laser output status + block->laser_on = laser_on; + // Number of steps for each axis block->steps_x = labs(target[X_AXIS]-position[X_AXIS]); block->steps_y = labs(target[Y_AXIS]-position[Y_AXIS]); diff -r 2c8ba1964db7 -r b584642d4f58 planner.h --- a/planner.h Sat Nov 07 13:23:07 2015 +0100 +++ b/planner.h Sat Nov 07 13:24:46 2015 +0100 @@ -61,6 +61,8 @@ unsigned long acceleration_st; // acceleration steps/sec^2 unsigned long fan_speed; volatile char busy; + + bool laser_on; } block_t; // Initialize the motion plan subsystem @@ -68,7 +70,7 @@ // Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in // millimaters. Feed rate specifies the speed of the motion. -void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder); +void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder, bool laser_on); // Set position. Used for G92 instructions. void plan_set_position(const float &x, const float &y, const float &z, const float &e); diff -r 2c8ba1964db7 -r b584642d4f58 stepper.cpp --- a/stepper.cpp Sat Nov 07 13:23:07 2015 +0100 +++ b/stepper.cpp Sat Nov 07 13:24:46 2015 +0100 @@ -291,6 +291,13 @@ current_block = plan_get_current_block(); if (current_block != NULL) { current_block->busy = true; + + if (current_block->laser_on) { + WRITE(M571_PIN, HIGH);// Fire the laser! + } else { + WRITE(M571_PIN, LOW);// Shutdown the laser! + } + trapezoid_generator_reset(); counter_x = -(current_block->step_event_count >> 1); counter_y = counter_x; diff -r 2c8ba1964db7 -r b584642d4f58 z_probe.cpp --- a/z_probe.cpp Sat Nov 07 13:23:07 2015 +0100 +++ b/z_probe.cpp Sat Nov 07 13:24:46 2015 +0100 @@ -48,7 +48,7 @@ //plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); destination[Z_AXIS] = 1.1 * max_length[Z_AXIS] * Z_HOME_DIR; feedrate = homing_feedrate[Z_AXIS]; - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder, false); st_synchronize(); //feedrate = 0.0; @@ -81,7 +81,7 @@ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], meas, current_position[E_AXIS]); destination[Z_AXIS] = Z_HOME_RETRACT_MM; feedrate = fast_home_feedrate[Z_AXIS]; - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder, false); st_synchronize(); //check z stop isn't still triggered