Skip to content

Measured Current A/B not swapped in alignBLDCDriver() #556

Description

@woods1712

I found a typo where the measured current from phase B is swapped with itself instead of the current for phase A

Activity

  1. adeshsudhir commented on Aug 5, 2026

    @adeshsudhir

    I investigated this and I believe the issue is caused by the cached phase current not being updated after the A/B mapping is swapped.

    During alignment, the code swaps:

    • pinA <-> pinB
    • offset_ia <-> offset_ib
    • gain_a <-> gain_b

    However, the cached current is updated using:

    _swap(c_a.b, c_a.b);

    which is a no-op.

    Since c_a was captured before the remapping, I believe this should instead be:

    _swap(c_a.a, c_a.b);

    to keep the cached measurements consistent before the subsequent polarity check.

    If this reasoning is correct, I'd be happy to prepare a PR

  2. runger1101001 commented on Aug 6, 2026

    @runger1101001
    Member

    Good find, thank you! I will definitely fix this for the next release.

  3. added theissue type on Aug 6, 2026
  4. self-assigned this
    on Aug 6, 2026
  5. added this to the 2.4.1_Release milestone on Aug 6, 2026
  6. woods1712 commented on Aug 8, 2026

    @woods1712
    Author

    heads up @runger1101001, the same error exists in line 300 of the same file, where A and B are being switched due to _NC on phase B:

    else{ //phase A is not measured so put the _NC to the phase A if(_isset(pinA) && !_isset(pinB)){ SIMPLEFOC_DEBUG("CS: Switch A-(B)NC"); _swap(pinA, pinB); _swap(offset_ia, offset_ib); _swap(gain_a, gain_b); _swap(c_a.b, c_a.b); phases_switched = true; // signal that pins have been switched

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions