Servo moving after setting `WIDTH=0`

Basic Information:

Printer Model: Voron Trident 300
MCU / Printerboard: Octopus v1.0
Host / SBC: Rpi 4

Hi!
I’m trying to set up a servo (MG90S).

Servo setup:

[servo nozzle_park]
pin: PB6
minimum_pulse_width: 0.00025
maximum_pulse_width: 0.0024

Macros:

[gcode_macro NOZZLE_PARK_STOW]
gcode:
  SET_SERVO SERVO=nozzle_park ANGLE=123
  G4 P500
  SET_SERVO SERVO=nozzle_park WIDTH=0

[gcode_macro NOZZLE_PARK_ACTIVATE]
gcode:
  SET_SERVO SERVO=nozzle_park ANGLE=33
  G4 P500
  SET_SERVO SERVO=nozzle_park WIDTH=0

So the idea is that when I call NOZZLE_PARK_ACTIVATE the nozzle park arm will turn and after NOZZLE_PARK_STOW it will hide.
I’m using SET_SERVO SERVO=nozzle_park WIDTH=0 to disable PWM signal to extend the life of the servo.

The problem I’m experiencing is that NOZZLE_PARK_ACTIVATE work as expected, but after calling NOZZLE_PARK_STOW the servo goes to an expected position (123 degrees), but after G4 P500 completes it goes to an angle of about 80 degrees.
This behavior is always repeatable and it’s always the same angle.
It doesn’t matter what is the value of G4 is. If I set it to G4 P5000 the servo will go to the desired angle and then go to an 80 degree angle after 5 seconds.
What’s interesting is that if I execute:

  SET_SERVO SERVO=nozzle_park ANGLE=123

and then

SET_SERVO SERVO=nozzle_park WIDTH=0

from console the issue is not there.
It only appears when the commands are run from the macro.

Any ideas what might be happening here and how I can fix it?

Sounds strange. Does it change when you do something like:

[gcode_macro SERVO_PWM_OFF]
gcode:
  G4 P500
  SET_SERVO SERVO=nozzle_park WIDTH=0

[gcode_macro NOZZLE_PARK_STOW]
gcode:
  SET_SERVO SERVO=nozzle_park ANGLE=123
  SERVO_PWM_OFF

[gcode_macro NOZZLE_PARK_ACTIVATE]
gcode:
  SET_SERVO SERVO=nozzle_park ANGLE=33
  SERVO_PWM_OFF

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