National High-Tech Enterprise IEC 61000 EMC · IEC 60730 Class B · RoHS ISO 9001 certified Jinhua, Zhejiang · around 200 staff · 25 in R&D
TECHNICAL NOTE 01 / 22

23-FOC Motor Control: Single-Shunt Sensing Offset Compensation

Sailike R&DFOC technical notes 中文原文

2026-09-19

Single-shunt sensing replaces two current-sensing channels with one shunt resistor, at the price that "the current that is measured" and "the current the current loop needs" are not the same quantity: the former is the instantaneous DC bus current at a given switching state and a given instant, the latter is the average value of the phase current over this switching period. The difference is not noise but a deterministic offset uniquely determined by the switching geometry, and its magnitude spans a wide range: on machines with high inductance and a low DC bus voltage it may be only a few tenths of an ampere, while on machines with low inductance and a relatively wide sampling window (dominated by dead time and settling time) it can reach several amperes. Whatever its size, it is independent of current amplitude, synchronized with the sector, and enters the current loop, the observer and the torque directly. Without relying on any particular implementation, this article explains the offset in the order "structural constraints of single-shunt sensing → origin of the offset → offset modeling → direct compensation → simplified compensation → summary".

Notation. To avoid ambiguity, all symbols are collected here first (local first appearances are explained in place). Every time quantity is expressed in "counts", i.e. in timer counts within one switching period. Correspondingly, the current slope is read as "current change per count": Vdc/(3Ls) is originally a quantity in "amperes/second", and throughout this article it is used as "amperes/count" (the two differ only by the constant factor "how many seconds one count corresponds to", omitted consistently throughout). Time, slope and current are then self-consistent in units, and no additional conversion factors appear in the equations.

Time and counts

  • ** T **: one switching period
  • ** P **: half-period count, T=2P (peak count of center-aligned PWM)
  • ** τ **: time variable within the period, τ∈[0,T]
  • ** ts **: sampling instant (relative to the period start)
  • ** d=ts−P **: offset of the sampling instant relative to the period midpoint, d>0 meaning later
  • ** dj **: d of the j -th sampling window, j=1,2
  • ** Δt **: offset of the sampling instant relative to the mean position of the ripple, in counts (under center-aligned, approximately symmetric modulation this is the absolute value of d ; used only for the magnitude discussion in §b)
  • ** ⟨·⟩ **: average over one switching period
  • ** clamp(x,0,P) **: x clamped to [0,P] , taking the end value when out of range

Switching states and current slopes

  • ** sXsw∈{0,1} **: whether the high-side switch of phase X is on
  • ** non **: number of currently conducting phases (1, 2 or 3)
  • ** kX=3sXsw−non **: sign weight of the current slope of phase X , value {−2,−1,0,1,2} ; the sum over the three phases is identically 0 (proof in §c(1))
  • ** X **: phase index (one of A , B , C ); in the compensation equations it denotes the phase currently being measured
  • ** Y **: phase index, used only as a summation dummy over the three phases ( Y is used to distinguish it from the measured phase X )
  • ** i˙X=diX/dt **: current slope of phase X
  • ** U3L=(Vdc/3)/Ls **: slope scale, the order of magnitude of the current slope associated with one switching state (in the "per count" convention above)
  • ** s¯, s^ **: period-average and zero-mean fluctuation parts of the slope, i˙=s¯+s^
  • ** F(τ)=∫0τi˙(σ)dσ : accumulation in the current convention** (dimension of Δi ); F^ is the part corresponding to s^
  • ** k¯ **: period average of k , k¯=K0/T
  • ** Φ(τ)=∫0τk(σ)dσ : accumulation in the k convention**, containing switching-state information only; its zero-mean part is Φ^(τ)=Φ(τ)−k¯τ , and F^=U3LΦ^ always holds

Currents and offsets

  • ** iX **: phase current of phase X
  • ** ⟨iX⟩ **: average of iX over one switching period, i.e. the quantity the current loop actually needs
  • ** if, r **: fundamental and switching-ripple components of the phase current (approximately linear within one period / zero mean over one period)
  • ** r(ts) **: instantaneous ripple value at the sampling instant, also the dominant term of the offset
  • ** r^ **: zero-mean part of the ripple, r^=r−⟨r⟩ (because ⟨r⟩=0 , it differs from r by a constant only)
  • ** ΔiX **: correction to be added to the sampled value so that iX(ts)+ΔiX=if,X(ts)
  • ** iα,iβ ; id,iq **: currents in the two-phase stationary / rotor reference frame (used to explain the 6th harmonic)

Geometric and electrical parameters

  • ** a **: turn-on count of a phase in the up-counting half period (compare value)
  • ** b **: turn-off count of a phase in the down-counting half period (compare value)
  • ** pa=P−a **: counts already on in the up-counting half period
  • ** pb=P−b **: counts still on in the down-counting half period
  • ** AX(T) **: on-counts of phase X over the whole period, i.e. the conduction "area"
  • ** MX(T)=∫τsXswdτ **: first moment of the conduction area with respect to time
  • ** AX(ts) **: conduction area from the period start up to the sampling instant
  • ** Q0,Q1,Q2 **: common symbol for the three quantities above: Q0=A(T) , Q1=M(T) , Q2=A(ts) (one set per sampling window, distinguished by j )
  • ** K0,K1,K2 **: the three single-integral quantities of k after three-phase differencing (three times the measured phase minus the sum of the three phases): Kn=3Qn(X)−∑YQn(Y)
  • ** br **: normalized correction, in time counts, ΔiX=U3Lbr
  • ** Vdc **: DC bus voltage
  • ** Ls **: phase inductance (the model usually takes the average inductance (Ld+Lq)/2 )
  • ** eX **: back-EMF of phase X
  • ** R **: phase resistance
  • ** ΔvX **: equivalent voltage loss caused by dead time, device drops, etc.

a. Single-shunt sensing: principle and structural constraints

Field-oriented control needs three phase currents. The three-shunt and two-shunt schemes place sensing resistors in the lower arms, so what is measured is the phase current itself; the single-shunt scheme places one resistor only in the DC bus path and reconstructs the three phase currents from the fact that "the bus current equals a different phase current in different switching states". The choice between the three topologies is a choice between cost and information:

SchemeHardwareCharacteristics
Three-shunt3 shunts, 3 op-amps, 3 ADCsSynchronous three-phase sampling, ample windows, highest cost
Two-shunt2 shunts, 2 op-amps, 2 ADCsThird phase derived from ic=−ia−ib
Single-shunt1 shunt, 1 op-amp, 1 ADCLowest cost, full three-phase reconstruction

Measurability criterion. Let sXsw∈{0,1} denote whether the high-side switch of phase X is on and non the number of conducting phases; define

kX=3sXsw−non∈{−2,−1,0,1,2}

then the bus current equals that phase current only when |kX|=2 :

  • kX=+2 : phase X is the only conducting phase, and the bus current is exactly iX ;
  • kX=−2 : phase X is the only non-conducting phase, and the shunt then carries the sum of the return currents of the other two phases, that is −iX — the sign must be flipped to recover that phase current, which is the most error-prone step in single-shunt reconstruction.

Among the 24 phase-state combinations (eight switching states times three phases), only 6 satisfy |kX|=2 (each of the six non-zero vectors contributes one). A switching period passes through only two of those non-zero vectors, so at most two phases can be measured directly in one period, and the third phase can only be derived from ∑XiX=0 .

Window constraint. The bus current is usable only in those two states, so a single-shunt design must guarantee two sufficiently wide measurable windows in every switching period. At low modulation the active vectors act for very short times and cannot meet the minimum window width; in practice this is solved by phase shifting (pulse shifting): the two active vectors are each pulled towards the two ends of the period and their action time is enlarged, while the central zero vector is compressed and distributed to the two ends, so that the originally unusable short stretch becomes a usable window. Once the windows are fixed, the sampling instant is in principle taken at the window centre (equivalent to the centre of the active-vector segment), and a minimum window width is enforced, so that the maximum output duty cycle is limited to a value below 1.

What phase shifting really does is borrow volt-seconds; it is not a mere rearrangement of time. To bring the measurable segment up to the minimum window, the action time of a non-zero vector is lengthened, and the extra volt-seconds must be deducted elsewhere, usually in the interval corresponding to the other half period (or in the zero vector). Therefore:

  • The period-average voltage is unchanged — borrowed and returned volt-seconds cancel within the period, which is the precondition for using phase shifting: the fundamental voltage, that is the average of the current, is unaffected;
  • But the instantaneous current is not zero — in the lengthened segment the current follows the slope of that state, and in the segment where the volt-seconds are returned it goes back in the opposite direction. The net change over the period is zero and the average current is unchanged, yet the instantaneous deviation is set by the lengthening amount, whose lower bound is exactly the minimum window (dead time + op-amp settling time + ADC sample-and-conversion time) and has nothing to do with the "wanted voltage".

This is most visible at low modulation: as the commanded voltage approaches zero, the ideal waveform should be nearly a flat line; after phase shifting, each half period contains a lengthened interval, and their current responses run in opposite directions and cancel within the period — the average value is still that very small commanded value, while the instantaneous value deviates noticeably in both the positive and the negative direction. In other words, at low modulation the fluctuation of the phase current is caused mainly by the need "to be able to sample", not by the "wanted voltage".

The starting point of this article must be stressed here: the sampling instant is determined by the modulation pattern (the window must avoid switching transients and must fall inside a measurable state), not by "where the period average of the current happens to lie". As long as single-shunt sensing is used, this mismatch between sampling point and average value exists by nature — it is structural, cannot be removed by layout, shielding or filtering, and can only be modeled and compensated.

Window width has one more consequence: the window lower bound is set by the dead time and the sampling settling time (sampling must wait until the switching transient has decayed). The higher the switching frequency, or the longer the required settling time (a low-inductance motor has a large current slope and is more sensitive to the sampling instant), the larger the share of the switching period the window occupies and the further the sampling point moves from the average current — which directly determines the order of magnitude of the offset discussed below.

b. Where the offset comes from

Write the phase current of one period as two parts:

i(t)=if(t)⏟基波,一拍内近似线性+r(t)⏟开关纹波,整拍均值为 0

Sampling yields i(ts)=if(ts)+r(ts) , while control needs the average value of this period. The difference

i(ts)−⟨i⟩=r(ts)+[if(ts)−⟨if⟩]

falls into two categories:

  1. Ripple term r(ts) : where the sampling point sits on the ripple waveform. It is strictly synchronized with the switching state, is a deterministic, sector-synchronized offset, and is the dominant term compensated in this article;
  2. Trend term if(ts)−⟨if⟩ : the slope of the fundamental within one period. It is proportional to the offset of the sampling instant relative to the period midpoint, and its magnitude depends on the fundamental slope.

In practice the trend term usually need not be "eliminated", because the existing current-loop delay compensation (angle compensation referenced to the sampling instant) is already tuned in the sampling-instant convention. The sound compensation convention is therefore: keep the existing sampling-instant convention and remove only the ripple at the sampling point, so that after compensation

i(ts)+Δi=if(ts)

(an equality under the assumption that the fundamental is linear within one period.)

(1) At low modulation the fluctuation comes mainly from phase shifting, not from the "wanted voltage". This deserves separate treatment, because it explains why the phase current still fluctuates noticeably when the commanded voltage is almost zero.

  • Without phase shifting: as the commanded voltage approaches zero, the action times of the two active vectors also approach zero, the phase current stays close to a flat line and the ripple is minimal;
  • with phase shifting: to bring the measurable segment up to the minimum window, each half period has a lengthened non-zero-vector interval "borrowed" from it, and the volt-seconds these intervals contribute do not shrink as the commanded voltage decreases (their lower bound is set by the minimum window);
  • the phase current then takes this shape: in the zero-vector segment the switching state contributes nothing to the slope ( k=0 , so only the back-EMF and the resistive drop remain and, on the ripple scale, the current is approximately flat) → in the lengthened segment a clear ramp appears ( k=±2 , with the sampling point exactly at the centre of that ramp) → back to flat → in the other half period a ramp of opposite direction pushes the current back;
  • the deviations in the positive and negative directions are equal in area and opposite in direction over the period, so the average current is still that very small commanded value while the instantaneous current is not zero. This is the origin of the sector-synchronized fluctuation layer on the phase current at low modulation.

(2) Sign of the ramps and its relation to the two windows. The direction of each ramp is set by the switching state of that segment:

  • when the measured phase is the "only conducting phase", k=+2 , its current changes with the slope +2U3L (rising);
  • when the measured phase is the "only non-conducting phase", k=−2 , its current changes with −2U3L (falling).

The two measurable windows correspond exactly to these two states, so the switching-state slopes at the two windows are opposite in sign and equal in magnitude (both equal 2U3L ; each also carries the same slowly varying term, so the actual slopes are only approximately equal in magnitude); and since the sampling point lies at the centre of the lengthened segment, what is sampled is the midpoint of that ramp rather than the period average. The relation between the offsets of the two windows follows:

  • The two windows sample the same ripple at two different instants, with corrections −r^(ts,1) and −r^(ts,2) respectively, so their difference is exactly the integral of the zero-mean ramp between those two instants:
Δ1−Δ2=∫ts,1ts,2s^dτ

Whether this integral is zero, that is whether the two windows happen to give the same correction, is decided entirely by the relative positions of the two windows within the period — by how far phase shifting lengthens each of the two segments and where the sampling points land — and not simply by the magnitude of the commanded voltage;

  • when the two sampling instants are close together within the period (for example at low modulation, where both active-vector segments are compressed into the same short stretch in the middle of the period), the integral above is small, the two corrections are naturally close to equal, and the situation looks like "two phases of the same sign and approximately equal", with the derived third phase about minus their sum, i.e. twice as large; once the two windows are clearly separated in time, the integral is no longer near zero, nothing forces the two corrections to stay equal, and they may even have opposite signs — which is exactly why "compensating with a single constant inevitably fixes one thing and breaks another".

The offset has three properties that decide its importance and how it should be verified:

  • Determinism: it is uniquely determined by the bus voltage, the duty cycle and the sampling instant, and does not vary randomly with current magnitude, temperature or speed;
  • Independence of current amplitude: the magnitude of the offset is set jointly by "the offset of the sampling instant relative to the mean ripple position, Δt " and the current slope. If that position is dominated by the state |k|=2 , the magnitude can be written as
|Δi| ~ 2U3LΔt,U3L=Vdc/3Ls

( |k|≤2 gives the upper bound; the actual scaling factor also depends on where the sampling point falls inside the segment.) The key point is that the expression contains no phase current: eX , RiX and ΔvX enter only the period-average slope and do not change the ripple shape, so under the same operating point the load level cannot change its absolute value. Strictly this is a conclusion of the present model — in reality the dead-time equivalent drop jumps with the polarity of each phase current and the inductance varies with saturation, so the safer statement is that it does not vary randomly with load, not that it is identical for every load. The expression also shows that its span can be wide: with high inductance, a low DC bus voltage and a narrow window it is only a few tenths of an ampere; on a machine with low inductance (large current slope) and a relatively wide sampling window (lower bound set by dead time and settling time, occupying a large share of the period), several amperes is entirely normal. Its harm therefore runs in two directions: at light load it is a large relative error (when the phase current is only a few amperes the offset may amount to tens of percent), and that is exactly the region where sensorless FOC depends most on current accuracy at low speed and light load; on a low-inductance machine it is at the same time a large absolute error, present at any load;

  • Sector synchronization: it repeats 6 times per electrical revolution (the measurable state and the sector recur every 60 electrical degrees), so it is a deterministic ripple rather than noise. It appears on iα/iβ and id/iq as a 6th harmonic synchronized with the sector (strictly, it is a clean 6th spectral line only when the switching frequency keeps a fixed integer ratio to the electrical frequency and the sector sequence is stable; otherwise it spreads into sidebands), raising the noise floor of the current loop and entering the observer and the torque.

Second-order offset: the sampling point off the segment centre. Besides the dominant term above, the sampling point itself may deviate from the centre of the vector segment it lies in. In implementations the window width is often twice the sampling settling time; in that case "take the segment centre" and "take the segment start plus one delay" give the same point, and under symmetric modulation this offset is exactly 0. An offset appears only when the segment is too short and the sampling point is pushed towards a segment boundary. It is proportional to the slope of the measured phase there (the only-conducting / only-non-conducting states give ±2U3L , see §b(2)); its magnitude is comparable to the dominant term, and it is a reference quantity to keep but not to treat as the dominant term.

c. Offset modeling

The route of this section: first the slope model of the phase current, then which quantities cancel within the period (which is why the model reduces to "switching states only"), then the sampling geometry, and finally the three combined into the offset model.

(1) Slope model of the phase current. The phase current satisfies

diXdt=vX−eX−RiXLs,vX=Vdc3(3sXsw−non)−ΔvX

where eX is the back-EMF, ΔvX the equivalent drop of dead time and of device and switch on-state voltage drops, and Ls the phase inductance. Define the slope scale

U3L=Vdc/3Ls

then the phase-current slope within one switching state can be written as

i˙X=U3LkX+(一拍内为常数或慢变的项)

kX depends only on the switching state:

State ABC (1 = high side on)nonkAkBkC
000 (zero vector)0000
1001+2−1−1
1102+1+1−2
0101−1+2−1
0112−2+1+1
0011−1−1+2
1012+1−2+1
111 (zero vector)3000

The table implies an identity:

∑XkX=3∑XsXsw−3non=3non−3non=0

that is, **the sum of k over the three phases is identically 0**. It carries two meanings: first, "phase k=+2 " and "phase k=−2 " are two sides of the same fact; second, the error of the derived third phase current is exactly minus the sum of the errors of the other two (because the third phase value is −(ia+ib) ) — at low modulation with approximately symmetric windows, the offset of the third phase is about twice that of the other two and of opposite sign.

(2) Cancellation of the period invariants. The most convenient step in the modeling. Split the slope into a period average and a zero-mean part:

i˙(τ)=s¯+s^(τ),s¯=1T∫0Ti˙dτ,∫0Ts^dτ=0

With F(τ)=∫0τi˙(σ)dσ , then

⟨F⟩−F(ts)+s¯(ts−T2)=⟨F^⟩−F^(ts)=−r^(ts)

(verified by substituting F^(τ)=r^(τ)−r^(0) and ⟨r^⟩=0 ; the identity holds for any slope.) That is: the compensation depends only on the voltage differences between switching states, i.e. on the ripple shape. There are in fact two separate cancellations here, and merging them is a common source of confusion:

  • First level (taking the zero mean): eX , RiX , ΔvX and the common part of the bus voltage are slow variables within one period; they enter only the period-average slope s¯ and do not change the ripple shape s^ ; once F is replaced by its zero-mean F^ , they disappear entirely — which is exactly what s¯(ts−T/2) in the expression is for. Note that these quantities are not common to the three phases: eX and iX differ from phase to phase, and the dead-time equivalent drop ΔvX also depends on the polarity of each phase current, so the three phases generally differ. They are removed at the "take the zero mean" step, not in the differencing;
  • Second level (three-phase combination): what is genuinely common to the three phases is the non background, and it is subtracted later in the three-phase combination Kn=3Qn(X)−∑YQn(Y) .

The engineering consequence: the model needs no online identification of the back-EMF, no computation of Ri , and no borrowing of the dead-time compensation drop; errors in those quantities do not leak into the compensation either.

(3) Sampling geometry. Under center-aligned PWM, each phase turns on in the up-counting part of every period at one compare value and off in the down-counting part at another compare value. If a phase turns on in the up-counting half period at count a and off in the down-counting half period at count b (both with the valley at 0 and the peak at P ), the high-level interval of that phase is [a, 2P−b] ; rewritten with the pa=P−a , pb=P−b used below, that is [P−pa, P+pb] — the on-segments of the two half periods meet at the peak. This interval notation is the common premise of the three closed-form groups below. The number of conducting high-side phases therefore changes in steps with the count. Cutting one period into segments by switching state gives a finite number of segments (no more than 8 under typical 7-segment modulation). The two sampling windows fall in the two measurable segments:

  • in segment 1 the measured phase is the "only non-conducting" phase of that segment (two phases conduct in the segment), where k=−2 ;
  • in segment 2 the measured phase is the "only conducting" phase of that segment (a single phase conducts in the segment), where k=+2 .

Denote the two sampling instants by ts,1 and ts,2 . If the counter runs from 0 at the valley to the half-period count P at the peak, the whole period is T=2P counts, and the offset of the sampling instant relative to the period midpoint is most conveniently expressed by a single scalar d :

d≡ts−P(时间口径下即 ts−T/2)

it captures both "earlier or later" and "by how much" ( d>0 meaning later).

(4) Offset model. Combining (1), (2) and (3), the correction for the measured phase X at sampling instant ts is

 ΔiX=⟨iX⟩−iX(ts)+s¯X(ts−T2)=−r^X(ts) 

the right-hand side contains the ripple only, which is (2)'s conclusion made concrete. More useful in practice is the form normalized by U3L , because the normalized quantity is determined only by the integral of k :

ΔiX,U≡ΔiXU3L=\langleΦ^X\rangle−Φ^X(ts),Φ(τ)=∫0τk(σ)dσ,Φ^(τ)=Φ(τ)−k¯τ

A different notation is used here: Φ is the accumulation of k , which differs from the earlier F in the i˙ convention by a common factor only — i˙=U3Lk+(一拍内慢变的公共项) gives F^=U3LΦ^ , so the "division by U3L " is already done inside Φ , which is also why U3L scales the magnitude proportionally without affecting sign or shape. Φ is in counts (time counts) and is independent of voltage, inductance and current magnitude — only switching-state information is left in the model. Each of the two sampling windows substitutes its own ts,j .

d. Compensation: the direct method

The most intuitive form of compensation evaluates that integral literally: cut one period into intervals by switching state and accumulate the first and second integrals segment by segment:

⟨F⟩=1T∑i(FiΔτi+12i˙iΔτi2),Fi=∑j<ii˙jΔτj

where F(τ)=∫0τi˙dσ is the first integral in the current convention defined above, and Δτi is the duration of segment i ( Δτi rather than di is used, to avoid confusion with the sampling-instant offset d ).

The implementation must maintain two rolling state variables (the current first integral and the accumulated second integral), update the switching state and slope at every breakpoint, and record the first integral at the moment the sampling point is crossed. In other words, the period must first be split into an ordered interval table and then walked segment by segment.

This route is accurate enough (it is the direct discretization of the offset model), but its cost is proportional to the number of intervals:

  • an ordered interval table must be generated, with several breakpoints sorted per half period and the switching state tracked across them;
  • all intervals must be accumulated segment by segment, and this must be done separately for each of the two measured phases;
  • in a real controller such computation usually has to complete inside the switching-period interrupt, and the closer to the sampling point it is placed, the less time remains for it.

The "direct method" is therefore correct in principle but usually unacceptable in real time, which naturally raises the question: since the slope is piecewise constant, can the integral be obtained without segment-by-segment accumulation? The answer is yes — which leads to the simplified compensation.

e. Simplified compensation

The simplification has three levels, each cheaper than the last.

First level: reduce the double integral to single integrals. What is needed is the period average of Φ , which is itself the double integral of k ; accumulating it segment by segment is exactly the cost of the "direct method". Because k is piecewise constant, integration by parts reduces it in one step to two single integrals:

⟨Φ⟩=1T∫0TΦ(τ)dτ=1T([τΦ(τ)]0T−∫0Tτk(τ)dτ)=Φ(T)−1T∫0Tτkdτ

Denote the three single-integral quantities

K0=∫0Tkdτ=Φ(T),K1=∫0Tτkdτ,K2=∫0tskdτ=Φ(ts)

then ⟨Φ⟩=K0−K1T , Φ(ts)=K2 . Substituting them into ΔiX,U=⟨Φ^X⟩−Φ^X(ts) (note k¯=K0/T ):

ΔiX,U=(K0−K1T)−K0T·T2−(K2−K0Tts)=K0T/2+tsT−K1T−K2
 br≡K0T/2+tsT−K1T−K2 

That is: the whole procedure needs only three single-integral quantities (the area, its moment with respect to time, and the area up to the sampling instant), no double integral at all and no per-interval accumulation.

**Second level: turn per-phase integration into a three-phase combination by means of ∑XkX=0 .** Since kX=3sXsw−non , and the three K are all integrals of k , each of them can be written in the same form:

Kn=3Qn(X)−∑YQn(Y),其中Q0=A(T),Q1=M(T),Q2=A(ts)

Qn(X) is the measured phase's share and ∑YQn(Y) is the sum over the three phases — this step works only because non=∑YsYsw happens to be exactly the sum of the three. The physical meaning is clear: the bus-current path of the measured phase corresponds to |k|=2 (factor 3 minus 1), the three-phase sum represents the "common background", and only their difference is this phase's offset. So no matter how many segments the period is cut into, all that is needed is three quantities per phase, and the computational cost is completely decoupled from the number of intervals.

Third level: all three quantities have elementary closed forms. Let a phase turn on in the up-counting half period at count a and off in the down-counting half period at b , and define

pa=P−a,pb=P−b

(these are the "counts already on in the up-counting half period" and the "counts still on in the down-counting half period", to be clamped to [0,P] ). Then, with d=ts−P ,

  • On-counts over the whole period (area): AX(T)=pa+pb ;
  • First moment of the conduction area with respect to time: MX(T)=∫τsswdτ=pa(2P−pa)+pb(2P+pb)2 ;
  • Conduction area from the period start to the sampling instant: AX(ts)=max(0,pa+d)−max(0,d−pb) ;

the first two follow directly from the definitions; the "hinge" form of the third comes from two cases: for d≤0 (sampling point in the up-counting half period) there is only the max(0,pa+d) term, while for d>0 (in the down-counting half period) it is pa+min(d,pb) — merging the two gives that expression, with no branch, no lookup table and no need to decide which segment the sampling point falls in. And because

T2+ts=P+ts=2P+d

the sampling instant enters the computation only as the scalar d .

The simplified compensation algorithm is therefore only three steps: (1) compute the three sets of pa,pb from the phase compare values; (2) compute A(T) , M(T) and A(ts) for each phase and combine them as above into br for each of the two windows of the measured phase; (3) multiply br by U3L and scale it into a current value with the present scale.

Combining the three steps into one expression: let the measured phase be X , let ∑Y run over the three phases, and let the sampling-instant offset of the j -th window be dj=ts,j−P ; then

①&pa=clamp(P−a,0,P),pb=clamp(P−b,0,P)②&Q0=AX(T)=pa+pb&Q1=MX(T)=12[pa(2P−pa)+pb(2P+pb)]&Q2=AX(ts,j)=max(0,pa+dj)−max(0,dj−pb)③&Kn=3Qn(X)−∑YQn(Y)(n=0,1,2)&brj=K02P+dj2P−K12P−K2,ΔiX=U3Lbrj

where P is the half-period count and T=2P the whole-period count; a is the turn-on count of a phase in the up-counting half period and b the turn-off count in the down-counting half period, from which pa and pb are obtained by subtracting from P and clamping; X is the measured phase and ∑Y runs over the three phases; j∈{1,2} identifies the two sampling windows and dj=ts,j−P is the offset of that window's sampling instant relative to the period midpoint; Q0,Q1,Q2 are in turn the conduction area, the time moment of the conduction area, and the conduction area up to the sampling instant; K0,K1,K2 is the three-phase difference of these three quantities (three times the measured phase minus the sum of the three phases); brj is the normalized correction, in time counts; U3L is the current slope scale; ΔiX is the correction finally added to the sampled current of phase X .

Steps (1) and (2) must be done for each of the three phases (the sum ∑Y in step (3) is exactly why all three phase data sets must be available at the same time), while step (3) is done once for each of the two measured phases: each window substitutes its own dj and measured phase, giving two corrections that are added to the corresponding two phase currents; the third phase is derived from ∑XiX=0 and its correction is naturally minus the sum of the other two. A dimensional self-check comes for free: Q and d are both in counts (time), so brj is in time, and multiplying by the current slope U3L=(Vdc/3)/Ls lands exactly on current — which is the fundamental reason why Ls scales the magnitude proportionally without affecting sign or shape.

The whole procedure has no interval table, no sorting and no per-segment loop; the cost changes from "proportional to the number of intervals" to a fixed small group of multiply-accumulates plus one constant division (the denominators 2P and dj depend only on the modulation parameters and can be precomputed).

Two general points for implementation:

  • The result is a small difference of large terms. The three quantities are far larger in magnitude than the final correction (at low modulation with nearly symmetric windows the two terms almost cancel), so every term must be exact and no single term may be approximated. In a fixed-point implementation the quantization (right shift) should be placed where the magnitude is largest, and in an approximate division the "shift + multiply" belongs to one and the same operation, so the magnitudes must not be judged separately. It is also advisable to clamp the three phase compare values so that pa,pb stays within [0,P] , otherwise the hinge form leaves its domain;
  • The magnitude depends on the inductance used. The correction is proportional to U3L=(Vdc/3)/Ls , and Ls is usually taken as the average inductance (Ld+Lq)/2 in the model, whereas the ripple is in fact set by the equivalent inductance of the magnetic path active when the switching state changes; the two may differ noticeably. Since Ls appears only in this common first-order factor, it scales the magnitude of the correction proportionally without affecting sign or shape — in practice the equivalent inductance should be inferred from the measured ripple slope at a bus voltage near zero and an approximately symmetric geometry, rather than simply using the average value.

f. Summary

The essence of single-shunt sensing offset compensation is to restore "the bus current at a given switching state and a given instant" to "the average phase current of this period". The whole argument compresses into four statements:

  1. The offset is structural. The sampling instant is set by the modulation pattern (it must fall in a measurable state and avoid switching transients), not by where the average value lies; single-shunt sensing therefore always has a difference between instantaneous and average value, and that difference is deterministic, independent of current amplitude and synchronized with the sector;
  2. Only the ripple needs compensation. Once the slope is written as s¯+s^ , the back-EMF, Ri , dead time and device drops enter only the period-average slope s¯ and do not change the ripple shape, so they vanish when the zero mean is taken; the genuinely common non background is removed by the three-phase combination. The correction ultimately depends only on the voltage differences between switching states, so the model needs no online identification of those quantities;
  3. The direct method is correct but expensive. Accumulating first and second integrals interval by interval costs in proportion to the number of intervals, which is usually unacceptable inside a switching-period interrupt;
  4. The simplified method reduces the dimension of the problem. Piecewise-constant slope, so integration by parts turns the double integral into single integrals; the sum of k over three phases is zero, so only "three quantities per phase" plus a weighted difference are needed; the area, the time moment and the sampling-instant area of a single phase all have elementary closed forms, so there is no interval table, no sorting, no loop and a fixed computational cost.

One last piece of engineering experience deserves separate emphasis: the absolute value of this correction may be very small or as large as several amperes (depending on Vdc , Ls and the window width), but it is always a sector-synchronized deterministic step rather than random noise — so acceptance must not rest on how "clean" the phase-current waveform looks. The reliable criteria are the sector-synchronized 6th harmonic on id/iq (compared before and after compensation), or an A/B test with compensation switched on and off at the same operating point; and note that the corrections of the two windows are computed independently and are generally not equal (their difference equals the integral of that zero-mean ramp between the two sampling instants), so "one phase hardly changed" does not prove the compensation has failed.

This article was compiled with AI assistance and proofread by a human.