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

[FR] SENSORLESS_HOMING for I, J, K… axes #22649

Closed
manicresin opened this issue Aug 27, 2021 · 25 comments
Closed

[FR] SENSORLESS_HOMING for I, J, K… axes #22649

manicresin opened this issue Aug 27, 2021 · 25 comments
Labels

Comments

@manicresin
Copy link

manicresin commented Aug 27, 2021

Did you test the latest bugfix-2.0.x code?

Yes, and the problem still exists.

Bug Description

SENSORLESS_HOMING does not work on I, J, K Axis (U, V, W).

Bug Timeline

I am not sure if this is new or this is even supported.

Expected behavior

When enabling SENSORLESS_HOMING on I, J, or K axis with a supported TMC driver (i.e. TMC2209) and homing said axis with the G28 command axis should homes as expected.

Actual behavior

I, J, or K attempts to locate home but the diag pin from the TMC driver is never reporting a stop and continues to crash in the homing stop block.

Steps to Reproduce

Step 1: Configure I, J, and/or K axis in the boards pin.h, I am using pins_custom.h.
Step 2: In Configuration.h uncomment and set #define LINEAR_AXES 4
Step 3: Further implement the addition axis in Configuration.h and Configuation_adv.h as accrding to the wiki
Step 4: Compile and load firmware.
Step 5: If STALL_SENSITIVITY was not set in config_adv set with M914
Step 6: Home the axis with G28

Version of Marlin Firmware

Marlin bugfix-2.0.x (Aug 27 2021 10:43:00)

Printer model

CUSTOM

Electronics

SKR 2, TMC2209

Add-ons

No response

Bed Leveling

No response

Your Slicer

No response

Host Software

No response

Additional information & file uploads

This issue only affects the AXIS in firmware. I swapped the pins for Z and I (U) in pins_custom.h and was able to reproduce the issue.
I was going to use this as a 5 axis controller run a custom robot so my config and config_adv have most of the extruder and heatbed items removed.
I also modified the pins.h with the following #include "pins_custom.h" // env:BIGTREE_SKR_2 env:BIGTREE_SKR_2_USB

configs.zip

@DerAndere1
Copy link
Contributor

I did not find the cause for this bug so far, but I found some unrelated things that still need work with LINEAR_AXES >= 4 here:

  • QUICK_HOMING
  • SAFE_Z_HOMING
  • SPI_SENSORLESS (Conditionals_post.cpp L2117)

@DerAndere1
Copy link
Contributor

DerAndere1 commented Aug 28, 2021

Try the following.

#if !defined(I_USE_ENDSTOP) && defined(I_STALL_SENSITIVITY) && _PEXI(I_E_INDEX, DIAG)

chage that to

  #if !defined(I_DIAG_PIN) && !defined(I_USE_ENDSTOP) && defined(I_STALL_SENSITIVITY) && _PEXI(I_E_INDEX, DIAG)

#if !defined(J_USE_ENDSTOP) && defined(J_STALL_SENSITIVITY) && _PEXI(J_E_INDEX, DIAG)

change that to

  #if !defined(J_DIAG_PIN) && !defined(J_USE_ENDSTOP) && defined(J_STALL_SENSITIVITY) && _PEXI(J_E_INDEX, DIAG)

#if !defined(K_USE_ENDSTOP) && defined(K_STALL_SENSITIVITY) && _PEXI(K_E_INDEX, DIAG)

change that to:

  #if !defined(K_DIAG_PIN) && !defined(K_USE_ENDSTOP) && defined(K_STALL_SENSITIVITY) && _PEXI(K_E_INDEX, DIAG)

@manicresin
Copy link
Author

Try the following.

#if !defined(I_USE_ENDSTOP) && defined(I_STALL_SENSITIVITY) && _PEXI(I_E_INDEX, DIAG)

chage that to

  #if !defined(I_DIAG_PIN) && !defined(I_USE_ENDSTOP) && defined(I_STALL_SENSITIVITY) && _PEXI(I_E_INDEX, DIAG)

#if !defined(J_USE_ENDSTOP) && defined(J_STALL_SENSITIVITY) && _PEXI(J_E_INDEX, DIAG)

change that to

  #if !defined(J_DIAG_PIN) && !defined(J_USE_ENDSTOP) && defined(J_STALL_SENSITIVITY) && _PEXI(J_E_INDEX, DIAG)

#if !defined(K_USE_ENDSTOP) && defined(K_STALL_SENSITIVITY) && _PEXI(K_E_INDEX, DIAG)

change that to:

  #if !defined(K_DIAG_PIN) && !defined(K_USE_ENDSTOP) && defined(K_STALL_SENSITIVITY) && _PEXI(K_E_INDEX, DIAG)

I made the changes that you have suggested but there was no change in homing behavior for the additional axis.

@DerAndere1
Copy link
Contributor

DerAndere1 commented Aug 30, 2021

M915 is wrong. Use M914 instead. But anyway I just saw that the feature is not completely implemented, e.g. code for axes I,J,K is missing from the function body of

sensorless_t start_sensorless_homing_per_axis(const AxisEnum axis) {

and

void end_sensorless_homing_per_axis(const AxisEnum axis, sensorless_t enable_stealth) {

@manicresin
Copy link
Author

manicresin commented Aug 31, 2021

M915 is wrong. Use M914 instead. But anyway I just saw that the feature is not completely implemented, e.g. code for axes I,J,K is missing from the function body of

sensorless_t start_sensorless_homing_per_axis(const AxisEnum axis) {

and

void end_sensorless_homing_per_axis(const AxisEnum axis, sensorless_t enable_stealth) {

Whoops, that was a typo, thanks for spotting it, I updated it with the correct command.

I will take a look at Motion.cpp and see if implementing the additional axis will work, thanks for the help.

@thinkyhead thinkyhead changed the title [BUG] SENSOLESS_HOMING does not work on I, J, K AXIS [FR] SENSORLESS_HOMING for I, J, K… axes Sep 4, 2021
@thinkyhead thinkyhead added the T: Feature Request Features requested by users. label Sep 4, 2021
@DerAndere1
Copy link
Contributor

Hi, @manicresin . Do you think you will manage to implement this feature yourself, or do you need help?

@manicresin
Copy link
Author

Hi, @manicresin . Do you think you will manage to implement this feature yourself, or do you need help?

I was going to implement it myself but I jump on another project at them moment and haven't had a chance to dig through it, thanks for the follow.

@rds11080
Copy link

hi, any fix for sensorless homing to work on I J K axis?

@DerAndere1
Copy link
Contributor

Can you test my branch https://github.com/DerAndere1/Marlin/tree/10axis_PR1 and report, if SENSORLESS_HOMING works with axes I, J, K ?

@rds11080
Copy link

Can you test my branch https://github.com/DerAndere1/Marlin/tree/10axis_PR1 and report, if SENSORLESS_HOMING works with axes I, J, K ?

hi, i try the firmware 10axis_PR1 on OCTOPUS V1.1 with tmc 2209 v3 (the one with weird jumper) , thanks

@tmartin007
Copy link

@DerAndere1 - After being unable to compile 2.0.9.2 (and bugfix-2.0.x) for a BTT SKR Pro V1.2, due to:

(In file included from Marlin/src/module/../inc/MarlinConfigPre.h:37,
                 from Marlin/src/module/../inc/MarlinConfig.h:28,
                 from Marlin/src/module/motion.h:31,
                 from Marlin/src/module/motion.cpp:27:
Marlin/src/module/motion.cpp: In function 'void homeaxis(AxisEnum)':
Marlin/src/module/motion.cpp:1738:23: error: 'I_MIN_PIN' was not declared in this scope; did you mean 'K_MIN_PIN'?)  

I just tried the branch https://github.com/DerAndere1/Marlin/tree/10axis_PR1, which yields the same error. I am attempting to configure just 4 linear axis with TMC2209s on every axis (hoping to achieve senseless homing on all axis, which worked on 2.0.8.2 for the XYZ axis).

Configuration.zip

@ellensp
Copy link
Contributor

ellensp commented Oct 6, 2021

@tmartin007 you need at add I endstops pins
Marlin can re allocate an unused extruders for the I stepper driver, but extruders do not have end stops. So you need to allocate them. See 5 axies ramps example Configuration/h https://github.com/MarlinFirmware/Configurations/blob/import-2.0.x/config/examples/linear_axes/RAMPS%205%20LINEAR_AXES/Configuration.h#L142

Hmm, actually it does have a Diag pin allocated...

@tmartin007
Copy link

@ellensp thanks for the prompt response and the 5axis example!
After defining I_MIN_PIN to be E0_DIAG_PIN, compiling succeeds.

Also, G28 A0 initiates Homing on axis "I" (while G28 I0 does not).
Unfortunately, though, sensorless homing does not work.
When swapping the "A" and "Z" stepper wires, sensorless homing of the same physical axis works (on "Z").

@tmartin007
Copy link

@DerAndere1

Can you test my branch https://github.com/DerAndere1/Marlin/tree/10axis_PR1 and report, if SENSORLESS_HOMING works with axes I, J, K ?

Testing your branch (https://github.com/DerAndere1/Marlin/tree/10axis_PR1) with the configuration files (attached),
"G28 A0" yields the following reproducible result while the I-axis moves a bit but always stops after a certain time :

M914 A10
ok
G28 A0
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:Homing Failed
Error:Printer halted. kill() called! 

Configuration.zip

@DerAndere1
Copy link
Contributor

DerAndere1 commented Oct 6, 2021

could you enable DEBUG_LEVELING_FEATURE and execute the following test-Gcode ?

M502
M500
M111 S38
M914 A10
G28 A

Repeat this test and try to stop the A axis by hand when it starts to do the small homing-move. Does the stallguard detect this? you can attach the log file from the terminal (serial monitor) of your host software as a zip file here

@tmartin007
Copy link

@DerAndere1

could you enable DEBUG_LEVELING_FEATURE and execute the following test-Gcode ?

M502
M500
M111 S38
M914 A10
G28 A

Repeat this test and try to stop the A axis by hand when it starts to do the small homing-move. Does the stallguard detect this? you can attach the log file from the terminal (serial monitor) of your host software as a zip file here

Thanks, I did as you proposed - (zipped log attached)

SENSORSLESS HOMEING ON I,J,K AXIS.rtf.zip

@DerAndere1
Copy link
Contributor

DerAndere1 commented Oct 7, 2021

To me, your log file looks as if SENSORLESS_HOMING works now for the 4th axis. but one thing is strange in the log file:

Home Fast: -75.00mm

is the output from this line of code:
https://github.com/DerAndere1/Marlin/blob/f8302a98c13a3ad23e6cb7cac31fc648f0626fa6/Marlin/src/module/motion.cpp#L1988

The move_length (EDIT: I meant max_length) is precalculated here:
https://github.com/DerAndere1/Marlin/blob/f8302a98c13a3ad23e6cb7cac31fc648f0626fa6/Marlin/src/inc/Conditionals_post.h#L110

From the attached configs I would expect
max_length = I_MAX_POS - I_MIN_POS = 200 - 0 = 200

thus I would expect an output of

Home Fast: -300.00mm

Please verify that the firmware you upload to your board has I_MAX_POS 200 and I_MIN_POS 0 in Configuration.h. Repeat the upload of the verified firmware to your board, as always followed by M502 and M500. Then repeat the tests.

@tmartin007
Copy link

tmartin007 commented Oct 7, 2021

@DerAndere1

Thank you very much for your response.

To me, your log file looks as if SENSORLESS_HOMING works now for the 4th axis.

Per your directions, I was able to manually grab the shaft-coupler of the 4th axis and hold it tight, so that it stopped moving early on in the test. - Nevertheless, the stepper still completed it's small homing move - this could be felt and heard clearly ;-).

but one thing is strange in the log file:

Home Fast: -75.00mm
is the output from this line of code:
https://github.com/DerAndere1/Marlin/blob/f8302a98c13a3ad23e6cb7cac31fc648f0626fa6/Marlin/src/module/motion.cpp#L1988

The move_length is precalculated here:
https://github.com/DerAndere1/Marlin/blob/f8302a98c13a3ad23e6cb7cac31fc648f0626fa6/Marlin/src/inc/Conditionals_post.h#L110

From the attached configs I would expect
move_length = I_MAX_POS - I_MIN_POS = 200 - 0 = 200

thus I would expect an output of ...

Yesterday, I had attached updated Config-Files https://github.com/MarlinFirmware/Marlin/issues/22649#issuecomment-936652249
with:

// Travel limits (mm) after homing, corresponding to endstop positions.
#define I_MIN_POS 0
#define I_MAX_POS 50

... sorry for the confusion.

However, to me it seems, as if move_length is computed in the line right before it is printed:

https://github.com/DerAndere1/Marlin/blob/f8302a98c13a3ad23e6cb7cac31fc648f0626fa6/Marlin/src/module/motion.cpp#L1987

Even though Conditionals_post.h defines:

#if LINEAR_AXES >= 4
  #define I_MAX_LENGTH (I_MAX_POS - (I_MIN_POS))
#endif

... form the quoted code, it is not really obvious to me that: move_length = I_MAX_POS - I_MIN_POS.
Meaning, it is not obvious that: move_length == I_MAX_LENGTH

Anyway, I just repeated the test (i.e. M502 ... G28 A while manually keeping the shaft-coupler from moving). The test was performed after double-checking that the Configs with #define I_MAX_POS 50 were used. The test yielded the following result:

M502
echo:Hardcoded Default Settings Loaded
ok
M500
Error:EEPROM disabled
ok
M111 S38
echo:DEBUG:INFO,ERRORS,LEVELING
ok
M914 A10
ok
G28 A
>>> G28  X0.00 Y0.00 Z0.00 A0.00
Machine Type: Cartesian
Probe: NONE
>>> homeaxis(A)
Home Fast: -75.00mm
>>> do_homing_move  X0.00 Y0.00 Z0.00 A0.00
...(A, -75.00, [5.00])
<<< do_homing_move  X0.00 Y0.00 Z0.00 A0.00
>>> set_axis_is_at_home(A)
Axis A home_offset = 0.00 position_shift = 0.00
> home_offset[A] = 0.00
  current_position= X0.00 Y0.00 Z0.00 A0.00 : 
<<< set_axis_is_at_home(A)
  current_position= X0.00 Y0.00 Z0.00 A0.00 : sync_plan_position
  current_position= X0.00 Y0.00 Z0.00 A0.00 : > AFTER set_axis_is_at_home
echo:busy: processing
echo:busy: processing
<<< homeaxis(A)
  current_position= X0.00 Y0.00 Z0.00 A20.00 : sync_plan_position
X:0.00 Y:0.00 Z:0.00 A:20.00 Count X:0 Y:0 Z:0 A:51200
<<< G28  X0.00 Y0.00 Z0.00 A20.00
ok

I'll be happy to perform more test, to help locate the problem ... - Please let me know, what I can do.

@DerAndere1
Copy link
Contributor

DerAndere1 commented Oct 7, 2021

Yesterday, I had attached updated Config-Files #22649 (comment)

Sorry, I was indeed looking at the wrong configs. So everything in the log file looks as expected to me.

Nevertheless, the stepper still completed it's small homing move - this could be felt and heard clearly ;-).

This was probably the backoff move. So what does the the log look like if you manually place the A axis less than 5 cm away from its physical axis minimum and execute the following test G-code?

M111 S38
M914 A255
G28
M914 A10
G28 A

Meaning, it is not obvious that: move_length == I_MAX_LENGTH

Sorry, I wanted to say that:

move_length = home_dir * 1.5 * max_length = home_dir * 1.5 * I_MAX_LENGTH = home_dir * 1.5 * (I_MAX_POS - I_MIN_POS)

I corrected my comment above. The main point is: you need to set the I_MAX_POS according to the length of your 4th axis to get proper homing.

@tmartin007
Copy link

@DerAndere1

The main point is: you need to set the I_MAX_POS according to the length of your 4th axis to get proper homing.

Thanks for clarifying. - This seems indeed to be part of the problem. - I am still investigating, though ...

@DerAndere1
Copy link
Contributor

The other setting that determines the actual homing move distance is DEFAULT_AXIS_STEPS_PER_UNIT. So make sure that this setting is also configured correctly for each axis.

@tmartin007
Copy link

tmartin007 commented Oct 8, 2021

@@DerAndere1

The other setting that determines the actual homing move distance is DEFAULT_AXIS_STEPS_PER_UNIT.

Yes, thanks, I had just discovered that my 4th axis does not seem to be configured accurately.
I will report my findings tomorrow.

@tmartin007
Copy link

@DerAndere1

It took a while, however I may report that HOMING of the I-axis with your branch:
https://github.com/DerAndere1/Marlin/tree/10axis_PR1 does work!

In my case, all stumbling blocks were related to the "I-"parameters set for: DEFAULT_AXIS_STEPS_PER_UNIT, DEFAULT_MAX_ACCELERATION, HOMING_FEEDRATE_MM_M and I_STALL_SENSITIVITY - all of which have an effect on each other and need to be fine-tuned in concert (quite frustrating at times ;-)).

However:

  1. without #define I_STOP_PIN E0_DIAG_PIN compilation fails
    (can I_STOP_PINnot be auto-assigned ?)
  2. the warning: #warning "Auto-assigned I_DIAG_PIN to X_MAX_PIN." is a bit confusing
    (should the I_DIAG_PIN not be auto-assigned to e.g. E0_DIAG_PIN ?)

@ellensp
Copy link
Contributor

ellensp commented Apr 1, 2022

9 axis has been merged, and in theory this also fixes Sensor less homing

@ellensp ellensp closed this as completed Apr 1, 2022
@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 May 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants