Skip to content

Encoder Fix - FSM Quadrature State Machine

Latest

Choose a tag to compare

@RMSSimRacing RMSSimRacing released this 21 May 11:40
5d2a931

Encoder Fix - FSM Quadrature State Machine

Fixes multiple encoder issues in FreeJoy firmware.

Problems fixed

  • Ghost HID output when partially rotating and releasing the encoder
  • Lost pulses on EC11 encoders due to time and direction blocking
  • First step lost when quickly changing rotation direction

Solution

Replaced the original lookup table logic with a full quadrature FSM (Finite State Machine) for ENCODER_CONF_1x and ENCODER_CONF_2x modes.

  • Bounce rejection is handled automatically by the FSM
  • Direction changes are detected immediately without losing the first step
  • ENCODER_CONF_4x keeps the original enc_array_4 logic, required for encoders like the ALPS RKJXT1F42001

Modified files

  • application/Src/encoders.c
  • application/Inc/common_types.h (added fsm_state field to encoder_state_t struct)

Tested on

  • EC16 (ENCODER_CONF_1x)
  • EC11 (ENCODER_CONF_1x)
  • ALPS RKJXT1F42001 (ENCODER_CONF_4x)

Installation

Flash FreeJoy.bin using FreeJoy Configurator, or FreeJoy.hex using ST-Link or similar programmer.