Overvoltage protection repeatedly counts stale VIN samples on hardware with multiplexed voltage sensing

Open
#976 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c
Domain
embedded-iot

Research direction

Start by reading mc_interface_mc_timer_isr() and tracing how GET_INPUT_VOLTAGE() obtains cached VIN samples on boards with multiplexed sensing. Compare the multiplexer acquisition cadence with voltage fault qualification, including both overvoltage and undervoltage behavior. Done means stale samples no longer qualify as repeated measurements while genuine faults retain an appropriate response time.

Written by the indexing model from the issue text.

Description

I'm seeing intermittent FAULT_CODE_OVER_VOLTAGE faults on my STR500 in seemingly benign operating conditions. While investigating, I noticed a potential issue in how voltage protection handles cached multiplexer readings. This may affect other VESC boards with multiplexed input-voltage sensing as well.

VESC hardware that measures input voltage through an analog multiplexer can repeatedly feed the same stored VIN sample into the voltage fault integrator. This can cause a single noisy reading to trigger FAULT_CODE_OVER_VOLTAGE.

The affected configuration is any board where GET_INPUT_VOLTAGE() returns a cached multiplexer reading that updates more slowly than the motor control loop.

Current behavior

The acquisition sequence typically looks like this:

ADCMUX_VIN();
chThdSleepMicroseconds(T_SAMP_US);
ADC_Value[ADC_IND_VIN_SENS] = ADC_Value[ADC_IND_ADC_MUX];

VIN remains unchanged while the multiplexer scans the other channels. Meanwhile, mc_interface_mc_timer_isr() evaluates that stored value on every call:

wrong_voltage_integrator += voltage_diff_now;

The fault threshold is 0.05 * l_max_vin. There is no check for a newly acquired VIN sample, and the accumulation does not use dt. Although a low-pass filter is updated nearby, the fault check uses the unfiltered voltage.

Example

An eight-channel scan with 400 µs per channel updates VIN approximately every 3.2 ms. At a 15 kHz control-loop frequency, each sample is evaluated approximately 48 times.

With l_max_vin = 60 V, one stored reading of 61 V produces integrator values:

1 → 2 → 3 → 4

The threshold is 3, so the fault triggers on the fourth evaluation—200 µs after the first, before another VIN measurement is available.

These timings illustrate the mechanism; actual sampling rates depend on the board and configuration.

Impact

One transient measurement error can appear to be sustained overvoltage. The same repeated-sample issue also affects undervoltage qualification.

This does not establish whether a particular high reading represents noise or a real voltage excursion.

Expected behavior

Voltage acquisition and fault qualification should account for the actual VIN sampling cadence while maintaining an appropriate response time to genuine voltage faults.

Possible improvements include:

  • Averaging independent ADC conversions while VIN is selected, after allowing the signal to settle.
  • Tracking sample freshness explicitly.
  • Defining fault qualification timing consistently with the measurement rate.

Simply processing only new VIN samples with the existing integrator threshold would substantially slow protection, so the threshold and timing would need to be considered together.

Dominant language
C
Stars
3.6k
Forks
2k
Avg merge
20h 29m
Merged PRs (30d)
12

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vedderb/bldc

All issues in vedderb/bldc

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.