Skip to content

fix(px4io): use VSERVO_SCALE register in servo rail voltage computation #26970

@mrpollo

Description

@mrpollo

The IO firmware (src/modules/px4iofirmware/registers.c:541) hardcodes the servo rail voltage conversion assuming a 3:1 divider:

unsigned mV = counts * 9900 / 4096;

A PX4IO_P_SETUP_VSERVO_SCALE register already exists in the protocol (protocol.h:171) and is initialized to 10000 (registers.c:140), but it's never actually used in the computation. It's dead code.

This matters because boards derived from the v6X reference design are shipping with different ADC divider ratios. For example, NewBeeDrone's PixNova uses an 11:1 divider (100K/10K) for 0-36V servo rail detection. With the current firmware, their voltage telemetry caps at ~9.9V regardless of actual input. PWM output is unaffected since it's completely decoupled from voltage sensing, so this is a telemetry-only issue, not safety-critical.

The fix should:

  1. Apply r_setup_page[PX4IO_P_SETUP_VSERVO_SCALE] in the voltage computation in registers.c
  2. Make the register writable from the FMU side so boards can set their own scale factor
  3. Keep the default at 10000 (equivalent to the current 3:1 / 9900mV behavior) for backwards compatibility

Also worth noting: VDD_SERVO_FAULT is defined in px4io.h:128 but never checked anywhere in the IO firmware.

Related: #26966 (NewBeeDrone PixNova board support)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions