Tuning Homing for 0.9 Degree Motors
I am starting this as a separate topic, because getting homing to work correctly on 0.9 motors has been difficult for some users. Simply put, the stall signal from from 0.9 degree motors is smaller than that from 1.8 degree motors. Adding to the problem is some variability in motor specimens. Also, physical setup issues such as too high/too low belt tension, sticky bearings, soft end hit points also obscure the Stallguard2 signal.
A - homing rate must be selected that is not too slow, too fast, and not at resonance speed.
Stallguard2 depends on sensing the back EMF of the motor changing as it encounters load. If motor velocity is too low, there isn't enough back EMF. If motor speed is too fast, back EMF is also generated by the motor own internals. Also, somewhere in the low to mid-range of speeds, the motor encounters resonance speed. That speed is also poor for generating a reliable Stallguard2 signal.
B - Stallguard threshold in the range 2 to 5 is ideal.
Stallguard threshold is the back EMF critical value above which a stall condition is considered true. A lower threshold means more sensitive. A higher threshold is less sensitive. Lower threshold detects a smaller back EMF, but also makes the system prone to false positive crashes. Higher threshold can make detection of end stops unreliable.
Trinamic documentation suggests valid values can range from -20 to 20, but in my testing on the EINSY and 0.9 motors, the actual usable range to consider is MUCH smaller. Somewhere in the range [2..5] is where I recommend keeping your Stallguard threshold.
C - Get belt tensions correct.
Belt tension changes underlying motor load during normal motion and also how sharply back EMF rises upon striking end of free travel. This is a difficult thing to get users to get reliably set correctly. 6 lbs total tension is what you should strive for. At that tension, belts are NOT guitar string tight. They merely have nearly all their slack taken out. Depressing the center of top belt spans should end slack take up at 2 mm depression. At that point, the rate of palpable belt tension increases as you switch from taking up slack to stretching the belt. Stretching the belts is NOT desirable. If it is difficult to pinch top and bottom of belt together, your tension is way too high.
D - Solid End Stops.
End stops must be solid hits for repeatable homing detection. If anything cushion physical impact, Stallguard doesn't get as clean a signal. Make certain that no cables, sheaths, tie wraps, or other impingements happen before the final, solid plastic vs plastic hit. For the y-axis, the usual configuration has impact between bearing and bearing mount. This is a hit that is off center and softer. Use of a Y-motor mount that includes a solid end stop against belt holder is beneficial.
Rubbing of any carriage components against axis ends before end impact must be eliminated.
E - Motors Low Detent
0.9 motors are not all manufactured to identical condition. Even with Moons' 0.9's, you can get an occasional dud. Inspect your motors by manually turning their shafts. For comparison feel how your original Prusa 1.8 degree motor shafts feel as you turn them. The 0.9 motors should have much softer detents that occur at 1/2 the angle change. If a motor is notchy, reject it. You will probably never get it to home reliably
===
Tuning Stallguard
Aside from proper physical setup and good motor specimens, We basically have two things that can be adjusted.
1. Stallguard threshold
2. Homing rate
Ideally, we could have real time graph of Stallguard signal, but we do not have access to that data. My old way of testing adjustments was to gradually alter the levels and note what seems to work most of the time. That strategy (sort of) works, but can lead to bad conclusions. Also, the long turn around time of reflashing firmware to test various settings made tests runs slow and less repeatable.
One poor outcome was my selection (until today) of a Y homing speed of 2000. That turns out to be a bad choice. Follow this article to its conclusion, you will see how a more objective and thorough tuning technique uncovered that a homing rate of 2000 on an OMC Y motor is probably at RESONANCE speed. That was not
Because we cannot directly graph Stallguard signal during motor motion, we need a proxy. When Stallguard is working well, detected motor position at end stop has minimal variance. When Stallguard is having problems, the position wavers. By repeatedly measuring stepper position after homing, we can look at how stable the system is working.
Unfortunately, this requires many test runs at each homing rate and Stallguard threshold
I recommend at least 8 test measurements at each combination.
For X and Y axis each
Homing feed rates from 1500 to 3000 {1500, 1750, 2000, 2250, 2500, 2750, 3000]
in combination with
Stallguard thresholds from 2 to 5
That is a lot of test runs, but doable with some help.
Custom M-Codes
In my latest 0.9 firmware (both the old 3.7x branch and new 3.8.0 branches) I have made my custom Mcodes M924 and M925 always available.
M924 - Sets Stallguard threshold during homing. Only 1 axis can be change at a time.
usage examples
M924 X4 // sets X stallguard threshold to 4
M924 Y3 // sets Y stallguard threshold to 3
M925 - Sets homing feed rate
usage examples
M924 X1500 // sets X homing rate to 1500
M924 Y3000 // sets Y homing rate to 3000
These let you change parameters without re-flashing the firmware. Settings won't be permanent, but you can much more quickly change settings. Once, you find best values, enter them into the firmware to make them permanent.
Method of Testing
Have latest 0.9 firmware flashed to your printer so you can use M924 and M925 commands.
Physical setup should already be at their best.
Work on only 1 axis at a time.
Send commands via a terminal window. I use Octopi with temperature readings suppressed.
//Set Stallguard homing threshold. In this case, we set Y stallguard threshold homing to 2
M924 Y2
//Set homing feed rate. Here we set it to 1000
M925 Y1000
//Home just Y-axis
G28 Y0
Printer will perform a homing operation and return results like...
Recv: tmc2130_home_enter(axes_mask=0x02)
Recv: 0 step=35 mscnt= 575
Recv: tmc2130_home_exit tmc2130_sg_homing_axes_mask=0x02
Recv: ok
You are only interested in the steps value. Copy that line and record it.
Repeat homing until you get at least 5, preferably 8 readings.
Change to next homing feed rate and repeat the homing tests.
Keep a record of the results.
Here is what I got with an OMC on Y at stallguard threshold of 2
M925 Y1000
Recv: 0 step= 3 mscnt= 53
Recv: 0 step= 3 mscnt= 52
Recv: 0 step= 3 mscnt= 55
Recv: 0 step= 3 mscnt= 52
Recv: 0 step= 3 mscnt= 58
Recv: 0 step= 5 mscnt= 80
Recv: 0 step= 3 mscnt= 54
M925 Y1500
Recv: 0 step=35 mscnt= 569
Recv: 0 step= 3 mscnt= 54
Recv: 0 step=35 mscnt= 566
Recv: 0 step=51 mscnt= 825
Recv: 0 step=35 mscnt= 571
M925 Y2000
Recv: 0 step= 3 mscnt= 63
Recv: 0 step=51 mscnt= 828
Recv: 0 step= 3 mscnt= 63
Recv: 0 step= 3 mscnt= 57
Recv: 0 step=51 mscnt= 828
Recv: 0 step= 3 mscnt= 56
Recv: 0 step=51 mscnt= 827
M925 Y2200
Recv: 0 step=35 mscnt= 568
Recv: 0 step=36 mscnt= 577
Recv: 0 step=35 mscnt= 572
Recv: 0 step=36 mscnt= 577
Recv: 0 step=35 mscnt= 575
Recv: 0 step=36 mscnt= 580
Recv: 0 step=35 mscnt= 569
Recv: 0 step=35 mscnt= 571
Recv: 0 step=35 mscnt= 573
M925 Y2500
Recv: 0 step=35 mscnt= 570
Recv: 0 step=36 mscnt= 577
Recv: 0 step=35 mscnt= 573
Recv: 0 step=36 mscnt= 576
Recv: 0 step=36 mscnt= 579
Recv: 0 step=35 mscnt= 574
Recv: 0 step=36 mscnt= 577
Recv: 0 step=36 mscnt= 576
M925 Y3000
Recv: 0 step=35 mscnt= 573
Recv: 0 step=35 mscnt= 575
Recv: 0 step=35 mscnt= 574
Recv: 0 step=35 mscnt= 575
Recv: 0 step=35 mscnt= 575
Recv: 0 step=36 mscnt= 579
Recv: 0 step=36 mscnt= 576
Recv: 0 step=36 mscnt= 580
Notice that at 2000, the step values wander. Once we go fast than 2000, step values stabilize. That is the rate getting above resonance. Once we go faster than that, things don't stabilize much more, but we are bashing things together harder.
Repeat this for other threshold values and find a feed rate that is above resonance but not so high that you are tearing apart the printer.
Once you have that feed rate, do a stallguard threshold series at that non-resonance feed rate.
I get best for my particular OMC on Y at SG-threshold of 4 and feed rate 2500
RE: Tuning Homing for 0.9 Degree Motors
I should add that you can pretty quickly get multiple homing tests done with G28 [axis] C
like...
G28 Y C
That gets you 16 test samples
RE: Tuning Homing for 0.9 Degree Motors
Here are values from Moons 0.9 on X and threshold set to 4.
Notice that motor resonance rears its ugly head around a feed rate of 2750
I would therefore set the x-homing feed rate at 2250. That above the low impact step = 12 values, but below the resonance. Can't really get above the resonance speed without making the impacts stupid fast.
G28 X C
M924 X4
M925 X1000
Recv: i= 0 step=12
Recv: i= 1 step=12
Recv: i= 2 step=12
Recv: i= 3 step=12
Recv: i= 4 step=12
Recv: i= 5 step=12
Recv: i= 6 step=12
Recv: i= 7 step=12
Recv: i= 8 step=12
Recv: i= 9 step=12
Recv: i=10 step=12
Recv: i=11 step=12
Recv: i=12 step=12
Recv: i=13 step=12
Recv: i=14 step=12
Recv: i=15 step=12
M925 X1250
Recv: i= 0 step=12
Recv: i= 1 step=12
Recv: i= 2 step=12
Recv: i= 3 step=12
Recv: i= 4 step=12
Recv: i= 5 step=12
Recv: i= 6 step=12
Recv: i= 7 step=12
Recv: i= 8 step=12
Recv: i= 9 step=12
Recv: i=10 step=12
Recv: i=11 step=12
Recv: i=12 step=12
Recv: i=13 step=12
Recv: i=14 step=12
Recv: i=15 step=12
M925 X1500
Recv: i= 0 step=12
Recv: i= 1 step=12
Recv: i= 2 step=12
Recv: i= 3 step=12
Recv: i= 4 step=12
Recv: i= 5 step=12
Recv: i= 6 step=12
Recv: i= 7 step=12
Recv: i= 8 step=12
Recv: i= 9 step=12
Recv: i=10 step=12
Recv: i=11 step=12
Recv: i=12 step=12
Recv: i=13 step=12
Recv: i=14 step=12
Recv: i=15 step=12
M925 X1750
Recv: i= 0 step=12
Recv: i= 1 step=12
Recv: i= 2 step=12
Recv: i= 3 step=12
Recv: i= 4 step=12
Recv: i= 5 step=12
Recv: i= 6 step=12
Recv: i= 7 step=12
Recv: i= 8 step=12
Recv: i= 9 step=12
Recv: i=10 step=12
Recv: i=11 step=12
Recv: i=12 step=12
Recv: i=13 step=12
Recv: i=14 step=12
Recv: i=15 step=12
M925 X2000
Recv: i= 0 step=43
Recv: i= 1 step=44
Recv: i= 2 step=44
Recv: i= 3 step=44
Recv: i= 4 step=44
Recv: i= 5 step=44
Recv: i= 6 step=44
Recv: i= 7 step=44
Recv: i= 8 step=44
Recv: i= 9 step=44
Recv: i=10 step=44
Recv: i=11 step=44
Recv: i=12 step=44
Recv: i=13 step=44
Recv: i=14 step=44
Recv: i=15 step=44
M925 X2250
Recv: i= 0 step=43
Recv: i= 1 step=44
Recv: i= 2 step=44
Recv: i= 3 step=44
Recv: i= 4 step=44
Recv: i= 5 step=44
Recv: i= 6 step=44
Recv: i= 7 step=44
Recv: i= 8 step=44
Recv: i= 9 step=44
Recv: i=10 step=44
Recv: i=11 step=44
Recv: i=12 step=44
Recv: i=13 step=44
Recv: i=14 step=44
Recv: i=15 step=44
M925 X2500
Recv: i= 0 step=43
Recv: i= 1 step=43
Recv: i= 2 step=43
Recv: i= 3 step=43
Recv: i= 4 step=43
Recv: i= 5 step=43
Recv: i= 6 step=43
Recv: i= 7 step=44
Recv: i= 8 step=44
Recv: i= 9 step=44
Recv: i=10 step=44
Recv: i=11 step=44
Recv: i=12 step=44
Recv: i=13 step=44
Recv: i=14 step=44
Recv: i=15 step=44
M925 X2750
Recv: i= 0 step=11
Recv: i= 1 step=11
Recv: i= 2 step=11
Recv: i= 3 step=11
Recv: i= 4 step=11
Recv: i= 5 step=11
Recv: i= 6 step=12
Recv: i= 7 step=12
Recv: i= 8 step=12
Recv: i= 9 step=12
Recv: i=10 step=12
Recv: i=11 step=12
Recv: i=12 step=12
Recv: i=13 step=43
Recv: i=14 step=44
Recv: i=15 step=44
M925 X3000
Recv: i= 0 step=11
Recv: i= 1 step=12
Recv: i= 2 step=27
Recv: i= 3 step=27
Recv: i= 4 step=27
Recv: i= 5 step=27
Recv: i= 6 step=28
Recv: i= 7 step=28
Recv: i= 8 step=59
Recv: i= 9 step=59
Recv: i=10 step=59
Recv: i=11 step=59
Recv: i=12 step=59
Recv: i=13 step=59
Recv: i=14 step=60
Recv: i=15 step=60
RE: Tuning Homing for 0.9 Degree Motors
Are you using an o-scope to know when resonance and emf is becoming significant?
RE: Tuning Homing for 0.9 Degree Motors
No. I am only using the variance in steps value.
Mainly trying to help people who have trouble getting tuned and not much help if we require tools that only a few of use have.
You definitely can measure the steps variance increase when the Stallguard system starts to falter.
On x, if the the test sequence ends with a blurrrt motor noise, the belt is probably a little too loose.
RE: Tuning Homing for 0.9 Degree Motors
Here is another test set. This time with Moon's 0.9 on X. SGThreshold = 4. I take measurements varying homing rate by 100.
What I see is that from 1800 to 2200 feed rate SG is getting unstable step positions for home. This motor I would set up with a homing rate of 2300 to 2400.
====
Moons on X axis
M924 X4
G28 X C <-- this is the command that gets the data. The M925 Xnnn labels how feed rate was set before G28 X C
M925 X1500
Recv: i= 0 step=28
Recv: i= 1 step=28
Recv: i= 2 step=28
Recv: i= 3 step=28
Recv: i= 4 step=28
Recv: i= 5 step=28
Recv: i= 6 step=28
Recv: i= 7 step=28
Recv: i= 8 step=59
Recv: i= 9 step=60
Recv: i=10 step=60
Recv: i=11 step=60
Recv: i=12 step=60
Recv: i=13 step=60
Recv: i=14 step=60
Recv: i=15 step=60
M925 X1700
Recv: i= 0 step=59
Recv: i= 1 step=59
Recv: i= 2 step=60
Recv: i= 3 step=60
Recv: i= 4 step=60
Recv: i= 5 step=60
Recv: i= 6 step=60
Recv: i= 7 step=60
Recv: i= 8 step=60
Recv: i= 9 step=60
Recv: i=10 step=60
Recv: i=11 step=60
Recv: i=12 step=60
Recv: i=13 step=60
Recv: i=14 step=60
Recv: i=15 step=60
M925 X1800
Recv: i= 0 step=44
Recv: i= 1 step=44
Recv: i= 2 step=44
Recv: i= 3 step=44
Recv: i= 4 step=44
Recv: i= 5 step=44
Recv: i= 6 step=44
Recv: i= 7 step=44
Recv: i= 8 step=44
Recv: i= 9 step=60
Recv: i=10 step=60
Recv: i=11 step=60
Recv: i=12 step=60
Recv: i=13 step=60
Recv: i=14 step=60
Recv: i=15 step=60
M925 X1900
Recv: i= 0 step=28
Recv: i= 1 step=43
Recv: i= 2 step=44
Recv: i= 3 step=44
Recv: i= 4 step=44
Recv: i= 5 step=44
Recv: i= 6 step=44
Recv: i= 7 step=44
Recv: i= 8 step=44
Recv: i= 9 step=44
Recv: i=10 step=44
Recv: i=11 step=44
Recv: i=12 step=44
Recv: i=13 step=44
Recv: i=14 step=44
Recv: i=15 step=44
M925 X2000
Recv: i= 0 step=27
Recv: i= 1 step=28
Recv: i= 2 step=28
Recv: i= 3 step=28
Recv: i= 4 step=28
Recv: i= 5 step=28
Recv: i= 6 step=28
Recv: i= 7 step=28
Recv: i= 8 step=28
Recv: i= 9 step=28
Recv: i=10 step=28
Recv: i=11 step=28
Recv: i=12 step=28
Recv: i=13 step=44
Recv: i=14 step=60
Recv: i=15 step=60
M925 X2100
Recv: i= 0 step=12
Recv: i= 1 step=28
Recv: i= 2 step=28
Recv: i= 3 step=28
Recv: i= 4 step=28
Recv: i= 5 step=28
Recv: i= 6 step=28
Recv: i= 7 step=44
Recv: i= 8 step=44
Recv: i= 9 step=44
Recv: i=10 step=59
Recv: i=11 step=59
Recv: i=12 step=60
Recv: i=13 step=60
Recv: i=14 step=60
Recv: i=15 step=60
M925 X2200
Recv: i= 0 step=12
Recv: i= 1 step=12
Recv: i= 2 step=12
Recv: i= 3 step=12
Recv: i= 4 step=44
Recv: i= 5 step=44
Recv: i= 6 step=59
Recv: i= 7 step=59
Recv: i= 8 step=60
Recv: i= 9 step=60
Recv: i=10 step=60
Recv: i=11 step=60
Recv: i=12 step=60
Recv: i=13 step=60
Recv: i=14 step=60
Recv: i=15 step=60
M925 X2300
Recv: i= 0 step=59
Recv: i= 1 step=59
Recv: i= 2 step=60
Recv: i= 3 step=60
Recv: i= 4 step=60
Recv: i= 5 step=60
Recv: i= 6 step=60
Recv: i= 7 step=60
Recv: i= 8 step=60
Recv: i= 9 step=60
Recv: i=10 step=60
Recv: i=11 step=60
Recv: i=12 step=60
Recv: i=13 step=60
Recv: i=14 step=60
Recv: i=15 step=60
M925 X2400
Recv: i= 0 step=59
Recv: i= 1 step=59
Recv: i= 2 step=59
Recv: i= 3 step=59
Recv: i= 4 step=59
Recv: i= 5 step=59
Recv: i= 6 step=60
Recv: i= 7 step=60
Recv: i= 8 step=60
Recv: i= 9 step=60
Recv: i=10 step=60
Recv: i=11 step=60
Recv: i=12 step=60
Recv: i=13 step=60
Recv: i=14 step=60
Recv: i=15 step=60
M925 X2500
Recv: i= 0 step=59
Recv: i= 1 step=59
Recv: i= 2 step=59
Recv: i= 3 step=59
Recv: i= 4 step=59
Recv: i= 5 step=59
Recv: i= 6 step=59
Recv: i= 7 step=60
Recv: i= 8 step=60
Recv: i= 9 step=60
Recv: i=10 step=60
Recv: i=11 step=60
Recv: i=12 step=60
Recv: i=13 step=60
Recv: i=14 step=60
Recv: i=15 step=60
RE: Tuning Homing for 0.9 Degree Motors
Interesting. Do you know how this homing calibration plays into crash detection? So far I am getting reliable homes on 0.9 motors (using stock firmware values, no less), but false crash detects during a print :-/
RE: Tuning Homing for 0.9 Degree Motors
Crashes during print are detected using the TMC2130_SG_THRS_X, TMC2130_SG_THRS_Y, TMC2130_SG_THRS_Z, TMC2130_SG_THRS_E values. They are a separate set of threshold, distinct from the ones used during homing. How the 0.9's affect what values those will need, I have not investigated.
I'm always in stealth and simply don't use crash detection. From how I see SG behaving during homing, I'm surprised crash detection even works. You need a pretty big drag on the motor to trigger things.
RE: Tuning Homing for 0.9 Degree Motors
I suspect they may just need a slight nudge up for 0.9s; all the crashes I was observing (I think) were right after fast travel moves so my suspicion is that the back-EMF from slowdown/stop is very close to the threshold for a crash.
Y is naturally worse than X because it's got more mass.
Perhaps that's not even necessary though... I wonder if it might be sufficient to just drop the jerk value for 0.9 degree motors so there's less momentum involved in such a brake event.
RE: Tuning Homing for 0.9 Degree Motors
Sorry if I'm completely off track, but whilst trying to understand the firmware, I came across this in Marlin_main.cpp and tmc2130.cpp
and it refers to the number of fullsteps and babysteps during homing procedure.
uint8_t tmc2130_home_bsteps[2] = {48, 48};
uint8_t tmc2130_home_fsteps[2] = {48, 48};
Since the motor is now a 0.9 stepper, then should the 48 not be a 96?
Like I said, I'm learning, so dont shoot me down in flames if I have got this completely wrong.
Normal people believe that if it ainât broke, donât fix it. Engineers believe that if it ainât broke, it doesnât have enough features yet.
RE: Tuning Homing for 0.9 Degree Motors
Sorry, took a bit before circling back around to this.
Thanks. I think you are correct. The effect would be to halve some of the setup moves done during homing.
Updated my branch to switch the constants from 48 to 96 depending on whether X or Y are set to be 0.9 degrees in configuration_Prusa.h
Homing hits sound a bit more vigorous after the fix.
PLEASE READ BELOW
This correction also changes the steps at which printer is at homing position. Your old home position may be outside of the new legal dimensions. The effect of that is x-axis test will immediately fail if the first thing you do is self-test, but your print head is still outside the expected legal positions. That can happen if your head is at home when you first switch to firmware with this fix.
Solution is easy and only needs to be done ONCE. You won't have to do this again after printer passes self-test and stores its new homing position.
Manually push the x-axis about an inch to right of home or do a calibration/home BEFORE executing calibration/self-test. That puts the head into a position that allows self-test to succeed.
Definitely do a self-test after installing firmware with this homing steps fix. The self-test lets printer store its new home position under the new step constants.
RE: Tuning Homing for 0.9 Degree Motors
Nope. More testing across printers ---> homing is less reliable if the steps are set to 96.
Reverting back to 48.
RE: Tuning Homing for 0.9 Degree Motors
The change in steps count from 48 to 96 was a bust. It might actually be pedantically correct, but makes a mess for self-test and doesn't improve homing. However, this got bunny scientists working on the old homing issue. They made a change that should make it easier to tune homing.
In Marlin_main.cpp,
void homeaxis(int axis, uint8_t cnt) includes a check after each homing iteration testing the result against a lower count limit. If the measured position count is below 63, it errored out and we see the slow bed move.
Looking back through my measured test values for the count I found that 0.9 motors often cluster their homing values well below 63. My x-motors can cluster as low as 11 and the Y motor often is about 31. Unless belt tension and velocity were just right to get the result value above 63, homing fails.
Latest firmware in my branch now sets a lower acceptance limit of 10 if a 0.9 degree motor has been defined on X or Y.
#ifdef X_AXIS_MOTOR_09 //Kuo adjust min acceptable homing count for 0.9 motors
#define kHOMING_CNT_MIN 10 //0.9 motors often home at much lower count
#elif defined(Y_AXIS_MOTOR_09)
#define kHOMING_CNT_MIN 10
#else
#define kHOMING_CNT_MIN 63 //original was 63 for 1.8 motors
#endif //---Kuo
A corresponding change was made in Marlin_main.cpp to use the new constant.
RE: Tuning Homing for 0.9 Degree Motors
Kuo, you've defined kHOMING, but the define isn't used anywhere. The implementation is missing.
RE: Tuning Homing for 0.9 Degree Motors
Weird. Commit wasn't accepted apparently. Should be there now.
RE: Tuning Homing for 0.9 Degree Motors
Just finished replacing my PSU (Meanwell LRS-350-24, Now running at 26V, Printer reports 25.6v) and X & Y motors with OMC 17HM15-0904S 0.9 Deg steppers. Fitted heat sinks to rear and fronts of all stepper drivers and FET'S for Hot End and Heated Bed. Replaced EINSY case with revers case, Uprated the PSU wiring to Einsy board and extended stepper motor cables as they were too short.
Just about to download latest firmware from guy-2k, compile it and upload to printer. Tested all parts work with existing firmware for 1.8 Deg motors before hand (Move in correct direction and sensors all report back correctly), but of course X and Y only move half the distance.
Normal people believe that if it ainât broke, donât fix it. Engineers believe that if it ainât broke, it doesnât have enough features yet.