This repository has been archived by the owner on Aug 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
126 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,9 @@ static const axes_uint32_t PROGMEM steps_per_m_P = { | |
STEPS_PER_M_E | ||
}; | ||
|
||
axes_int32_t BSS debug_axis; | ||
TARGET BSS debug_position; | ||
|
||
/// \var maximum_feedrate_P | ||
/// \brief maximum allowed feedrate on each axis | ||
static const axes_uint32_t PROGMEM maximum_feedrate_P = { | ||
|
@@ -309,7 +312,7 @@ void dda_create(DDA *dda, const TARGET *target) { | |
else | ||
distance = approx_distance_3(delta_um[X], delta_um[Y], delta_um[Z]); | ||
|
||
if (distance < 2) | ||
if (distance < 1) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Wurstnase
Author
Collaborator
|
||
distance = delta_um[E]; | ||
|
||
if (DEBUG_DDA && (debug_flags & DEBUG_DDA)) | ||
|
@@ -574,40 +577,44 @@ void dda_start(DDA *dda) { | |
*/ | ||
void dda_step(DDA *dda) { | ||
|
||
#if ! defined ACCELERATION_TEMPORAL | ||
#if ! defined ACCELERATION_TEMPORAL | ||
if (move_state.steps[X]) { | ||
move_state.counter[X] -= dda->delta[X]; | ||
if (move_state.counter[X] < 0) { | ||
x_step(); | ||
x_step(); | ||
move_state.steps[X]--; | ||
move_state.counter[X] += dda->total_steps; | ||
} | ||
debug_axis[X] += get_direction(dda, X); | ||
} | ||
} | ||
if (move_state.steps[Y]) { | ||
move_state.counter[Y] -= dda->delta[Y]; | ||
if (move_state.counter[Y] < 0) { | ||
y_step(); | ||
y_step(); | ||
move_state.steps[Y]--; | ||
move_state.counter[Y] += dda->total_steps; | ||
} | ||
debug_axis[Y] += get_direction(dda, Y); | ||
} | ||
} | ||
if (move_state.steps[Z]) { | ||
move_state.counter[Z] -= dda->delta[Z]; | ||
if (move_state.counter[Z] < 0) { | ||
z_step(); | ||
z_step(); | ||
move_state.steps[Z]--; | ||
move_state.counter[Z] += dda->total_steps; | ||
} | ||
debug_axis[Z] += get_direction(dda, Z); | ||
} | ||
} | ||
if (move_state.steps[E]) { | ||
move_state.counter[E] -= dda->delta[E]; | ||
if (move_state.counter[E] < 0) { | ||
e_step(); | ||
e_step(); | ||
move_state.steps[E]--; | ||
move_state.counter[E] += dda->total_steps; | ||
} | ||
debug_axis[E] += get_direction(dda, E); | ||
} | ||
} | ||
#endif | ||
#endif | ||
|
||
#ifdef ACCELERATION_REPRAP | ||
// linear acceleration magic, courtesy of http://www.embedded.com/design/mcus-processors-and-socs/4006438/Generate-stepper-motor-speed-profiles-in-real-time | ||
|
@@ -970,6 +977,7 @@ void update_current_position() { | |
if (queue_empty()) { | ||
for (i = X; i < AXIS_COUNT; i++) { | ||
current_position.axis[i] = startpoint.axis[i]; | ||
debug_position.axis[i] = muldiv(debug_axis[i], 1000000, pgm_read_dword(&steps_per_m_P[i])); | ||
} | ||
} | ||
else if (dda->live) { | ||
|
@@ -981,6 +989,7 @@ void update_current_position() { | |
// Unfortunately, using muldiv() overwhelms the compiler. | ||
// Also keep the parens around this term, else results go wrong. | ||
((move_state.steps[i] * 1000) / pgm_read_dword(&steps_per_mm_P[i])); | ||
debug_position.axis[i] = muldiv(debug_axis[i], 1000000, pgm_read_dword(&steps_per_m_P[i])); | ||
} | ||
|
||
if (dda->endpoint.e_relative) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
if [ $1 ] | ||
then | ||
drwnumber="$1" | ||
else | ||
drwnumber="000" | ||
fi | ||
|
||
echo "${drwnumber}" | ||
|
||
if [ -z "$2" ] | ||
then | ||
test_it=false | ||
else | ||
test_it=true | ||
fi | ||
|
||
if $test_it | ||
then | ||
make -f Makefile-SIM clean | ||
make -f Makefile-SIM | ||
./sim -t0 -g testcases/swan4.gcode -o | ||
fi | ||
|
||
grep '#' datalog.out > datalog.out2 | ||
grep '[^[:blank:]]' datalog.out2 > datalog.out3 | ||
|
||
grep '# X:' datalog.out3 > datalog.out4 | ||
|
||
python3 parse_datalog.py 'datalog.out4' 'swan.log' | ||
|
||
gnuplot <<__EOF | ||
set term png size 1024,768 | ||
set output "swan-diff-${drwnumber}.png" | ||
plot 'swan.log' u 1:4 with lines | ||
set yrange [80:120] | ||
set output "swan-reference-${drwnumber}.png" | ||
plot 'swan.log' u 1:2 with lines | ||
set output "swan-current-${drwnumber}.png" | ||
plot 'swan.log' u 1:3 with lines | ||
__EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import sys | ||
|
||
in_file = sys.argv[1] | ||
out_file = sys.argv[2] | ||
|
||
diff_list = list() | ||
diff_list.clear() | ||
|
||
with open(in_file, 'r') as file: | ||
data = file.readlines() | ||
|
||
def get_line(text): | ||
temp = text | ||
temp = temp[temp.find('X:')+2:] | ||
X = temp[:temp.find(',')] | ||
temp = temp[temp.find('Y:')+2:] | ||
Y = temp[:temp.find(',')] | ||
temp = temp[temp.find('Z:')+2:] | ||
Z = temp[:temp.find(',')] | ||
temp = temp[temp.find('E:')+2:] | ||
E = temp[:temp.find(',')] | ||
X = float(X) | ||
Y = float(Y) | ||
Z = float(Z) | ||
E = float(E) | ||
return X, Y, Z, E | ||
|
||
|
||
for i, line in enumerate(data): | ||
if not (i % 2): | ||
x1, y1, z1, e1 = get_line(line) | ||
else: | ||
x2, y2, z2, e2 = get_line(line) | ||
x = x2 - x1 | ||
y = y2 - y1 | ||
z = z2 - z1 | ||
e = e2 - e1 | ||
# diff_list.append('- X:{}\t\t\t,Y:{}\t\t\t,Z:{}\n'.format(x1, y1, z1)) | ||
# diff_list.append('# X:{}\t\t\t,Y:{}\t\t\t,Z:{}\n'.format(x, y, z)) | ||
diff_list.append('{}\t\t\t{}\t\t\t{}\t\t\t{}\n'.format(i//2, x1, x2, x)) | ||
# try: | ||
# x3 = x/x2 | ||
# except ZeroDivisionError: | ||
# x3 = 0 | ||
# try: | ||
# y3 = x/y2 | ||
# except ZeroDivisionError: | ||
# y3 = 0 | ||
# try: | ||
# z3 = z/z2 | ||
# except ZeroDivisionError: | ||
# z3 = 0 | ||
|
||
# diff_list.append('# X:{}\t,Y:{}\t,Z:{}\n'.format(x3, y3, z3)) | ||
|
||
|
||
with open(out_file, 'w') as file: | ||
file.writelines(diff_list) |
This is the same as
if (distance == 0)
sincedistance
is unsigned int. I assume this is the change that fixed aDIV0
error you saw. But the original code is mysterious to me. It has never been clear why we would switch to E-axis only when our head moves less than 2um. I assume this is only needed to allow us to extrude without movement, but it seems suspicious to me that we treat E special. Isn't it reasonable for E to be treated like any other moving axis?I'm not blaming you for this code, but I am wondering if you have any insight about this.