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

[BUG] M502/M500 when TMC drivers do not have VMOT results in incorrect values being stored in EEPROM #19313

Closed
ManuelMcLure opened this issue Sep 9, 2020 · 5 comments

Comments

@ManuelMcLure
Copy link
Contributor

Bug Description

If a motherboard is powered by USB but the main power supply is not powered on, executing M500 will save the wrong values into EEPROM.

My Configurations

Config.zip

Steps to Reproduce

  • Use my configuration on an LPC-1768-based board.
  • Power board with main power.
  • Execute M502.
  • Execute M503 and see that there is no M569 S1 T0 E line in the output. This is the correct behavior.
  • Execute M500.
  • Power down the board, power it up again, execute M503 and see that there still is no M569 S1 T0 E line.
  • Power down the board, power it up just via USB, execute M502 followed by M500.
  • Power down the board, power it up via the main supply. Execute M503 - there will be a M569 S1 T0 E line.

Expected behavior: [What you expect to happen]

M502 followed by M500 will initialize EEPROM to the values in Configuration.h regardless of whether the TMC drivers have full power.

Actual behavior: [What actually happens]

Executing M502 followed by M500 when board is only powered by USB results in different values in EEPROM than if full power is applied.

Additional Information

It looks like MarlinSettings::save() attempts to fetch the values from the drivers instead of using the cached values that are used by M80 and M122 I to re-initialize the drivers. I noticed this specifically with StealthChop/Spreadcycle but code review shows that other TMC driver configuration values suffer from the same issue.

@GMagician
Copy link
Contributor

I think this will give you further issues if you don't "reset" tmc after full power. This was already seen, and reported, by me a "month ago". Some boards keep vmot to 3.3V. To fix this just give 5V to vmot when 12/24V is missing (if your board has possibility to do that).
Not sure trinamics report this, it can be a board design fault or missing info issue

@GMagician
Copy link
Contributor

You may read #18498

@ManuelMcLure
Copy link
Contributor Author

This isn't about the initialization, but rather that even though Marlin knows what the values should be for the TMC drivers (in the case of the SpreadCycle/StealthChop these are in stored.stealthChop_enabled), instead of using those values when storing with M500 it instead tries to read them from the TMC driver. If the values in EEPROM are correct when booting up (because they were stored with M500 once full power was applied) they are correctly sent to the drivers when M80 or M122 I is executed. It's just this save issue that is a problem. I'm going to do a PR to get as much of this stuff from the stored values instead of from the drivers.

@ManuelMcLure
Copy link
Contributor Author

Fixed by #19364

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants