[2.0.x] Specify stepper drivers per axis#11133
[2.0.x] Specify stepper drivers per axis#11133GMagician wants to merge 2 commits intoMarlinFirmware:bugfix-2.0.xfrom GMagician:2.0.x-define-drivers-axis
Conversation
|
This is an attempt to satisfy #11119. Maybe is not the best, maybe some define are in wrong place but at the moment is just an idea. |
|
A good start. But note that this is in conflict with |
|
You can have a look at what @MagoKimbra did in MK4duo (obviously the file structure there is quite different, but not that much) MKFirmware/MK4duo@4dc684a |
I know I'm repeating myself but never hurts to reiterate even if just for documentation purposes; |
It's just a matter of whether to do this now and include the change in 1.1.9, or retain the current method for the final 1.1.x release and apply this new method only to 2.0.x. |
|
I'd say leave 1.1.x be and apply only to 2.0.x after the 1.1.9 release. |
For spi control used/not used I was thinking of with this I can simply redefine My 'driver' definition is more general than @teemuatlut since it apply also to driver with no features at all, but I think he can use mine as base to link in his collective macros. eg so this will simplify also his work. Now I don't know if it's better to use 'HAVE' or 'HAS'. I meant printer/system this is why I used 'HAS'. |
I'll take a look at it |
|
Ok, now it's almost to the end. Missing only driver and timing in examples Since I saw @teemuatlut will add 2660 and 5130 I also prepared defines for them |
|
I could be wrong but I think the logic added to configuration_adv should be in the sanity check, the configuration files should be pure data. |
|
@p3p sanity should check mismatch thing and raise error, maybe these should go in conditional_post.h but something must be done to let user override assumed values...but really someone need to override them? |
Configuration.h
#define X_DRIVER_TYPE DRV8825
//#define Y_DRIVER_TYPE TMC2100
...Configuration_adv.h:
// Optional override
//#define STEP_PULSE_WIDTH 5Configuration_post.h
#define HAS_DRIVER(IC) (X_DRIVER_TYPE == IC) || (Y_DRIVER_TYPE == IC) || ...
#ifndef STEP_PULSE_WIDTH
// Pulse width definition in order
#if HAS_DRIVER(DRV8825)
#define STEP_PULSE_WIDTH 10
#elif HAS_DRIVER(TMC2100)
#define STEP_PULSE_WIDTH 9
#elif HAS_DRIVER(A4988)
#define STEP_PULSE_WIDTH 8
#else
// Probably don't need this unless compiler expects it to be defined.
// By default let Marlin run as fast as possible
#define STEP_PULSE_WIDTH 0
#endif
#endifThis leaves the driver selection as optional, while also giving an override option for those who would want to tweak the timings. EDIT: |
|
@teemuatlut I agree with you but your solution is to arrange STEP_PULSE_WIDTH test from worst to best.
CONS
My solution
CONS
If I would be the only maintainer I would choose for sure your solution, but since many people may put hands on it, I think mine is safer. survey for maintainers: what do you think is better? Also, macros can be reduced (coping @MagoKimbra solution) and I'll do that also to clean up code. |
|
Likely that I have missed it but I couldn't find the logic to tune the enitre system to comply with the slowest timings / lowest frequency in case of mixed configurations. |
|
@GMagician I'd rather not see your definition ladder in a configuration file. It's quite rare for us to add new drivers, and especially drivers that would need special timing constraints. If for example the user would define the driver type as ABC1234 (sounds like a Alphabet product), then Marlin would just use the default values. There would be nothing to add. Only in the case the driver wouldn't like our default values. Also we go to some lengths to improve usability at the expense of added code lines. |
Current defaults
Unfortunately this is not true: But I can't understand correctly
|
look at configuration_adv.h #if HAS_DRIVER(TB6600)
#if MINIMUM_STEPPER_DIR_DELAY < 1500 // guess, no info in datasheet
#undef MINIMUM_STEPPER_DIR_DELAY
#define MINIMUM_STEPPER_DIR_DELAY 1500
#endif
#if MINIMUM_STEPPER_PULSE < 3
#undef MINIMUM_STEPPER_PULSE
#define MINIMUM_STEPPER_PULSE 3
#endif
#if !defined(MAXIMUM_STEPPER_RATE) || MAXIMUM_STEPPER_RATE > 150000
#undef MAXIMUM_STEPPER_RATE
#define MAXIMUM_STEPPER_RATE 150000
#endif
#endifevery driver type has its own tests |
that's already done, TMC2100 is not a string but a number and macro are already working |
|
Thanks @GMagician |
Marlin/Configuration_adv.h
Outdated
There was a problem hiding this comment.
Absolutely possible that I do not fully understand this but:
- Wouldn't it make sense to have a
#define MAXIMUM_STEPPER_RATE 0here as well? - To allow manual override in the following shouldn't the constructs all be analog to
#if !defined(MINIMUM_STEPPER_DIR_DELAY) || MINIMUM_STEPPER_DIR_DELAY < 200
There was a problem hiding this comment.
This is wrong "default and overriding value", but I'll change thing like suggested by teemuatlut, moving defines in other files and simplifying test as magokimbra has done
|
@thinkyhead now I think is ready to evaluate if merge or not. Do travis need to be changed for this? I don't know how |
|
What's the purpose for |
|
@teemuatlut DRIVER_TYPE is used to set up timings and nothing more, DRIVER_USES_SPI is used to add all communication code required. You may have also TMC without using SPI, I think |
Marlin/Configuration_adv.h
Outdated
There was a problem hiding this comment.
Since we're still allowing these values to be overridden, we might want to preserve the comments that describe the timings for each type of driver. If for no other reason that it provides some extra documentation.
Marlin/Configuration_adv.h
Outdated
There was a problem hiding this comment.
I think we should set these to the values for DRV8825, but leave them commented-out, since we mention that DRV8825 is the default on the main driver type config option. And it makes it clear that these have to have a numeric value.
Marlin/Configuration.h
Outdated
There was a problem hiding this comment.
I think these should all have the default value of DRV8825, but still remain commented out, since that is the default and it makes it clear that these must be defined as one of the listed options, and are not just on/off switches.
|
Rebased, squashed, and added some commits based on my review comments. |
|
@thinkyhead I think that there are some more missing sanitychecks to add (?_IS_TMC2130 and ?_IS_TMC2208) but I'm having some issue with git to get back it aligned with what you did... EDIT @thinkyhead may you help me with github to resync my branch? don't know which commands to use and I don't want to mess up |
|
@thinkyhead I solved github... deleted local branch and re-got it from remote When everything is reputed ok I'll start 1.1.x (if required) |
Cool. This also works: |
|
@thinkyhead TMC2660 & TMC5130 + SPI are not yet implemented, maybe @teemuatlut is working on that but it will be something coming next. Don't know if change again all .h... |
Since this is limited to the 2.0.x branch I'm not too worried about it right now. Note that TMC5130 will be SPI-only. And currently these drivers are implied by I've rebased and squashed the branch, so you can fetch the updated version anytime using the git commands I listed above. |
Sure?
|
|
I'm not aware of a stepstick style driver based on TMC5130. The only implementations I've seen are SPI-based to take advantage of the built-in motion controller. (There's no reason to use the expensive TMC5130 while eschewing the motion controller.) |
- Specify stepper drivers for each axis - Automatically apply timings based on (worst-case) driver type
|
I've reverted it just in case someone decides (for some reason) they want to use a 5130 without SPI. |
Wonder what other drivers support double edge stepping, getting rid of the wasted cycles during pulses sounds like an optimisation waiting to happen |
|
There is a simple way to eliminate all step pulse waiting when not double/quad stepping. |
Then no 1.1.x counterpart? |
f454bf2 to
63f4c9b
Compare
Maybe… I know @teemuatlut wants to give it a review and suggest more changes. And it's possible 1.1.9 is on the verge of release. Just a couple of subtle bugs to work out at the moment. |
|
@GMagician I'm forking your branch from here and combining it with what I had before for the TMC drivers. Maybe this way we can get most of the macro changes done in one go. |
|
No more required after teemuatlut pull request |
Use drivers type to initialize timings