Commit Graph

145 Commits

Author SHA1 Message Date
Guðni Már Gilbert 503c01aa57 tmc2130: write chopper config and powerdown setting first
I noticed this is how the order is in 3.13.0 and before.
I want to keep it exactly the same.

This somehow saves 2 bytes of flash. Probably compiler magic.

Change in memory:
Flash: -2 bytes
SRAM: 0 bytes
2023-08-05 10:41:21 +02:00
Guðni Már Gilbert 02332018ec tmc2130: Fix bug with vSense bit and current values
If vSense changes at runtime due to Run current
being changed. Then we must always shift the Hold current
correctly. Whether the vSense is changing 1 -> 0 or 0 ->1

Change in memory (with TMC2130_SERVICE_CODES_M910_M918):
Flash: +76 bytes
SRAM: 0 bytes
2023-08-05 10:41:21 +02:00
gudnimg a1a3194985 tmc2130: Fix wrong values report by M913 when Hold > Run
The firmware will ensure that the Hold current can never
exceed the Run current. In this scenario we must update
the global current array so that M913 reflects the register settings.

Added a echo to serial when this truncation happens

Change in memory:
Flash: +54 bytes
SRAM: 0 bytes
2023-08-05 10:41:21 +02:00
Guðni Már Gilbert 5b8813bf18 tmc2130: fix octoprint error 2023-07-25 15:02:49 +00:00
Guðni Már Gilbert 5288d615f8 optimisation: lcd avoid streams
Author: leptun

Change in memory:
Flash: -124 bytes
SRAM: 0 bytes
2023-07-25 15:02:49 +00:00
Guðni Már Gilbert 0ab10a9df6 tmc2130: chopconf: add comments to structure 2023-07-25 08:56:43 +02:00
Guðni Már Gilbert ed13d008d9 tmc2130: minor code cleanup
Using tmc2130_wr() instead makes the code a bit more
aligned and easier to read IMO

No change in memory
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert 3819f7a473 tmc2130: Refactor code for setting/changing currents
- Always re-calculate the Vsense flag when the currents are changed
- Make sure Hold current is not larger than Run current
- Added SetCurrents() function from MMU FW
- Added MotorCurrents structure from MMU FW
- Various code size optimisations e.g. in power panic

Change in memory:
Flash: -10 bytes
SRAM: +4 bytes
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert a87faba2bd tmc2130: pull TMC2130_CNSTOFF_E outside tmc2130_setup_chopper
We can probably improve tmc2130_chopper_config further by adding
a constructor.

No change in memory
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert 664d4e2bbe tmc2130: chopconf: Add constructor to ChopConfU
Removed redundant initialisations which the constructor now takes care of

Change in memory:
Flash: +8 bytes
SRAM: 0 bytes
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert bb8ebbb5e3 tmc2130: chopconf: simplify intpol config
Pull the preprocessor code outside tmc2130_setup_chopper

No change in memory
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert 2d2ab6e889 tmc2130: chopconf: simplify dedge code
move dedge preprocessing out of tmc2130_setup_chopper

We can use default_dedge_bit to initialise
the dedge bit in the chopconf constuctor later

No change in memory
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert 3842a5c98c optimisation: correctly reset registers in tmc2130_home_exit
Previously Z-axis would not be reset to
TMC2130_GCONF_DYNAMIC_SGSENS
in tmc2130_home_exit() when
TMC2130_STEALTH_Z is defined

Pulled configuration code into one common function
this ensures the registers are set correctly like in tmc2130_init()

Change in memory:
Flash: -206 bytes
SRAM: 0 bytes
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert 60f1c2095f optimise tmc2130_setup_chopper further
Reduce code duplication

Change in memory:
Flash: -50 bytes
SRAM: 0 bytes
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert ae1a7898dc optimisation: use union in for TMC2130 PWMCONF
Simplify writing the value to PWMCONF by
gathering all the bits into one dword.

Change in memory:
Flash: -128 bytes
SRAM: 0 bytes
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert 06100e366c optimisation: use union in tmc2130_setup_chopper
An idea from the MMU FW

Change in memory:
Flash: -278 bytes
SRAM: 0 bytes
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert 34ef9665cd Remove two ultralcd includes 2023-07-13 09:57:52 +02:00
Guðni Már Gilbert ebdcfbec50 cleanup: tmc2130: make variables static where applicable
No change in memory
2023-04-15 13:45:10 +00:00
Guðni Már Gilbert d175dba669 optimisation: use expired_cont is specific places
!variable.running() || variable.expired()
is equal to
variable.expired_cont()

The latter required less flash memory

Change in memory:
Flash: -28 bytes
SRAM: 0 bytes
2023-04-15 13:45:09 +00:00
Guðni Már Gilbert 7ff514621c cleanup: remove unused global variable 2023-04-15 13:45:09 +00:00
Alex Voinea 339c080b19
tmc2130: optimize mask when iterating over axes
Change in memory:
Flash: -28 bytes
SRAM: 0 bytes
2023-04-09 17:49:28 +02:00
Guðni Már Gilbert 4e31bb94ef tmc2130: simplify parsing axis mask
There is no need to check if every axis bit with each for-loop
iteration. We just need to check if a given axit bit is set.

Change in memory:
Flash: -6 bytes
SRAM: 0 bytes
2023-04-09 13:12:22 +00:00
Alex Voinea 1b9379b328 PSU_DELTA alternative 2023-04-05 11:12:17 +02:00
Yuri D'Elia b3790f4094 Typo: meassure -> measure 2022-12-22 12:54:42 +01:00
Alex Voinea 510f13b24a Make the diag pins open collector with pullup.
Solves random crash detected on startup
2022-09-14 07:39:47 +02:00
Alex Voinea bb57d99c35 Remove the crashDetection software counters and use sfilt 2022-09-14 07:39:47 +02:00
Yuri D'Elia e37435b53f Merge remote-tracking branch 'upstream/MK3_3.11.1' into mk311_sync 2022-07-04 16:14:23 +02:00
Alex Voinea 1fa87da2d0 Fix gnu++17 register warning 2022-07-04 09:35:17 +02:00
Alex Voinea 6ce7792045 Remove "hh" in fmt where it makes no difference 2022-02-02 20:58:21 +01:00
Guðni Már Gilbert 9bf45773f9 Merge remote-tracking branch 'upstream/MK3' into rebase-testing-ground-v2 2022-01-30 11:43:16 +00:00
Alex Voinea cdd7ea30f4 Fix LUT loop 2022-01-30 11:39:23 +00:00
Alex Voinea fb10b4398e Merge pull request #6 from gudnimg/gudni-PR1
Purged some `int`s for `uint8_t` when using the axis enum
2022-01-30 11:30:25 +00:00
Voinea Dragos 9d1e54e685 Tmc2130 use ShortTimer instead of custom timer implementation 2022-01-30 11:22:43 +00:00
Voinea Dragos d8a14842c5 Remove unused `skip_debug_msg` flag 2022-01-30 11:22:43 +00:00
Guðni Már Gilbert b716c208d7 Various optimisation to change int to uint8_t
This commit saves 174 bytes of flash memory
2021-08-03 22:42:01 +00:00
Guðni Már Gilbert d087973e00 Remove redundant extern variable is_usb_printing from tmc2130.cpp
This extern variable is included from Marlin.h
2021-07-20 09:12:14 +02:00
Yuri D'Elia 051f03119b Fix misleading indentation warnings by expanding tabs 2021-06-21 06:52:52 +02:00
Marek Bel aa45091400
Scale extruder motor current linearly with speed. (#2813)
Scale extruder motor current linearly with speed.

49% less heating when running at low speed and standstill, 4% more torque at maximum extrusion rate (15mm^3/s), 15% more torque in high speed movements (un/retractions).

StealthChop mode is used for low speeds (below 900mm/min)
spreadCycle is used above. Transition speed is well above maximum extrusion rate of 15mm^3/s (275mm/min) so mode transition is not expected to be visible on printed surface.

StealthChop is expected to improve printed surface quality (less artifacts).

Warning you can burn extruder motor if it is not the same impedance as original Prusa i3 Extruder stepper motor. There is no current feedback in low speed so lower impedance motor can be burned by over current.

Even there is no direct current feedback, there is no risk for original motor thermal runaway, as motor resistance increases with temperature, current decreases.

Standstill peak phase current is expected to be 500 mA and linearly increase with speed to 970 mA at 900mm/min where spreadCycle constant current regulation takes over and keeps peak current at 805 mA to maximum speed possible.

As motor heating increases with current squared, lowering low speed current from 700mA to 500mA decreases heating 49% in thate mode, where motor spends most of the time.

Enable E-motor cool mode in farm mode only (and experimental menu) - the experimental menu is visible AND the EEPROM_ECOOL variable has a value of the universal answer to all problems of the universe - i.e. two conditions must be met at the start of the FW to enable the E-cool mode. If the user enables the experimental menu, sets the E-cool mode and disables the menu afterwards, on the next start of the FW the E-cool mode will be DISABLED. This is still subject to discussion how much obscure (security through obscurity) we'd like this option to have .

Additional stuff:
* Add serial debug msg to verify if E-cool mode is on
* Avoid access to E-cool mode switch on machines without TMC2130
* Do not allow only M907 E in case of E-cool mode+warn the user on the serial line that the command was skipped

Co-authored-by: D.R.racer <drracer@drracer.eu>
2021-04-23 16:06:28 +02:00
Yuri D'Elia 3276320a06 Hide tmc2130_sg_change behind DEBUG_CRASHDET_COUNTERS
tmc2130_sg_change is only used for debugging purposes.
Hide definition and usage behind the required define.
2021-04-05 20:07:03 +02:00
DRracer 42311db5f1
Merge pull request #2789 from wavexx/MK3_TMC2130_DEDGE
Use/enable TMC2130 DEDGE support in MK3/MK3S
2021-01-29 11:13:09 +01:00
Yuri D'Elia 4fed728e08 Elide delayMicroseconds for TMC2130 in non-DEDGE mode
Introduce new macros TMC2130_MINIMUM_DELAY/STEPPER_MINIMUM_DELAY for
blocking pauses.

If MINIMUM_PULSE has defined to be zero, avoid the delay call entirely.
2021-01-26 16:02:53 +01:00
Voinea Dragos da21916473 Change printf_P without format arguments and NL to puts_P only 2021-01-22 18:56:05 +02:00
Yuri D'Elia e6b182aa9f Implement proper step/delay pauses in tmc2130 functions
Add constants for the various required delays in tmc2130.h,
which will come in handy for stepper.cpp as well.

Move the delays in the _set functions and remove the pauses
from the various calling points and macros.

Note that the hard-coded pause wouldn't cut it for the stepper ISR,
but it's fine for other use cases.
2020-06-24 17:58:43 +02:00
Yuri D'Elia 6ceca9bf85 Implement double-edge stepping
Introduce new wrapper macros to tick the stepper pins.
Default to the original raising-edge stepping mode.

When using the TMC double-edge stepping mode (aka half-wave or
square-wave mode) the _LO macros become no-ops.
2020-06-24 17:58:43 +02:00
Yuri D'Elia 6017600714 Reintroduce the ability to disable TMC interpolation per-axis 2020-06-24 17:58:43 +02:00
Alex Voinea fd1d05ab48
♻️Code optimization 2020-04-02 14:44:44 +03:00
Alex Voinea d0c51b9e73
int -> bool 2020-03-26 19:06:35 +02:00
Alex Voinea 2e50954710
Merge branch 'MK3' into MK3_fix_selftest_Z_crash2 2020-01-22 14:56:54 +02:00
DRracer d6ac9e4638
Merge pull request #2342 from vintagepc/2306-hard-reset-homing-fails
Fix #2306 hard reset homing fails
2019-12-15 10:51:52 +01:00
Alex Voinea 779423f0e7
Move hardcoded values to variants 2019-11-29 15:06:54 +02:00