CoreXY: separate out bot axes distance calculations.

This also introduces dda_kinematics.c/.h and a KINEMATICS definition,
which allows to do different distance calculations depending on the
bot kinematics in use. So far only KINEMATICS_STRAIGHT, which matches
what we had before, but other kinematics types are present in
comments already.
This commit is contained in:
Markus Hitter 2014-10-16 21:37:22 +02:00
parent 7d2dbaa481
commit 30dd1f4535
4 changed files with 77 additions and 4 deletions

View File

@ -44,6 +44,19 @@
#define MOTHERBOARD
/** \def KINEMATICS
This defines the type of kinematics your printer uses. That's essential!
Valid values (see dda_kinematics.h):
KINEMATICS_STRAIGHT Motors move axis directions directly. This is the
traditional type, found in many printers, including
Mendel, Prusa i3, Mendel90, Ormerod, Mantis.
*/
#define KINEMATICS KINEMATICS_STRAIGHT
/** \def STEPS_PER_M
steps per meter ( = steps per mm * 1000 )

7
dda.c
View File

@ -13,6 +13,7 @@
#include "dda_maths.h"
#include "preprocessor_math.h"
#include "dda_kinematics.h"
#include "dda_lookahead.h"
#include "timer.h"
#include "serial.h"
@ -191,12 +192,10 @@ void dda_create(DDA *dda, TARGET *target) {
dda->id = idcnt++;
#endif
code_axes_to_stepper_axes(&startpoint, target, delta_um, steps);
for (i = X; i < E; i++) {
int32_t delta_steps;
delta_um[i] = (uint32_t)abs32(target->axis[i] - startpoint.axis[i]);
steps[i] = um_to_steps(target->axis[i], i);
delta_steps = steps[i] - startpoint_steps.axis[i];
dda->delta[i] = (uint32_t)abs32(delta_steps);
startpoint_steps.axis[i] = steps[i];
@ -217,8 +216,8 @@ void dda_create(DDA *dda, TARGET *target) {
int32_t delta_steps;
delta_um[E] = (uint32_t)abs32(target->axis[E] - startpoint.axis[E]);
steps[E] = um_to_steps(target->axis[E], E);
delta_steps = steps[E] - startpoint_steps.axis[E];
dda->delta[E] = (uint32_t)abs32(delta_steps);
startpoint_steps.axis[E] = steps[E];

20
dda_kinematics.c Normal file
View File

@ -0,0 +1,20 @@
#include "dda_kinematics.h"
/** \file G-code axis system to stepper motor axis system conversion.
*/
#include <stdlib.h>
#include "dda_maths.h"
void
carthesian_to_carthesian(TARGET *startpoint, TARGET *target,
axes_uint32_t delta_um, axes_int32_t steps) {
enum axis_e i;
for (i = X; i < E; i++) {
delta_um[i] = (uint32_t)labs(target->axis[i] - startpoint->axis[i]);
steps[i] = um_to_steps(target->axis[i], i);
}
}

41
dda_kinematics.h Normal file
View File

@ -0,0 +1,41 @@
#ifndef _DDA_KINEMATICS_H
#define _DDA_KINEMATICS_H
#include <stdint.h>
#include "dda.h"
#define KINEMATICS_STRAIGHT 1
//#define KINEMATICS_COREXY 2
//#define KINEMATICS_SCARA 3
#include "config_wrapper.h"
void carthesian_to_carthesian(TARGET *startpoint, TARGET *target,
axes_uint32_t delta_um, axes_int32_t steps);
//void carthesian_to_corexy(TARGET *startpoint, TARGET *target,
// axes_uint32_t delta_um, axes_int32_t steps);
//void carthesian_to_scara(TARGET *startpoint, TARGET *target,
// axes_uint32_t delta_um, axes_int32_t steps);
static void code_axes_to_stepper_axes(TARGET *, TARGET *, axes_uint32_t,
axes_int32_t)
__attribute__ ((always_inline));
inline void code_axes_to_stepper_axes(TARGET *startpoint, TARGET *target,
axes_uint32_t delta_um,
axes_int32_t steps) {
#if KINEMATICS == KINEMATICS_STRAIGHT
carthesian_to_carthesian(startpoint, target, delta_um, steps);
// #elif KINEMATICS == KINEMATICS_COREXY
// carthesian_to_corexy(startpoint, target, delta_um, steps);
// #elif KINEMATICS == KINEMATICS_SCARA
// return carthesian_to_scara(startpoint, target, delta_um, steps);
#else
#error KINEMATICS not defined or unknown, edit your config.h.
#endif
}
#endif /* _DDA_KINEMATICS_H */