Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default microsteps to axis first stepper #21230

Conversation

xorza
Copy link
Contributor

@xorza xorza commented Feb 28, 2021

Description

In cases when you swap motors on your printer, adjust micro-steps count or change belt gears you need to go and calculate correct value for DEFAULT_AXIS_STEPS_PER_UNIT, which isnt very obvious and seems to have magic numbers at first glance. Also name DEFAULT_AXIS_STEPS_PER_UNIT is misleading because it actually needs MICROSTEPS count and not steps.

In this PR I propose:

  1. rename DEFAULT_AXIS_STEPS_PER_UNIT -> DEFAULT_AXIS_MICROSTEPS_PER_UNIT
  2. make DEFAULT_AXIS_MICROSTEPS_PER_UNIT auto calculated based on three physical properties of your machine, such as: microsteps number, degrees per step and degrees per unit.

This way, for example, if you swapped the motor for more precise 0.9 degree one, but didnt change any dimensions of the system and want leave same microsteppings settings, you can only change <MOTOR_ID>_DEGREES_PER_STEP value and not worry about anything else, because you know that you changed only one of system properties. Same way you only need to change <MOTOR_ID>_DEGREES_PER_UNIT if you only changed belt bearing.

Requirements

Tested on I3 system with SKR1.4 and TMC2209

Benefits

Now config better reflects physical properties of your machine and makes tweaking it easier

Configurations

Default one is fine, also TMC-related config was altered

Potential Issues

I dont have any non-UART drivers and cannot test if such config would work for simple cheap drivers

@xorza xorza changed the title STEPS_PER_UNIT config changes to refletc physical properties of the machine better STEPS_PER_UNIT config changes to better reflect physical properties of the machine Feb 28, 2021
@ellensp
Copy link
Contributor

ellensp commented Feb 28, 2021

I really don't like this.
There is no such thing as sending microsteps, there are only steps, which you works out from hardware including the micro stepping settings

@xorza
Copy link
Contributor Author

xorza commented Feb 28, 2021

@ellensp exactly my thoughts, but currently DEFAULT_AXIS_STEPS_PER_UNIT actually has value specified in microsteps. So if I change X_MICROSTEPS form 16 to 8 I also have to go to and reduce X value in DEFAULT_AXIS_STEPS_PER_UNIT.

I can try and go the other way - to change DEFAULT_AXIS_STEPS_PER_UNIT be independent from microsteps count.
Default config would change to
#define DEFAULT_AXIS_STEPS_PER_UNIT { 5, 5, 25, 31.25 }
(existing { 80, 80, 400, 500 } divided by 16 microsteps basically)

Wyt?

@thinkyhead thinkyhead added C: Configuration T: Design Concept Technical ideas about ways and methods. T: Suggestion labels Feb 28, 2021
@thinkyhead
Copy link
Member

As for configuration, well of course users are free to invent their own methodologies. For example, my first printer has all the extra stuff shown below in it so that I don't have to work too hard.

One idea that makes sense is to modify the stored steps-per-unit value if you send a G-code that modifies the micro-steps of an axis stepper. Of course you could only do that in the middle of a print job if the G-code itself is aware of those details, and of course only a small minority of machines allows microsteps to be set by software.

//
// Example: Standard NEMA 17 with T2 belt and 20 tooth pulley
//
#define NEMA17_FULL_STEPS 200.0
#define NEMA17_MICROSTEPS 16.0
#define PULLEY_PITCH 2.0
#define PULLEY_TEETH 20.0
#define Z_ROD_PITCH 0.8

#define WADE_PULLEY_TEETH 11.0
#define WADE_GEAR_TEETH 45.0
#define HOBBED_BOLT_DIAM 6.0

#define NEMA17_MOTOR_STEPS (NEMA17_FULL_STEPS * NEMA17_MICROSTEPS)
#define WADE_GEAR_RATIO (WADE_GEAR_TEETH / WADE_PULLEY_TEETH)
#define HOBBED_BOLD_CIRC (M_PI * HOBBED_BOLT_DIAM)
#define WADE_E_STEPS (NEMA17_MOTOR_STEPS * WADE_GEAR_RATIO / HOBBED_BOLD_CIRC)
// (200 * 16) * (45.0 / 11.0) / (pi * 6.0) = 694.49429712

//
// Example: Calculate 2engineers.com 1:50 Geared Motor "Direct Drive"
//
#define ENG2_FULL_STEPS 48.0
#define ENG2_MICROSTEPS 16.0
#define ENG2_GEAR_RATIO 50.0
#define ENG2_PULLEY_DIAM 10.56

#define ENG2_MOTOR_STEPS (ENG2_FULL_STEPS * ENG2_MICROSTEPS)
#define ENG2_GEAR_CIRC (M_PI * ENG2_PULLEY_DIAM)
#define ENG2_CORRECTION (20 / 18.4)
#define ENG2_E_STEPS (ENG2_MOTOR_STEPS * ENG2_GEAR_RATIO / ENG2_GEAR_CIRC) * ENG2_CORRECTION
// (48 * 16 * 50) / (pi * 10.56) = 1157.4904952 * (20/18.4) = 1258.1418426

//
// Example: Ultimaker defaults based on MXL belt, then calibrated
//
#define UM_PULLEY_PITCH 2.032
#define UM_PULLEY_TEETH 20.0

// Get steps/mm from selected results above
#define XY_STEPS (NEMA17_MOTOR_STEPS / (PULLEY_PITCH * PULLEY_TEETH))
#define Z_STEPS (NEMA17_MOTOR_STEPS / Z_ROD_PITCH)

/**
#define XY_BELT_PITCH 2
#define XY_GEAR_TEETH 20

#define Z_ROD_PITCH 0.8

// NEMA17 with 16 microsteps
#define STEPS_NEMA17 200
#define MICROS_NEMA17 16

// PG with 50:1 ratio, 16 microsteps
#define STEPS_PG50 48
#define MICROS_PG50 16

// A typical Wade's Extruder. Gregstruder: 51/11 or 43/10
#define LG_GEAR_WADE 39
#define SM_GEAR_WADE 11

// Diameter of the drive wheel or hobbed bolt
#define DRIVE_DIAM_WADE 7
#define DRIVE_DIAM_MK7 10.56

// calculated step unit values
#define STEPS_PER_TURN_NEMA17 (STEPS_NEMA17 * MICROS_NEMA17)
#define STEPS_PER_TURN_PG50 (STEPS_PG50 * MICROS_PG50)
#define GEAR_RATIO_WADE (LG_GEAR_WADE/SM_GEAR_WADE)
#define GEAR_RATIO_PG50 (50/1)
#define DRIVE_CIRC_WADE (DRIVE_DIAM_WADE * M_PI)
#define DRIVE_CIRC_MK7 (DRIVE_DIAM_MK7 * M_PI)

// Some extruder steps-per-mm examples:

// Classic Wade
#define STEPS_PER_MM_WADE_39_11 (STEPS_PER_TURN_NEMA17 * GEAR_RATIO_WADE / DRIVE_CIRC_WADE) // = 515.91048

// MK7 Direct Drive with 50:1 PG motor
#define STEPS_PER_MM_MK7_50_1 (STEPS_PER_TURN_PG50 * GEAR_RATIO_PG50 / DRIVE_CIRC_MK7) // = 1157.49147

#define DEFAULT_AXIS_STEPS_PER_UNIT   {78.7402,78.7402,200.0*8/3,STEPS_PER_MM_MK7_50_1}  // Default for Prusa i3 with GT2 belts
*/

/**
 * With this option each E stepper can have its own factors for the
 * following movement settings. If fewer factors are given than the
 * total number of extruders, the last value applies to the rest.
 */
//#define DISTINCT_E_FACTORS

/**
 * Default Axis Steps Per Unit (steps/mm)
 * Override with M92
 *                                      X, Y, Z, E0 [, E1[, E2...]]
 */
//#define DEFAULT_AXIS_STEPS_PER_UNIT   { XY_STEPS, XY_STEPS, Z_STEPS, ENG2_E_STEPS }  // White Fishbone: 39/12? 556.857 ; Black Fishbone: 694.494
#define DEFAULT_AXIS_STEPS_PER_UNIT   { XY_STEPS, XY_STEPS, Z_STEPS, WADE_E_STEPS }  // White Fishbone: 39/12? 556.857 ; Black Fishbone: 694.494

@thinkyhead thinkyhead changed the title STEPS_PER_UNIT config changes to better reflect physical properties of the machine Default microsteps to axis first stepper Mar 1, 2021
@thinkyhead
Copy link
Member

I can get behind the inheritance of micro-steps for the smart stepper drivers, so I will propagate that to Configurations and merge what is now left after that.

@thinkyhead thinkyhead marked this pull request as ready for review March 1, 2021 07:04
thinkyhead added a commit to MarlinFirmware/Configurations that referenced this pull request Mar 1, 2021
@thinkyhead thinkyhead merged commit 2b9842e into MarlinFirmware:bugfix-2.0.x Mar 1, 2021
@ellensp
Copy link
Contributor

ellensp commented Mar 1, 2021

@thinkyhead

with committed changes is there a reason why the following are unchanged?
#if AXIS_IS_L64XX(Y)
#define Y_MICROSTEPS 128
...
#if AXIS_IS_L64XX(Z)
#define Z_MICROSTEPS 128
...
#if AXIS_IS_L64XX(E0)
#define E0_MICROSTEPS 128

@xorza xorza deleted the microstepping_improvementupstream branch March 5, 2021 02:20
vyacheslav-shubin pushed a commit to vyacheslav-shubin/Marlin that referenced this pull request Mar 10, 2021
vyacheslav-shubin pushed a commit to vyacheslav-shubin/Marlin that referenced this pull request Mar 10, 2021
W4tel-BiDi pushed a commit to W4tel-BiDi/Marlin that referenced this pull request Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Configuration T: Design Concept Technical ideas about ways and methods. T: Suggestion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants