Skip to content

[1.1.x] More complete Trinamic driver options#10101

Merged
thinkyhead merged 4 commits intoMarlinFirmware:bugfix-1.1.xfrom
thinkyhead:bf1_eeprom_M913
Mar 21, 2018
Merged

[1.1.x] More complete Trinamic driver options#10101
thinkyhead merged 4 commits intoMarlinFirmware:bugfix-1.1.xfrom
thinkyhead:bf1_eeprom_M913

Conversation

@thinkyhead
Copy link
Member

@thinkyhead thinkyhead commented Mar 14, 2018

Addressing #10087

  • Add EEPROM Init, Load, Save, Report for M913 Hybrid Threshold.
  • Bump EEPROM to V53.
  • Reorder TMC_AxisEnum to match EEPROM storage.
  • Reduce PROGMEM string usage with small functions.
  • Add T parameter to M906/M913 to specific which extruder.
  • Add I (index) parameter to M906/M913/M914 to specify which dual axis stepper.

Concise Diff
Counterpart to #10102

Copy link
Member

@teemuatlut teemuatlut Mar 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No N argument needed?
tmc_hybrid_threshold array should be indexed according to the N argument and not P_AXIS.
Each driver can have their unique threshold.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already patched. It is needed as an index for the array.

@thinkyhead thinkyhead force-pushed the bf1_eeprom_M913 branch 12 times, most recently from 61d6b30 to 7d68ff2 Compare March 14, 2018 12:06
@thinkyhead
Copy link
Member Author

Currently the M906 and M913 commands always set the same value for all extruders when given an E parameter. Perhaps those commands should be extended to take a T parameter specifying which extruder to set, and if no T parameter is given they should set the active extruder.

@thinkyhead thinkyhead force-pushed the bf1_eeprom_M913 branch 6 times, most recently from ca55aac to 4d9e8ba Compare March 15, 2018 03:22
@thinkyhead thinkyhead changed the title [1.1.x] Add M913 Hybrid Threshold to EEPROM [1.1.x] More complete Trinamic driver options Mar 15, 2018
@thinkyhead
Copy link
Member Author

@teemuatlut Submitted for your approval….

Copy link
Member

@teemuatlut teemuatlut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anything obvious why something wouldn't work. The most noteworthy is if the if conditions work as expected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work alright? What's the boolean result of assigning a value to a variable as it is not a comparison in itself?

Copy link
Member Author

@thinkyhead thinkyhead Mar 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-zero evaluates as true in all C-like languages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will change the behavior of M906 so that the values are no longer reported when setting a new value.
This also applies to the following TMC gcodes.

Copy link
Member Author

@thinkyhead thinkyhead Mar 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. That is the intent. We don't want the EEPROM loading to spew more information than the M503 report already produces. So the tmc setters no longer repeat the set value. It's also a standard of Marlin to stay quiet when setting values, but to report values when a command is given without arguments.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like TMC_COUNT would probably be a bit closer but doesn't really matter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The EEPROM needs to save placeholders for all potential axes. It shouldn't resize based on flexible options. MAX_EXTRUDERS will only change when Marlin gains support for more extruders.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminds me that we could remove setCurrent from tmc_init functions in stepper_indirection.cpp as we already set current (and some other parameters) here already. The newer versions of the libraries support a push method that re-sends all the shadow registers to the driver in case the driver was not powered by 12V when initially booting the machine, like when PS_DEFAULT_OFF is enabled. But let's not do that yet as it will require testing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As another standard behavior, Marlin initialized all settings-based values in the EEPROM load and reset code, so yes, if they are also being initialized in stepper_indirection then we can eliminate the redundancy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminds me that we could remove setCurrent from tmc_init functions

It looks like tmc2130_init call would still be needed in response to the M80 command powering the board, unless we can enable those shadow registers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the push command isn't yet even copied into the TMC2208Stepper library.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we will need to add our own "shadow registers" because if you power down with M81 and then re-power with M80 the settings will revert to those in the configuration, and won't use the ones saved in the EEPROM.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word hysterisis should be hysteresis.

I'll fix that but it'll break Marlin for a bit. See stepper_indirection.cpp.

settings.reset or settings.load don't handle all the configuration parameters so we still need to call init. Although there may very well still be some that are duplicates.

M80 can call st.push() to sync to the drivers anything that was attempted while there was no 12V power. I'll add this to TMC2208Stepper v0.0.4 as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add this to TMC2208Stepper v0.0.4 as well.

Sounds good. I hope we can get that before the 1.1.9 release. In the meantime for this PR I need to come up with some kind of alternative solution.

Note that the settings.load/settings.reset method is called before the stepper.init function. It looks like we'll need to call stepper.init first. But I hope there's not some "Catch-22" here, where we can't call stepper.init before or during EEPROM loading because it depends on having values already loaded from EEPROM.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If stepper.init is called before settings.load then we no longer have to call tmc_init_cs_pins in setup.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TMC2208Stepper v0.0.4 released.
Adds the push method and fixes the same typo that was in TMC2130Stepper.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated Marlin to use the latest libraries. I hoped to check the version number in the SanityCheck.h but it's not visible to the preprocessor. For the next version that would be a useful addition.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here as I said with the v2.0.0 PR. Need to account for dual steppers and possibility for a better output format.

@thinkyhead thinkyhead force-pushed the bf1_eeprom_M913 branch 2 times, most recently from 1e265a4 to ff8841e Compare March 18, 2018 01:15
@thinkyhead thinkyhead force-pushed the bf1_eeprom_M913 branch 8 times, most recently from bd31a3f to 67c8ef4 Compare March 20, 2018 02:44
@thinkyhead thinkyhead merged commit bc01200 into MarlinFirmware:bugfix-1.1.x Mar 21, 2018
@thinkyhead thinkyhead deleted the bf1_eeprom_M913 branch March 21, 2018 04:14
thinkyhead added a commit that referenced this pull request Mar 23, 2018
thinkyhead added a commit that referenced this pull request Sep 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants