From 280edf6dbc87135d554ba37cb8c5248f17cc0b71 Mon Sep 17 00:00:00 2001 From: wurstnase Date: Fri, 24 Jun 2016 20:04:24 +0200 Subject: [PATCH] dda_kinematics.c: note about unrolling loops. Note a performance improvement opportunity. Review note by Traumflug: the original commit didn't add a comment, but replaced the existing code with what's in the comment now. According to the comment in issue #223: Pre-unroll: LED on time minimum: 3138.44 clock cycles. LED on time maximum: 5108.8 clock cycles. LED on time average: 4590.58 clock cycles. Unrolled: LED on time minimum: 3016.92 clock cycles. LED on time maximum: 4987.28 clock cycles. LED on time average: 4469.06 clock cycles. --- dda_kinematics.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dda_kinematics.c b/dda_kinematics.c index a8ecc81..6634df5 100644 --- a/dda_kinematics.c +++ b/dda_kinematics.c @@ -17,6 +17,17 @@ carthesian_to_carthesian(TARGET *startpoint, TARGET *target, delta_um[i] = (uint32_t)labs(target->axis[i] - startpoint->axis[i]); steps[i] = um_to_steps(target->axis[i], i); } + + /* Replacing the above five lines with this costs about 200 bytes binary + size on AVR, but also takes about 120 clock cycles less during movement + preparation. The smaller version was kept for our Arduino Nano friends. + delta_um[X] = (uint32_t)labs(target->axis[X] - startpoint->axis[X]); + steps[X] = um_to_steps(target->axis[X], X); + delta_um[Y] = (uint32_t)labs(target->axis[Y] - startpoint->axis[Y]); + steps[Y] = um_to_steps(target->axis[Y], Y); + delta_um[Z] = (uint32_t)labs(target->axis[Z] - startpoint->axis[Z]); + steps[Z] = um_to_steps(target->axis[Z], Z); + */ } void