Commit 075af738 authored by MagoKimbra's avatar MagoKimbra

Same fix

parent ae00f247
......@@ -6786,29 +6786,29 @@ inline void gcode_T(uint8_t tmp_extruder) {
switch(target_extruder)
{
case 0:
WRITE_RELE(E0E2_CHOICE_PIN, 0);
WRITE_RELE(E1E3_CHOICE_PIN, 0);
WRITE_RELE(E0E2_CHOICE_PIN, LOW);
WRITE_RELE(E1E3_CHOICE_PIN, LOW);
active_driver = 0;
delay(500); // 500 microseconds delay for relay
enable_e0();
break;
case 1:
WRITE_RELE(E0E2_CHOICE_PIN, 0);
WRITE_RELE(E1E3_CHOICE_PIN, 0);
WRITE_RELE(E0E2_CHOICE_PIN, LOW);
WRITE_RELE(E1E3_CHOICE_PIN, LOW);
active_driver = 1;
delay(500); // 500 microseconds delay for relay
enable_e1();
break;
case 2:
WRITE_RELE(E0E2_CHOICE_PIN, 1);
WRITE_RELE(E1E3_CHOICE_PIN, 0);
WRITE_RELE(E0E2_CHOICE_PIN, HIGH);
WRITE_RELE(E1E3_CHOICE_PIN, LOW);
active_driver = 0;
delay(500); // 500 microseconds delay for relay
enable_e2();
break;
case 3:
WRITE_RELE(E0E2_CHOICE_PIN, 0);
WRITE_RELE(E1E3_CHOICE_PIN, 1);
WRITE_RELE(E0E2_CHOICE_PIN, LOW);
WRITE_RELE(E1E3_CHOICE_PIN, HIGH);
active_driver = 1;
delay(500); // 500 microseconds delay for relay
enable_e3();
......@@ -6820,33 +6820,33 @@ inline void gcode_T(uint8_t tmp_extruder) {
switch(target_extruder)
{
case 0:
WRITE_RELE(E0E1_CHOICE_PIN, 0);
WRITE_RELE(E0E2_CHOICE_PIN, 0);
WRITE_RELE(E0E3_CHOICE_PIN, 0);
WRITE_RELE(E0E1_CHOICE_PIN, LOW);
WRITE_RELE(E0E2_CHOICE_PIN, LOW);
WRITE_RELE(E0E3_CHOICE_PIN, LOW);
active_driver = 0;
delay(500); // 500 microseconds delay for relay
enable_e0();
break;
case 1:
WRITE_RELE(E0E1_CHOICE_PIN, 1);
WRITE_RELE(E0E2_CHOICE_PIN, 0);
WRITE_RELE(E0E3_CHOICE_PIN, 0);
WRITE_RELE(E0E1_CHOICE_PIN, HIGH);
WRITE_RELE(E0E2_CHOICE_PIN, LOW);
WRITE_RELE(E0E3_CHOICE_PIN, LOW);
active_driver = 0;
delay(500); // 500 microseconds delay for relay
enable_e0();
break;
case 2:
WRITE_RELE(E0E1_CHOICE_PIN, 1);
WRITE_RELE(E0E2_CHOICE_PIN, 1);
WRITE_RELE(E0E3_CHOICE_PIN, 0);
WRITE_RELE(E0E1_CHOICE_PIN, HIGH);
WRITE_RELE(E0E2_CHOICE_PIN, HIGH);
WRITE_RELE(E0E3_CHOICE_PIN, LOW);
active_driver = 0;
delay(500); // 500 microseconds delay for relay
enable_e0();
break;
case 3:
WRITE_RELE(E0E1_CHOICE_PIN, 1);
WRITE_RELE(E0E2_CHOICE_PIN, 1);
WRITE_RELE(E0E3_CHOICE_PIN, 1);
WRITE_RELE(E0E1_CHOICE_PIN, HIGH);
WRITE_RELE(E0E2_CHOICE_PIN, HIGH);
WRITE_RELE(E0E3_CHOICE_PIN, HIGH);
active_driver = 0;
delay(500); // 500 microseconds delay for relay
enable_e0();
......@@ -6858,22 +6858,22 @@ inline void gcode_T(uint8_t tmp_extruder) {
switch(target_extruder)
{
case 0:
WRITE_RELE(E0E2_CHOICE_PIN, 0);
WRITE_RELE(E0E2_CHOICE_PIN, LOW);
active_driver = 0;
delay(500); // 500 microseconds delay for relay
enable_e0();
break;
case 1:
WRITE_RELE(E0E2_CHOICE_PIN, 0);
WRITE_RELE(E0E2_CHOICE_PIN, LOW);
active_driver = 1;
delay(500); // 500 microseconds delay for relay
enable_e1();
break;
case 2:
WRITE_RELE(E0E2_CHOICE_PIN, 1);
WRITE_RELE(E0E2_CHOICE_PIN, HIGH);
active_driver = 0;
delay(500); // 500 microseconds delay for relay
enable_e2();
enable_e0();
break;
}
#elif (EXTRUDERS == 3) && HAS(E0E1) && HAS(E0E2) && (DRIVER_EXTRUDERS == 1)
......@@ -6882,22 +6882,22 @@ inline void gcode_T(uint8_t tmp_extruder) {
switch(target_extruder)
{
case 0:
WRITE_RELE(E0E1_CHOICE_PIN, 0);
WRITE_RELE(E0E2_CHOICE_PIN, 0);
WRITE_RELE(E0E1_CHOICE_PIN, LOW);
WRITE_RELE(E0E2_CHOICE_PIN, LOW);
active_driver = 0;
delay(500); // 500 microseconds delay for relay
enable_e0();
break;
case 1:
WRITE_RELE(E0E1_CHOICE_PIN, 1);
WRITE_RELE(E0E2_CHOICE_PIN, 0);
WRITE_RELE(E0E1_CHOICE_PIN, HIGH);
WRITE_RELE(E0E2_CHOICE_PIN, LOW);
active_driver = 0;
delay(500); // 500 microseconds delay for relay
enable_e0();
break;
case 2:
WRITE_RELE(E0E1_CHOICE_PIN, 1);
WRITE_RELE(E0E2_CHOICE_PIN, 1);
WRITE_RELE(E0E1_CHOICE_PIN, HIGH);
WRITE_RELE(E0E2_CHOICE_PIN, HIGH);
active_driver = 0;
delay(500); // 500 microseconds delay for relay
enable_e0();
......@@ -6909,13 +6909,13 @@ inline void gcode_T(uint8_t tmp_extruder) {
switch(target_extruder)
{
case 0:
WRITE_RELE(E0E1_CHOICE_PIN, 0);
WRITE_RELE(E0E1_CHOICE_PIN, LOW);
active_driver = 0;
delay(500); // 500 microseconds delay for relay
enable_e0();
break;
case 1:
WRITE_RELE(E0E1_CHOICE_PIN, 1);
WRITE_RELE(E0E1_CHOICE_PIN, HIGH);
active_driver = 0;
delay(500); // 500 microseconds delay for relay
enable_e0();
......
......@@ -672,8 +672,10 @@
#if ENABLED(MKR4)
#if ENABLED(INVERTED_RELE_PINS)
#define WRITE_RELE(pin, value) WRITE(pin, !value)
#define OUT_WRITE_RELE(pin, value) OUT_WRITE(pin, !value)
#else
#define WRITE_RELE(pin, value) WRITE(pin, value)
#define OUT_WRITE_RELE(pin, value) OUT_WRITE(pin, value)
#endif
#endif
......
......@@ -1248,7 +1248,7 @@
#define MAX6675_SS 66 // Do not use pin 49 as this is tied to the switch inside the SD card socket to detect if there is an SD card present
#endif
#endif // RAMPS_13_EEB
#endif // RAMPS_13_HHB
/****************************************************************************************/
......@@ -2533,7 +2533,6 @@
#define Z_MIN_PIN 38 // PC6
#define Z_MAX_PIN 39 // PC7
#define Z_MS1_PIN 44 // PC19
#define Z_PROBE_PIN 39 // PC7
// E0 AXIS
#define ORIG_E0_STEP_PIN 5 // PC25
......
......@@ -134,14 +134,14 @@ unsigned char g_uc_extruder_last_move[4] = {0,0,0,0};
FORCE_INLINE int8_t next_block_index(int8_t block_index) { return BLOCK_MOD(block_index + 1); }
FORCE_INLINE int8_t prev_block_index(int8_t block_index) { return BLOCK_MOD(block_index - 1); }
// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the
// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the
// given acceleration:
FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) {
if (acceleration == 0) return 0; // acceleration was 0, set acceleration distance to 0
return (target_rate * target_rate - initial_rate * initial_rate) / (acceleration * 2);
}
// This function gives you the point at which you must start braking (at the rate of -acceleration) if
// This function gives you the point at which you must start braking (at the rate of -acceleration) if
// you started at speed initial_rate and accelerated until this point and want to end at the final_rate after
// a total travel of distance. This can be used to compute the intersection point between acceleration and
// deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed)
......@@ -179,7 +179,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
}
#if ENABLED(ADVANCE)
volatile long initial_advance = block->advance * entry_factor * entry_factor;
volatile long initial_advance = block->advance * entry_factor * entry_factor;
volatile long final_advance = block->advance * exit_factor * exit_factor;
#endif // ADVANCE
......@@ -197,16 +197,16 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
#endif
}
CRITICAL_SECTION_END;
}
}
// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the
// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the
// acceleration within the allotted distance.
FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) {
return sqrt(target_velocity * target_velocity - 2 * acceleration * distance);
}
// "Junction jerk" in this context is the immediate change in speed at the junction of two blocks.
// This method will calculate the junction jerk as the euclidean distance between the nominal
// This method will calculate the junction jerk as the euclidean distance between the nominal
// velocities of the respective blocks.
//inline float junction_jerk(block_t *before, block_t *after) {
// return sqrt(
......@@ -229,7 +229,7 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n
if (!current->nominal_length_flag && current->max_entry_speed > next->entry_speed) {
current->entry_speed = min(current->max_entry_speed,
max_allowable_speed(-current->acceleration, next->entry_speed, current->millimeters));
}
}
else {
current->entry_speed = current->max_entry_speed;
}
......@@ -239,16 +239,16 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n
} // Skip last block. Already initialized and set for recalculation.
}
// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This
// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This
// implements the reverse pass.
void planner_reverse_pass() {
uint8_t block_index = block_buffer_head;
//Make a local copy of block_buffer_tail, because the interrupt can alter it
CRITICAL_SECTION_START;
unsigned char tail = block_buffer_tail;
CRITICAL_SECTION_END
if (BLOCK_MOD(block_buffer_head - tail + BLOCK_BUFFER_SIZE) > 3) { // moves queued
block_index = BLOCK_MOD(block_buffer_head - 3);
block_t *block[3] = { NULL, NULL, NULL };
......@@ -300,8 +300,8 @@ void planner_forward_pass() {
planner_forward_pass_kernel(block[1], block[2], NULL);
}
// Recalculates the trapezoid speed profiles for all blocks in the plan according to the
// entry_factor for each junction. Must be called by planner_recalculate() after
// Recalculates the trapezoid speed profiles for all blocks in the plan according to the
// entry_factor for each junction. Must be called by planner_recalculate() after
// updating the blocks.
void planner_recalculate_trapezoids() {
int8_t block_index = block_buffer_tail;
......@@ -332,22 +332,22 @@ void planner_recalculate_trapezoids() {
// Recalculates the motion plan according to the following algorithm:
//
// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor)
// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor)
// so that:
// a. The junction jerk is within the set limit
// b. No speed reduction within one block requires faster deceleration than the one, true constant
// b. No speed reduction within one block requires faster deceleration than the one, true constant
// acceleration.
// 2. Go over every block in chronological order and dial down junction speed reduction values if
// a. The speed increase within one block would require faster acceleration than the one, true
// 2. Go over every block in chronological order and dial down junction speed reduction values if
// a. The speed increase within one block would require faster acceleration than the one, true
// constant acceleration.
//
// When these stages are complete all blocks have an entry_factor that will allow all speed changes to
// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than
// When these stages are complete all blocks have an entry_factor that will allow all speed changes to
// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than
// the set limit. Finally it will:
//
// 3. Recalculate trapezoids for all blocks.
void planner_recalculate() {
void planner_recalculate() {
planner_reverse_pass();
planner_forward_pass();
planner_recalculate_trapezoids();
......@@ -356,7 +356,7 @@ void planner_recalculate() {
void plan_init() {
block_buffer_head = block_buffer_tail = 0;
memset(position, 0, sizeof(position)); // clear position
for (int i=0; i<NUM_AXIS; i++) previous_speed[i] = 0.0;
for (int i=0; i<NUM_AXIS; i++) previous_speed[i] = 0.0;
previous_nominal_speed = 0.0;
}
......@@ -480,7 +480,7 @@ void check_axes_activity() {
float junction_deviation = 0.1;
// Add a new linear movement to the buffer. steps[X_AXIS], _y and _z is the absolute position in
// Add a new linear movement to the buffer. steps[X_AXIS], _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.
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
......@@ -492,7 +492,7 @@ float junction_deviation = 0.1;
// Calculate the buffer head after we push this byte
int next_buffer_head = next_block_index(block_buffer_head);
// If the buffer is full: good! That means we are well ahead of the robot.
// If the buffer is full: good! That means we are well ahead of the robot.
// Rest here until there is room in the buffer.
while (block_buffer_tail == next_buffer_head) idle();
......@@ -743,13 +743,13 @@ float junction_deviation = 0.1;
NOLESS(feed_rate, mintravelfeedrate);
/**
* This part of the code calculates the total length of the movement.
* This part of the code calculates the total length of the movement.
* For cartesian bots, the X_AXIS is the real X movement and same for Y_AXIS.
* But for corexy bots, that is not true. The "X_AXIS" and "Y_AXIS" motors (that should be named to A_AXIS
* and B_AXIS) cannot be used for X and Y length, because A=X+Y and B=X-Y.
* So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head.
* So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head.
* Having the real displacement of the head, we can calculate the total movement length and apply the desired speed.
*/
*/
#if MECH(COREXY)
float delta_mm[6];
delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
......@@ -786,7 +786,7 @@ float junction_deviation = 0.1;
#endif
);
}
float inverse_millimeters = 1.0 / block->millimeters; // Inverse millimeters to remove multiple divides
float inverse_millimeters = 1.0 / block->millimeters; // Inverse millimeters to remove multiple divides
// Calculate speed in mm/second for each axis. No divide by zero due to previous checks.
float inverse_second = feed_rate * inverse_millimeters;
......@@ -854,13 +854,12 @@ float junction_deviation = 0.1;
// Max segement time in us.
#if ENABLED(XY_FREQUENCY_LIMIT)
#define MAX_FREQ_TIME (1000000.0 / XY_FREQUENCY_LIMIT)
// Check and limit the xy direction change frequency
unsigned char direction_change = block->direction_bits ^ old_direction_bits;
old_direction_bits = block->direction_bits;
segment_time = lround((float)segment_time / speed_factor);
long xs0 = axis_segment_time[X_AXIS][0],
xs1 = axis_segment_time[X_AXIS][1],
xs2 = axis_segment_time[X_AXIS][2],
......@@ -891,7 +890,7 @@ float junction_deviation = 0.1;
}
#endif // XY_FREQUENCY_LIMIT
// Correct the speed
// Correct the speed
if (speed_factor < 1.0) {
for (unsigned char i = 0; i < NUM_AXIS; i++) current_speed[i] *= speed_factor;
block->nominal_speed *= speed_factor;
......@@ -920,7 +919,7 @@ float junction_deviation = 0.1;
if ((float)acc_st * bsy / block->step_event_count > ysteps) acc_st = ysteps;
if ((float)acc_st * bsz / block->step_event_count > zsteps) acc_st = zsteps;
if ((float)acc_st * bse / block->step_event_count > esteps) acc_st = esteps;
block->acceleration_st = acc_st;
block->acceleration = acc_st / steps_per_mm;
......@@ -973,7 +972,7 @@ float junction_deviation = 0.1;
// Start with a safe speed
float vmax_junction = max_xy_jerk / 2;
float vmax_junction_factor = 1.0;
float vmax_junction_factor = 1.0;
float mz2 = max_z_jerk / 2, me2 = max_e_jerk[extruder] / 2;
float csz = current_speed[Z_AXIS], cse = current_speed[E_AXIS];
if (fabs(csz) > mz2) vmax_junction = min(vmax_junction, mz2);
......
......@@ -940,20 +940,16 @@ void st_init() {
//Choice E0-E1 or E0-E2 or E1-E3 pin
#if ENABLED(MKR4) && HAS(E0E1)
SET_OUTPUT(E0E1_CHOICE_PIN);
WRITE_RELE(E0E1_CHOICE_PIN, 0);
OUT_WRITE_RELE(E0E1_CHOICE_PIN, LOW);
#endif
#if ENABLED(MKR4) && HAS(E0E2)
SET_OUTPUT(E0E2_CHOICE_PIN);
WRITE_RELE(E0E2_CHOICE_PIN, 0);
OUT_WRITE_RELE(E0E2_CHOICE_PIN, LOW);
#endif
#if ENABLED(MKR4) && HAS(E0E3)
SET_OUTPUT(E0E3_CHOICE_PIN);
WRITE_RELE(E0E3_CHOICE_PIN, 0);
OUT_WRITE_RELE(E0E3_CHOICE_PIN, LOW);
#endif
#if ENABLED(MKR4) && HAS(E1E3)
SET_OUTPUT(E1E3_CHOICE_PIN);
WRITE_RELE(E1E3_CHOICE_PIN, 0);
OUT_WRITE_RELE(E1E3_CHOICE_PIN, LOW);
#endif
//endstops and pullups
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment