Basic Information:
Printer Model: modified Cindy mill
MCU / Printerboard: BigTreeTech M8P (STM32H723)
Host / SBC Raspberry Pi CM4
I’m trying to use an analog joystick to jog my CNC router and I’m having the exact issues in lhelmig’s gamepad jogging video (sorry, can’t have > 2 links as new user)
This is the relevant printer.cfg for experiment 1. I also changed the ADC update rate (REPORT_TIME in adc_temperature.py) from 300 to 50ms.
[adc_temperature my_sensor_type]
voltage1: 0
temperature1:0
voltage2:5
temperature2:1
[temperature_sensor joystick_x]
sensor_type:my_sensor_type
sensor_pin:PF10
min_temp:0
max_temp:1
[temperature_sensor joystick_y]
sensor_type:my_sensor_type
sensor_pin:PC0
min_temp:0
max_temp:1
[delayed_gcode joystick_runner]
initial_duration: 0.1
gcode:
{% set x = printer[“temperature_sensor joystick_x”].temperature - 0.5 %}
{% set y = printer[“temperature_sensor joystick_y”].temperature - 0.5 %}
{% set magnitude = [0.001, (x * x + y * y) ** 0.5]|max %}
{% set dead_zone = 0.08 %}
{% if magnitude > dead_zone %}
G91
G1 X{x*8} Y{y*8}
{% endif %}
UPDATE_DELAYED_GCODE ID=joystick_runner DURATION=0.2
-
If the loop executes with duration=0.2, there is very little lag, but the moves are jerky, probably because the motion planner doesn’t have enough future moves, so deaccelerates after each.
experiment1.zip (9.3 MB)
-
If the loop executes every 0.1s (and lower X & Y multipliers from 8 to 4), the delay is 1s, but the motion is much smoother. Also it stutters.
experiment2.zip (9.4 MB)
I can totally understand the command queue getting full and block further commands from being issued, but that shouldn’t cause a 1s delay. It seems like when the joystick loop gets blocked, it prevents already issued commands from executing ![]()
Is there such a priority inversion? Regardless, any ideas on how to improve things?