diff --git a/config.h.dist b/config.h.dist index b0c33f7..484ec60 100644 --- a/config.h.dist +++ b/config.h.dist @@ -3,19 +3,19 @@ /* Values reflecting the gearing of your machine. - All numbers are integers, so no decimals, please :-) + All numbers are fixed point integers, so no more than 3 digits to the right of the decimal point, please :-) */ // calculate these values appropriate for your machine // for threaded rods, this is (steps motor per turn) / (pitch of the thread) // for belts, this is (steps per motor turn) / (number of gear teeth) / (belt module) // half-stepping doubles the number, quarter stepping requires * 4, etc. -#define STEPS_PER_MM_X 320 -#define STEPS_PER_MM_Y 320 -#define STEPS_PER_MM_Z 320 +#define STEPS_PER_MM_X 320.000 +#define STEPS_PER_MM_Y 320.000 +#define STEPS_PER_MM_Z 320.000 // http://blog.arcol.hu/?p=157 may help with this next one -#define STEPS_PER_MM_E 320 +#define STEPS_PER_MM_E 320.000 /* Values depending on the capabilities of your stepper motors and other mechanics. diff --git a/gcode.c b/gcode.c index 9b47164..42c16c4 100644 --- a/gcode.c +++ b/gcode.c @@ -15,9 +15,29 @@ #include "heater.h" #include "sersendf.h" +/* + Switch user friendly values to coding friendly values + + This also affects the possible build volume. We have +-2^31 numbers available and as we internally measure position in steps and use a precision factor of 1000, this translates into a possible range of + + 2^31 mm / STEPS_PER_MM_x / 1000 + + for each axis. For a M6 threaded rod driven machine and 1/16 microstepping this evaluates to + + 2^31 mm / 200 / 1 / 16 / 1000 = 671 mm, + + which is about the worst case we have. All other machines have a bigger build volume. +*/ + +#define STEPS_PER_M_X ((uint32_t) (STEPS_PER_MM_X * 1000.0)) +#define STEPS_PER_M_Y ((uint32_t) (STEPS_PER_MM_Y * 1000.0)) +#define STEPS_PER_M_Z ((uint32_t) (STEPS_PER_MM_Z * 1000.0)) +#define STEPS_PER_M_E ((uint32_t) (STEPS_PER_MM_E * 1000.0)) + /* mm -> inch conversion */ + #define STEPS_PER_IN_X ((uint32_t) ((25.4 * STEPS_PER_MM_X) + 0.5)) #define STEPS_PER_IN_Y ((uint32_t) ((25.4 * STEPS_PER_MM_Y) + 0.5)) #define STEPS_PER_IN_Z ((uint32_t) ((25.4 * STEPS_PER_MM_Z) + 0.5)) @@ -133,7 +153,7 @@ void scan_char(uint8_t c) { if (next_target.option_inches) next_target.target.X = decfloat_to_int(&read_digit, STEPS_PER_IN_X, 1); else - next_target.target.X = decfloat_to_int(&read_digit, STEPS_PER_MM_X, 1); + next_target.target.X = decfloat_to_int(&read_digit, STEPS_PER_M_X, 1000); if (debug_flags & DEBUG_ECHO) serwrite_int32(next_target.target.X); break; @@ -141,7 +161,7 @@ void scan_char(uint8_t c) { if (next_target.option_inches) next_target.target.Y = decfloat_to_int(&read_digit, STEPS_PER_IN_Y, 1); else - next_target.target.Y = decfloat_to_int(&read_digit, STEPS_PER_MM_Y, 1); + next_target.target.Y = decfloat_to_int(&read_digit, STEPS_PER_M_Y, 1000); if (debug_flags & DEBUG_ECHO) serwrite_int32(next_target.target.Y); break; @@ -149,7 +169,7 @@ void scan_char(uint8_t c) { if (next_target.option_inches) next_target.target.Z = decfloat_to_int(&read_digit, STEPS_PER_IN_Z, 1); else - next_target.target.Z = decfloat_to_int(&read_digit, STEPS_PER_MM_Z, 1); + next_target.target.Z = decfloat_to_int(&read_digit, STEPS_PER_M_Z, 1000); if (debug_flags & DEBUG_ECHO) serwrite_int32(next_target.target.Z); break; @@ -157,7 +177,7 @@ void scan_char(uint8_t c) { if (next_target.option_inches) next_target.target.E = decfloat_to_int(&read_digit, STEPS_PER_IN_E, 1); else - next_target.target.E = decfloat_to_int(&read_digit, STEPS_PER_MM_E, 1); + next_target.target.E = decfloat_to_int(&read_digit, STEPS_PER_M_E, 1000); if (debug_flags & DEBUG_ECHO) serwrite_uint32(next_target.target.E); break;