Overvoltage protection repeatedly counts stale VIN samples on hardware with multiplexed voltage sensing
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
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vedderb/bldc
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
CAN_PACKET_FILL_RX_BUFFER(_LONG): a frame shorter than its header makes `len` negative before memcpyOpen
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
foc_sensor_mode from COMM_SET_MCCONF isn't range-checked, and the FOC ISR switch has no defaultOpen
Difficulty 3/5 1-2 days Newbie friendliness 58/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
deprecation:active impact:breaking-change
Difficulty 1/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Cisco-Talos/clamav#1957 ·
Maintainers usually reply within 1 day
-
Read-only client can close a dead pane (remain-on-exit key)Possibly taken @lingyicute claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
bug mod: quantum info
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Qiskit/qiskit#17699 · 2 comments ·
Maintainers usually reply within 1 day