Improve LV8729 stepping (#13776)
This commit is contained in:
		| @@ -1209,7 +1209,8 @@ | ||||
| /** | ||||
|  * Minimum stepper driver pulse width (in µs) | ||||
|  *   0 : Smallest possible width the MCU can produce, compatible with TMC2xxx drivers | ||||
|  *   1 : Minimum for A4988, A5984, and LV8729 stepper drivers | ||||
|  *   0 : Minimum 500ns for LV8729, adjusted in stepper.h | ||||
|  *   1 : Minimum for A4988 and A5984 stepper drivers | ||||
|  *   2 : Minimum for DRV8825 stepper drivers | ||||
|  *   3 : Minimum for TB6600 stepper drivers | ||||
|  *  30 : Minimum for TB6560 stepper drivers | ||||
| @@ -1224,8 +1225,8 @@ | ||||
|  *  500000 : Maximum for A4988 stepper driver | ||||
|  *  400000 : Maximum for TMC2xxx stepper drivers | ||||
|  *  250000 : Maximum for DRV8825 stepper driver | ||||
|  *  200000 : Maximum for LV8729 stepper driver | ||||
|  *  150000 : Maximum for TB6600 stepper driver | ||||
|  *  130000 : Maximum for LV8729 stepper driver | ||||
|  *   15000 : Maximum for TB6560 stepper driver | ||||
|  * | ||||
|  * Override the default value based on the driver type set in Configuration.h. | ||||
|   | ||||
| @@ -514,8 +514,10 @@ | ||||
|     #define MINIMUM_STEPPER_PULSE 3 | ||||
|   #elif HAS_DRIVER(DRV8825) | ||||
|     #define MINIMUM_STEPPER_PULSE 2 | ||||
|   #elif HAS_DRIVER(A4988) || HAS_DRIVER(LV8729) || HAS_DRIVER(A5984) | ||||
|   #elif HAS_DRIVER(A4988) || HAS_DRIVER(A5984) | ||||
|     #define MINIMUM_STEPPER_PULSE 1 | ||||
|   #elif HAS_DRIVER(LV8729) | ||||
|     #define MINIMUM_STEPPER_PULSE 0 | ||||
|   #elif TRINAMICS | ||||
|     #define MINIMUM_STEPPER_PULSE 0 | ||||
|   #else | ||||
| @@ -526,10 +528,10 @@ | ||||
| #ifndef MAXIMUM_STEPPER_RATE | ||||
|   #if HAS_DRIVER(TB6560) | ||||
|     #define MAXIMUM_STEPPER_RATE 15000 | ||||
|   #elif HAS_DRIVER(LV8729) | ||||
|     #define MAXIMUM_STEPPER_RATE 130000 | ||||
|   #elif HAS_DRIVER(TB6600) | ||||
|     #define MAXIMUM_STEPPER_RATE 150000 | ||||
|   #elif HAS_DRIVER(LV8729) | ||||
|     #define MAXIMUM_STEPPER_RATE 200000 | ||||
|   #elif HAS_DRIVER(DRV8825) | ||||
|     #define MAXIMUM_STEPPER_RATE 250000 | ||||
|   #elif TRINAMICS | ||||
|   | ||||
| @@ -156,9 +156,11 @@ | ||||
| #define MIN_ISR_LOOP_CYCLES (ISR_X_STEPPER_CYCLES + ISR_Y_STEPPER_CYCLES + ISR_Z_STEPPER_CYCLES + ISR_E_STEPPER_CYCLES + ISR_MIXING_STEPPER_CYCLES) | ||||
|  | ||||
| // Calculate the minimum MPU cycles needed per pulse to enforce, limited to the max stepper rate | ||||
| #define _MIN_STEPPER_PULSE_CYCLES(N) MAX((unsigned long)((F_CPU) / (MAXIMUM_STEPPER_RATE)), ((F_CPU) / 500000UL) * (N)) | ||||
| #define _MIN_STEPPER_PULSE_CYCLES(N) MAX(uint32_t((F_CPU) / (MAXIMUM_STEPPER_RATE)), ((F_CPU) / 500000UL) * (N)) | ||||
| #if MINIMUM_STEPPER_PULSE | ||||
|   #define MIN_STEPPER_PULSE_CYCLES _MIN_STEPPER_PULSE_CYCLES((unsigned long)(MINIMUM_STEPPER_PULSE)) | ||||
|   #define MIN_STEPPER_PULSE_CYCLES _MIN_STEPPER_PULSE_CYCLES(uint32_t(MINIMUM_STEPPER_PULSE)) | ||||
| #elif HAS_DRIVER(LV8729) | ||||
|   #define MIN_STEPPER_PULSE_CYCLES uint32_t((((F_CPU) - 1) / 2000000) + 1) // 0.5µs, aka 500ns | ||||
| #else | ||||
|   #define MIN_STEPPER_PULSE_CYCLES _MIN_STEPPER_PULSE_CYCLES(1UL) | ||||
| #endif | ||||
| @@ -167,7 +169,11 @@ | ||||
| // adding the "start stepper pulse" code section execution cycles to account for that not all | ||||
| // pulses start at the beginning of the loop, so an extra time must be added to compensate so | ||||
| // the last generated pulse (usually the extruder stepper) has the right length | ||||
| #define MIN_PULSE_TICKS (((PULSE_TIMER_TICKS_PER_US) * (unsigned long)(MINIMUM_STEPPER_PULSE)) + ((MIN_ISR_START_LOOP_CYCLES) / (unsigned long)(PULSE_TIMER_PRESCALE))) | ||||
| #if HAS_DRIVER(LV8729) | ||||
|   #define MIN_PULSE_TICKS ((((PULSE_TIMER_TICKS_PER_US) + 1) / 2) + ((MIN_ISR_START_LOOP_CYCLES) / uint32_t(PULSE_TIMER_PRESCALE))) | ||||
| #else | ||||
|   #define MIN_PULSE_TICKS (((PULSE_TIMER_TICKS_PER_US) * uint32_t(MINIMUM_STEPPER_PULSE)) + ((MIN_ISR_START_LOOP_CYCLES) / uint32_t(PULSE_TIMER_PRESCALE))) | ||||
| #endif | ||||
|  | ||||
| // Calculate the extra ticks of the PULSE timer between step pulses | ||||
| #define ADDED_STEP_TICKS (((MIN_STEPPER_PULSE_CYCLES) / (PULSE_TIMER_PRESCALE)) - (MIN_PULSE_TICKS)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user