Issue: RepRap Rotary Encoder doesn't work

Having a Velleman K8800 Vertex Delta printer. It’s based on RAMPS1.4 with a RepRap Smart Controller. Works fine with Marlin 1.x and 2.x.
We got nearly everything running. The rotary encoder button is working, also does Kill-switch and LCD.
Rotation of the knob is not detected. So I wonder how to debug the encoder functionality. Also the beeper doesn’t work.
I can’t see anything about those in klippy.log

Excerpt from the printers schematic:
2021-04-07_16-34

And here’s the config (from klippy.log)

#      1: config file

[pause_resume]

[display_status]

[gcode_macro CANCEL_PRINT]
rename_existing = kiauh_CANCEL_PRINT
gcode =
M220 S100 ; Reset Speed factor override percentage to default (100%)
M221 S100 ; Reset Extrude factor override percentage to default (100%)
G91 ; Set coordinates to relative
{% if printer.extruder.temperature >= 170 %}
G1 F1800 E-1 ; Retract filament 3 mm to prevent oozing
{% endif %}
;if all axis are homed, lift the hotend to leave room for hot filament to ooze and to keep it clear of the bed.
{% if printer.toolhead.homed_axes == “xyz” %}
G1 F6000 Z10 ; Move Z Axis up 10 mm to allow filament ooze freely
G90 ; Set coordinates to absolute
M84 ; Disable stepper motors
{% endif %}
;set part fan speed to zero.
M106 S0
;bed and hotend are left at the print temps in case I want to restart.

[gcode_macro PAUSE]
rename_existing = BASE_PAUSE
variable_extrude = 1.0
gcode =
{% set E = printer[“gcode_macro PAUSE”].extrude|float %}
{% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
SAVE_GCODE_STATE NAME=PAUSE_state
BASE_PAUSE
G91
G1 E-{E} F2100
G1 Z{z_safe} F900
G90
G1 X{x_park} Y{y_park} F6000

[gcode_macro RESUME]
rename_existing = BASE_RESUME
gcode =
{% set E = printer[“gcode_macro PAUSE”].extrude|float %}
G91
G1 E{E} F2100
RESTORE_GCODE_STATE NAME=PAUSE_state
BASE_RESUME

[board_pins arduino-mega]
aliases =
ar0=PE0, ar1=PE1, ar2=PE4, ar3=PE5, ar4=PG5,
ar5=PE3, ar6=PH3, ar7=PH4, ar8=PH5, ar9=PH6,
ar10=PB4, ar11=PB5, ar12=PB6, ar13=PB7, ar14=PJ1,
ar15=PJ0, ar16=PH1, ar17=PH0, ar18=PD3, ar19=PD2,
ar20=PD1, ar21=PD0, ar22=PA0, ar23=PA1, ar24=PA2,
ar25=PA3, ar26=PA4, ar27=PA5, ar28=PA6, ar29=PA7,
ar30=PC7, ar31=PC6, ar32=PC5, ar33=PC4, ar34=PC3,
ar35=PC2, ar36=PC1, ar37=PC0, ar38=PD7, ar39=PG2,
ar40=PG1, ar41=PG0, ar42=PL7, ar43=PL6, ar44=PL5,
ar45=PL4, ar46=PL3, ar47=PL2, ar48=PL1, ar49=PL0,
ar50=PB3, ar51=PB2, ar52=PB1, ar53=PB0, ar54=PF0,
ar55=PF1, ar56=PF2, ar57=PF3, ar58=PF4, ar59=PF5,
ar60=PF6, ar61=PF7, ar62=PK0, ar63=PK1, ar64=PK2,
ar65=PK3, ar66=PK4, ar67=PK5, ar68=PK6, ar69=PK7,
analog0=PF0, analog1=PF1, analog2=PF2, analog3=PF3, analog4=PF4,
analog5=PF5, analog6=PF6, analog7=PF7, analog8=PK0, analog9=PK1,
analog10=PK2, analog11=PK3, analog12=PK4, analog13=PK5, analog14=PK6,
analog15=PK7,
ml70=PG4, ml71=PG3, ml72=PJ2, ml73=PJ3, ml74=PJ7,
ml75=PJ4, ml76=PJ5, ml77=PJ6, ml78=PE2, ml79=PE6,
ml80=PE7, ml81=PD4, ml82=PD5, ml83=PD6, ml84=PH2,
ml85=PH7

[mcu]
serial = /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0
baud = 250000

[virtual_sdcard]
path = ~/virtual_sdcard

[stepper_a]
step_pin = ar54
dir_pin = ar55
enable_pin = !ar38
microsteps = 32
rotation_distance = 55
endstop_pin = ^!ar3
homing_speed = 50
angle = 210.359180
arm_length = 288.130000
position_endstop = 207.234478

[stepper_b]
step_pin = ar60
dir_pin = ar61
enable_pin = !ar56
microsteps = 32
rotation_distance = 55
endstop_pin = ^!ar14
angle = 328.370322
arm_length = 288.130000
position_endstop = 204.834818

[stepper_c]
step_pin = ar46
dir_pin = ar48
enable_pin = !ar63
microsteps = 32
rotation_distance = 55
endstop_pin = ^!ar66
angle = 90.000000
arm_length = 288.130000
position_endstop = 209.645362

[extruder]
step_pin = ar26
dir_pin = !ar28
enable_pin = !ar24
rotation_distance = 22.727
microsteps = 32
full_steps_per_rotation = 200
gear_ratio = 50:17
nozzle_diameter = 0.400
filament_diameter = 1.750
heater_pin = ar10
sensor_pin = analog13
sensor_type = NTC 100K beta 3950
min_temp = 0
max_temp = 295
control = pid
pid_kp = 29.611
pid_ki = 2.193
pid_kd = 99.936

[heater_bed]
heater_pin = PC1
sensor_type = ATC Semitec 104GT-2
sensor_pin = PK0
min_temp = 0
max_temp = 130
control = pid
pid_kp = 63.282
pid_ki = 2.526
pid_kd = 396.305

[printer]
kinematics = delta
max_velocity = 300
max_accel = 3000
max_z_velocity = 150
print_radius = 105.00
minimum_z_position = -2
delta_radius = 109.031288

[delta_calibrate]
radius = 75
speed = 25
horizontal_move_z = 25
height0 = 0.0
height0_pos = 24126.000,24126.000,24126.000
height1 = 0.0
height1_pos = 27319.400,27319.400,22109.400
height2 = 0.0
height2_pos = 23705.000,28916.000,23705.000
height3 = 0.0
height3_pos = 22022.000,26660.000,26660.000
height4 = 0.0
height4_pos = 23321.000,23321.000,27284.000
height5 = 0.0
height5_pos = 26096.800,22021.800,26096.800
height6 = 0.0
height6_pos = 28112.000,23535.000,23535.000

[probe]
pin = ar68
z_offset = 0.0
speed = 12.0
samples = 5
samples_tolerance_retries = 5

[bed_mesh]
speed = 12
horizontal_move_z = 5
mesh_radius = 75
mesh_origin = 0,0
round_probe_count = 9
algorithm = bicubic
bicubic_tension = 0.2
move_check_distance = 10
split_delta_z = .025
fade_start = 1
fade_end = 10

[fan]
pin = ar8

[controller_fan default_controller_fan]
pin = ar9

[display]
lcd_type = uc1701
contrast = 55
cs_pin = PA7
a0_pin = PA5
encoder_pins = ^!PH0, ^!PH1
click_pin = ^!PA1

[buttons]

[output_pin beeper]
pin = PH3

[output_pin led]
pin = PH4
pwm = True

[gcode_macro START_PRINT]
default_parameter_bed_temp = 60
default_parameter_extruder_temp = 190
gcode =
G90
SET_GCODE_OFFSET Z=0.0
G28
BED_MESH_CALIBRATE
G1 X0 Y90 Z1 F3000
M109 S{EXTRUDER_TEMP}
G1 E20 F100
G1 Z5 F3000
G1 Z0.15 F300

[gcode_macro END_PRINT]
gcode =
M104 S0
M106 S0
G91
G1 X-2 Y-2 E-3 F300
G1 Z10 F3000
G90
M84

[gcode_macro M851]
gcode =
G28
probe_calibrate

[gcode_macro G32]
gcode =
G28
delta_calibrate
G1 X0 Y0 F4200
save_config

[gcode_macro G29]
gcode =
G28
bed_mesh_calibrate
G1 X0 Y0 Z15 F4200
save_config

[gcode_macro M300]
default_parameter_s = 1000
default_parameter_p = 100
gcode =
SET_PIN PIN=BEEPER_pin VALUE={S}
G4 P{P}
SET_PIN PIN=BEEPER_pin VALUE=0

[bed_mesh default-25C]
version = 1
points =
-0.219574, -0.219574, -0.219574, -0.219574, -0.219574, -0.219574, -0.219574, -0.219574, -0.219574
-0.037017, -0.037017, -0.037017, -0.052022, -0.133269, -0.094081, -0.098984, -0.098984, -0.098984
0.018393, 0.018393, -0.040298, -0.022518, -0.019808, -0.032209, -0.015151, 0.209346, 0.209346
-0.017896, -0.017896, -0.022294, -0.035723, -0.018842, -0.007806, 0.037089, 0.221282, 0.221282
0.021724, -0.007815, -0.021689, -0.015027, -0.005815, 0.005924, 0.069866, 0.156410, 0.573575
-0.042181, -0.042181, -0.062293, -0.066384, -0.030364, -0.032531, 0.014503, 0.068030, 0.068030
-0.067965, -0.067965, -0.084220, -0.076400, -0.105514, -0.094768, -0.078881, -0.050111, -0.050111
-0.118173, -0.118173, -0.118173, -0.108442, -0.150268, -0.149843, -0.192007, -0.192007, -0.192007
-0.034559, -0.034559, -0.034559, -0.034559, -0.034559, -0.034559, -0.034559, -0.034559, -0.034559
tension = 0.2
mesh_x_pps = 2
algo = bicubic
min_x = -75.0
min_y = -74.99
y_count = 9
mesh_y_pps = 2
x_count = 9
max_x = 75.0
max_y = 75.0

[bed_mesh Bed@75C]
version = 1
points =
-0.135356, -0.135356, -0.135356, -0.135356, -0.135356, -0.135356, -0.135356, -0.135356, -0.135356
0.014545, 0.014545, 0.014545, -0.007334, -0.014676, -0.052831, -0.014765, -0.014765, -0.014765
0.145581, 0.145581, 0.059390, 0.011857, 0.013288, -0.006428, 0.024380, 0.248878, 0.248878
0.017172, 0.017172, 0.010363, 0.003809, 0.065376, 0.081569, 0.074902, 0.260813, 0.260813
0.071567, 0.026560, 0.029873, 0.009036, 0.023404, 0.069517, 0.095647, 0.177035, 0.790138
0.016256, 0.016256, -0.027918, -0.040603, 0.012605, 0.020750, 0.066066, 0.098968, 0.098968
0.011098, 0.011098, -0.049845, -0.050619, -0.014420, -0.034612, -0.044506, 0.059889, 0.059889
-0.075205, -0.075205, -0.075205, -0.074067, -0.127924, -0.113749, -0.159351, -0.159351, -0.159351
-0.027684, -0.027684, -0.027684, -0.027684, -0.027684, -0.027684, -0.027684, -0.027684, -0.027684
tension = 0.2
min_x = -75.0
algo = bicubic
y_count = 9
mesh_y_pps = 2
min_y = -74.99
x_count = 9
max_y = 75.0
mesh_x_pps = 2
max_x = 75.0

[bed_mesh default]
version = 1
points =
-0.099262, -0.099262, -0.099262, -0.099262, -0.099262, -0.099262, -0.099262, -0.099262, -0.099262
0.054077, 0.054077, 0.054077, 0.025322, 0.021418, -0.013300, 0.028203, 0.028203, 0.028203
0.178237, 0.178237, 0.116109, 0.111545, 0.059255, 0.094978, 0.120630, 0.247159, 0.247159
0.108266, 0.108266, 0.089425, 0.072559, 0.089439, 0.115944, 0.148808, 0.267688, 0.267688
0.112817, 0.069529, 0.064248, 0.101848, 0.114498, 0.115924, 0.140335, 0.189066, 0.800450
0.071256, 0.071256, 0.047707, 0.067678, 0.067605, 0.080906, 0.100441, 0.150530, 0.150530
0.057504, 0.057504, 0.044687, 0.040475, 0.016517, 0.018669, 0.044869, 0.066764, 0.066764
-0.004736, -0.004736, -0.004736, -0.020785, -0.024799, -0.072499, -0.133569, -0.133569, -0.133569
0.114972, 0.114972, 0.114972, 0.114972, 0.114972, 0.114972, 0.114972, 0.114972, 0.114972
tension = 0.2
min_x = -75.0
algo = bicubic
y_count = 9
mesh_y_pps = 2
min_y = -74.99
x_count = 9
max_y = 75.0
mesh_x_pps = 2
max_x = 75.0

[bed_mesh Bed@75-Noz@215]
version = 1
points =
-0.099262, -0.099262, -0.099262, -0.099262, -0.099262, -0.099262, -0.099262, -0.099262, -0.099262
0.054077, 0.054077, 0.054077, 0.025322, 0.021418, -0.013300, 0.028203, 0.028203, 0.028203
0.178237, 0.178237, 0.116109, 0.111545, 0.059255, 0.094978, 0.120630, 0.247159, 0.247159
0.108266, 0.108266, 0.089425, 0.072559, 0.089439, 0.115944, 0.148808, 0.267688, 0.267688
0.112817, 0.069529, 0.064248, 0.101848, 0.114498, 0.115924, 0.140335, 0.189066, 0.800450
0.071256, 0.071256, 0.047707, 0.067678, 0.067605, 0.080906, 0.100441, 0.150530, 0.150530
0.057504, 0.057504, 0.044687, 0.040475, 0.016517, 0.018669, 0.044869, 0.066764, 0.066764
-0.004736, -0.004736, -0.004736, -0.020785, -0.024799, -0.072499, -0.133569, -0.133569, -0.133569
0.114972, 0.114972, 0.114972, 0.114972, 0.114972, 0.114972, 0.114972, 0.114972, 0.114972
tension = 0.2
min_x = -75.0
algo = bicubic
y_count = 9
mesh_y_pps = 2
min_y = -74.99
x_count = 9
max_y = 75.0
mesh_x_pps = 2
max_x = 75.0

Any ideas where to start looking? I’m having the same issue

It’s hard to say why that would be. Typically this is the result of an incorrect pin configuration. If you’re looking to debug it, you could remove those pins from the display section and add them to [gcode_button] config sections that report each time the pin changes value. For example, something like:

[gcode_button test_pin1]
pin: ^PH0
press_gcode: {action_respond_info("test_pin1 press")}
release_gcode: {action_respond_info("test_pin1 release")}

And then see if you’re getting any changes all on the given pins.

Cheers,
-Kevin

Pin definition:

[gcode_button test_ph0]
pin: ^PH0
press_gcode: {action_respond_info(“pin PH0 press”)}
release_gcode: {action_respond_info(“pin PH0 release”)}

[gcode_button test_ph1]
pin: ^PH1
press_gcode: {action_respond_info(“pin PH1 press”)}
release_gcode: {action_respond_info(“pin PH1 release”)}

Result directly after restart firmware:

pin PH0 press
pin PH1 press

That are the results when turning the encoder by two consecutive clicks:

pin PH0 release
pin PH1 release
pin PH0 press
pin PH1 press
Stats 503117.2: gcodein=0 mcu: mcu_awake=0.009 mcu_task_avg=0.000095 mcu_task_stddev=0.000074 bytes_write=5032 bytes_read=8854 bytes_retransmit=9 bytes_invalid=6 send_seq=237 receive_seq=237 retransmit_seq=2 srtt=0.003 rttvar=0.000 rto=0.025 ready_bytes=0 stalled_bytes=0 freq=15999644 heater_bed: target=0 temp=20.3 pwm=0.000 sysload=0.03 cputime=8798.235 memavail=2375776 print_time=0.001 buffer_time=0.000 print_stall=0 extruder: target=0 temp=19.1 pwm=0.000
pin PH0 release
pin PH1 release
pin PH0 press
pin PH1 press

(btw… how to I attach a text file?)

Looks about right. Are you sure the rotary encoder doesn’t work? (When you enter the menu by the click button, what happens when you turn the rotary wheel?)

FYI, there is an “upload” icon when editing a message.

-Kevin

Clicking the button opens up the menu, showing


OctoPrint >
SD Card >
Control >

Turning the button (left or right) doesn’t do anything. I also don’t see any kind of prompt showing the current cursor position.
Pressing the button again will end the menu and show the main status display.

I did not customize the menu.

So, how should we continue? Buttons are detected, but menu doesn’t work.
Opening an GitHub issue?

Alas, I don’t know why it doesn’t work. Someone with the hardware and some programming knowledge will have to add debugging to the code to find out what’s going wrong. For those interested, the key files are klippy/extras/buttons.py and klippy/extras/display/menu_keys.py .

-Kevin

I’d give it a try - as soon as I know where to start…
My first trial by adding a simple logging.debug statement to button.py didn’t show anything in klippy.log when pushing or turning the encoder button.

def register_rotary_encoder(self, pin1, pin2, cw_callback, ccw_callback):
logging.debug(
“register_rotary_encoder: pin1=‘%s’, pin2=‘%s’” % (pin1, pin2,))
re = RotaryEncoder(cw_callback, ccw_callback)

Fixed with Fix rotary encoder handling - resurrection of #730 by susisstrolch · Pull Request #4202 · KevinOConnor/klipper · GitHub.