Specifying TMC2209 parameters (Including sensorless homing) on a "MANUAL STEPPER"

Basic Information:

Printer Model: Functional Tester
MCU / Printerboard: Custom TMC2209 board
Host / SBC: Raspberry Pi CM4
klippy.log (1.7 MB) NOTE: Klipper is identified as “dirty” because I’m using DynamicMacros, otherwise it’s stock.

I’m just finishing up my functional test - everything is working on a basic level but I wanted to see if I could get non-specific stepper operation (as opposed to having steppers specified to different axes).

I want to use “manual_stepper” as detailed here with a TMC2209 driver:

With the “MANUAL_STEPPER" G-Code Commands:

For the tests, I need the ability to sensorless home (“MANUAL_STEPPER STEPPER=config_name STOP_ON_ENDSTOP=1") and then move to a specific location to return the stepper to position for the next test run (“MANUAL_STEPPER STEPPER=config_name SET_POSITION=<pos>").

I’m trying to define the manual_stepper the same way I’d define a TMC2209 stepper on an axis:

[manual_stepper stepper_1]
step_pin: PC10
dir_pin: !PC11
enable_pin: !PB9
microsteps: 16
rotation_distance: 40
velocity: 1000
accel: 1000
endstop_pin = tmc2209_stepper_1:virtual_endstop
position_min: -2
position_max: 225
[tmc2209 stepper_1]
uart_pin: PC15
uart_address: 1
diag_pin: PC13
run_current: 0.580
stealthchop_threshold: 999999
driver_SGTHRS: 70

Klipper doesn’t seem to like the “[tmc2209 stepper_1]” statement, no matter how I configure it and it definitely doesn’t like it when I configure it as the virtual endstop.

Am I doing something that can’t be done or is there something wrong with how I’m defining things?

Thanx!

Hi @mykepredko ,

The TMC section for your example would be:

[tmc2209 manual_stepper stepper_1]

For the virtual end stop, it would be:

tmc2209_manual_stepper_stepper_1:virtual_endstop

Okay, I found this thread:

Which discusses manual_stepper- it seems that the [tmc2209 statement in printer.cfg must first and the endstop_pin parameter must have a colon instead of an equals sign.

Changing the definition above to:

[tmc2209 manual_stepper stepper_1]
uart_pin: PC15
uart_address: 1
diag_pin: PC13
run_current: 0.300
stealthchop_threshold: 999999
driver_SGTHRS: 70
[manual_stepper stepper_1]
step_pin: PC10
dir_pin: PC11
enable_pin: !PB9
microsteps: 16
rotation_distance: 40
velocity: 25
accel: 1000
endstop_pin: tmc2209_stepper_1:virtual_endstop
position_min: -200
position_max: 225

Doesn’t get the Klipper error but I’m having problems getting the MANUAL_STEPPERG-Code commands working properly. Note that I changed the run_current and velocity parameters to match what I use with sensorless homing on the axis steppers.

For example:

MANUAL_STEPPER STEPPER=stepper_1 MOVE=10 STOP_ON_ENDSTOP=1

Causes the stepper to move to the endstop but it does not move back afterwards.

When I try a set position command:

MANUAL_STEPPER STEPPER=stepper_1 SET_POSITION=10

Nothing happens.

I can disable the driver using:

MANUAL_STEPPER STEPPER=stepper_1 ENABLE=0

Which does turn off the stepper driver.

But when I again try:

MANUAL_STEPPER STEPPER=stepper_1 MOVE=10 STOP_ON_ENDSTOP=1

I get the error:

No trigger on manual_stepper stepper_1 after full movement

Here is the sequence:

Any suggestions on how to get movement as I am expecting (ie to move like a stepper defined as an axis)?

Thanx.

The MOVE parameter in a homing move only tells it the maximum it will try to move to the endstop. You’d have to issue another move command after to move it away from the endstop.

That just tells the stepper it’s at position 10. It doesn’t actually move it. If you were to issue a command after with MOVE=0, it would move -10mm.

I would put an ENABLE=1 on the homing move to re enable the stepper.

Hopefully that explains things a bit better.

Thanx for the reply but I’m still not seeing what I’m expecting.

I tried:

MANUAL_STEPPER STEPPER=stepper_1 ENABLE=0

followed by:

MANUAL_STEPPER STEPPER=stepper_1 MOVE=10 STOP_ON_ENDSTOP=1 ENABLE=1

With no movement and the message: “No trigger on manual_stepper stepper_1 after full movement”

The stepper motor driver is engaged.

Just running:

MANUAL_STEPPER STEPPER=stepper_1 ENABLE=0

and:

MANUAL_STEPPER STEPPER=stepper_1 ENABLE=1

Does disengage/engage the stepper.

Movement commands like:

MANUAL_STEPPER STEPPER=stepper_1 MOVE=15

Work fine.

Now, when I try the homing command, everything seems okay…except for:


One thing for you specifically; when I try to read registers using the Dynamic Macro READ_TMC_FIELD it works fine for the axis drivers but doesn’t recognize the MANUAL_STEPPER driver:

Am I doing something wrong here?

Those commands would tell Klipper to:

  1. Disable stepper
  2. Enable stepper
  3. Attempt to home by moving 10mm.

The error indicates that the sensor less homing never triggered. I would increase the sgthrs value to make sensor less more sensitive.

To make it home then move 10mm:

MANUAL_STEPPER STEPPER=stepper_1 ENABLE=1 MOVE=50 STOP_ON_ENDSTOP=1
MANUAL_STEPPER STEPPER=stepper_1 ENABLE=1 MOVE=-10 SET_POSITION=0

That should tell Klipper to:

  1. Enable stepper
  2. Move up to 50mm to home
  3. Move -10mm after homing

Can you try passing STEPPER="manual_stepper stepper_1" to that command?

1 Like

Okay, I think I see what I’m doing wrong here. A few things here:

  • I have to think about the space the movement takes place. I had it set to -200 to 250 thinking that movements were relative, not to an absolute position. I have to rethink how I’m setting this up as I have less than one turn of the stepper available to me with the test hardware. I’m pretty sure I can get something working correctly here for the test.

  • I think there’s an issue with not resetting the StallGuard registers before issuing a subsequent move looking to home. In the sequence below, I have done a homing operation and then turned off the stepper by first using the command MANUAL_STEPPER=stepper_1 ENABLE=1 MOVE=10 STOP_ON_ENDSTOP=1and then turn it off using the “Engine Off” icon in the Toolhead Window. Then I do the homing operation again (which there is no movement) and get the response:

  • I’m not 100% sure that movements to a negative position works correctly. If I do a SETPOSTION=0 then a MOVE=5 and then a MOVE=-5 the stepper is at the SETPOSITION=0 point, not -5. It seems to be moving to positions relative to the last movement, not to what I would think is the absolute position.


Using `STEPPER=”manual_stepper stepper_1” seems to do the trick:

Can you comment on what I’m seeing with not being able to repeat MOVE with ENDSTOP and the MOVE commands to positive and negative values?

Thanx - you’ve been a big help.

1 Like

Okay, I think I’m on the right road.

I should have put in the test apparatus - it’s a simple striker arm attached to the stepper output shaft that comes into contact on a plate with a post that’s attached to the body of the stepper motor:

The test simply consists of moving the striker arm to the post so that sensorless homing is engaged and then moving the post back the original position to prepare it for the next test.

The verification test that I just ran through the four stepper drivers on two boards is:

  1. Get the initial SG_RESULT register contents using “READ_TMC_FIELD FIELD=sg_result STEPPER=“manual_stepper stepper_#”" command where “#” is the stepper number (from 0 to 3). This produces different results for each of the steppers which leads me to the note below.
  2. Home the stepper arm to the post using “MANUAL_STEPPER STEPPER=stepper_# ENABLE=1 MOVE=10 STOP_ON_ENDSTOP=1" command.
  3. Repeat step 1. which produces a value which is different from the value in step 1. as well as being different for all four stepper drivers.
  4. Move the stepper arm away from the post using the command “MANUAL_STEPPER STEPPER=stepper_# ENABLE=1 MOVE=-5"
  5. Move the stepper arm towards the post using the command “MANUAL_STEPPER STEPPER=stepper_# ENABLE=1 MOVE=5"
  6. Repeat step 1. which produces a value which is different from the value in steps 1. and 4. as well as being different for all four stepper drivers.
  7. Repeat step 2.
  8. Repeat step 1. which produces a value which is different from the value in steps 1., 4. and 6. as well as being different for all four stepper drivers.

So, I think I’m good. The actions of the commands are repeatable across different devices.

Now, two things:

  1. I have to figure out the best position settings for the test apparatus. Just playing around with it now, I believe that a position_max of 40 and a position_minof 0 will give me proper operation, regardless of where the striker arm is when the test starts.
  2. I have to look at the TMC2209 datasheet and figure out a better register to read to determine whether or not the sensorless homing worked correctly.

Thanx for your help and patience with me.

I think the issue is that you’re doing SETPOSITION, not SET_POSITION with an underscore. Let me know if that works.

Great!

The endstop issue is strange…the main thing I would try is doing an ENABLE=1 command, then in a separate command initiate the homing move.

Hey,

I think using SETPOSITION instead of SET_POSITION was the cause of the issues. I’m using it correctly now and not seeing a problem.

Thanx again for your help,

myke

2 Likes