« first day (1 day earlier)      last day (19 days later) » 

5:30 AM
And you get incremental encoders from US$1 to US$200+:
(1) Incremental encoder - AliExpress US$0.7

(2) 5V Smart Car Code Wheel Photoelectric Speed ​​Sensor - AliExpress US$3
3 hours later…
8:37 AM
Now let me comment on the code you listed in you question, as a partial answer of of your question of first of two things you don't understand, ie, why your motor makes less turns (Note 1) than you expected/calculated.
Note 1 - What you don''t understand, in other words, is this:
You count the number of steps moved and found no problem, but the number of turns or distance/degrees traveled is smaller.
The cause or crux of the matter of discrepancy between steps make and degrees traveled is this:
If you skim my code you might notice that I have more GPIO pins than yours. You have the basic GPIO pins for (1) Enable, (2) Direction, (3) Step pulse, But I have two more GPIOs pin m1, m2 to set microstepping resolution, from 1/8 to 1//32, or higher. Actually your advanced driver has four pins to set microstepping, m1, m2, m3, m4, and the resolution is much much higher, so for very high precision needed in medical and industrial applications (laser cutting a 1 cm tumor or IC wafer.
You might like to compare and contrast my code and yours:
# ========= ========= ========= ========= ========= ========= ========= =========
# *** TMC2130/2160/2208/2209/2225 Testing Functions ***

# ========= ========= ========= ========= ========= ========= ========= =========
# 5. TMC2225 Config/Functions

enblPinNum   = 20
dirPinNum    = 21
stepPinNum   = 22
ms1PinNum    = 26
ms2PinNum    = 27

# *** tmc2225 Functions ***

def testToggleTmc2225ControlPins():
    print('  Begin testToggleTmc2225ControlPins(), ...')
    toggleGpOutPinNumList([enblPinNum, dirPinNum, stepPinNum, ms1PinNum, ms2PinNum], \
Below is a complete listing of the code, showing how to do microStepping:
tmc2225 programming, test99: penzu.com/p/0bf511af
9:13 AM
The following code snippet shows the three (pink) statements commanding the motor to make three separate movement, by 2,000, 3000, and 3000 (1ms pulse width) step pulses. Before commanding the last move, the microstepping resolution is set higher to 1/8 (the green statement), resulting the driver/motor moving same number of steps, but less degrees/distance.
9:34 AM
And the Youtube video: youtu.be/lj0xFBAkzeI

« first day (1 day earlier)      last day (19 days later) »