# Adding encoder feedback functionality

**URL:** <https://klipper.discourse.group/t/adding-encoder-feedback-functionality/12473>\
**Category:** Features\
**Created:** [December 21, 2023, 9:53am UTC](https://klipper.discourse.group/t/adding-encoder-feedback-functionality/12473 "2023-12-21T09:53:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ganesh](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@ganesh](https://klipper.discourse.group/u/ganesh)\
**Post date:** [December 21, 2023, 9:53am UTC](https://klipper.discourse.group/t/adding-encoder-feedback-functionality/12473/1 "2023-12-21T09:53:31Z")

</div>

I am using incremental encoder for getting feedback of my Z axis movement. I would like to know if it has moved or not. I would like be making it a loop if it has skipped a step.  
Below is link of incremental encoder which can be read using timer/QEI pins of STM32H723.

[https://www.cuidevices.com/product/motion-and-control/rotary-encoders/incremental/modular/amt13a-series](https://www.cuidevices.com/product/motion-and-control/rotary-encoders/incremental/modular/amt13a-series)

Can we add this feedback module for motor movement?

---

<div class="post-metadata">

**Author:** ![NexGen-3D](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/nexgen-3d/32/7509_2.png) [@NexGen-3D](https://klipper.discourse.group/u/NexGen-3D)\
**Post date:** [December 21, 2023, 12:55pm UTC](https://klipper.discourse.group/t/adding-encoder-feedback-functionality/12473/2 "2023-12-21T12:55:59Z")

</div>

+1

I too would love this feature, I designed my own optical based rotary encoder, but Klipper has very little support for these things, currently only support is for filamet motion detection in the extrude direction only.

---

<div class="post-metadata">

**Author:** ![EddyMI3D](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/eddymi3d/32/1981_2.png) [@EddyMI3D](https://klipper.discourse.group/u/EddyMI3D)\
**Post date:** [December 21, 2023, 2:17pm UTC](https://klipper.discourse.group/t/adding-encoder-feedback-functionality/12473/3 "2023-12-21T14:17:35Z")

</div>

Try this:

Disable your `[display]` section. Do not delete, just comment it out.  
Put the pins you have for the rotary encoder into the three macros below, restart Klipper and use the encoder.

You should get the messages in the terminal…

```auto
#[display]
#lcd_type: st7920
#display_group: _multiextruder_16x4
#cs_pin: PH1 
#sclk_pin: PA1 
#sid_pin: PH0 
#encoder_pins: ^PC4,^PC6
#click_pin: ^!PC2 

[gcode_button rot_1]
pin: ^PC4
press_gcode: M118 rot_1

[gcode_button rot_2]
pin: ^PC6
press_gcode: M118 rot_2

[gcode_button press]
pin: ^!PC2
press_gcode: M118 press

```

You must have enabled the `M118` command by putting `[respond]` into your klipper.config.

---

<div class="post-metadata">

**Author:** ![ganesh](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@ganesh](https://klipper.discourse.group/u/ganesh)\
**Post date:** [December 21, 2023, 4:22pm UTC](https://klipper.discourse.group/t/adding-encoder-feedback-functionality/12473/4 "2023-12-21T16:22:56Z")

</div>

I actually need 4 pins i. e. Signal from encoder is A+, A-, B+, B- and I need to connect to timer pins. It’s a square wave output which we get. That’s how this encoder works. May be different for other encoders. STM32H732 has ability to read encoder. So, I think we need make a module for this to have this functionality. Is there any guide/ help to make a module?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/klipper/original/1X/64419bf2aac6639e6ef5cef200dcd456b0a01ac3.png) [@system](https://klipper.discourse.group/u/system)\
**Post date:** [February 19, 2024, 4:23pm UTC](https://klipper.discourse.group/t/adding-encoder-feedback-functionality/12473/5 "2024-02-19T16:23:02Z")

</div>

Closed on February 19, 2024, 4:23pm UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
