# Improve Hall sensor rotor-position measurements: Part 2

**Part 1** of this article described the design task required and various sources of electric motor rotor position error.

**Concept overview**

Let's assume a motor with three Hall sensors, but what follows can be applied to whatever number of Hall sensors.

Preliminarily, note that between two consecutive occurrences of the same edge, rising or falling, of the same sensor on a mechanical rotation, the rotor surely moved 360 degrees. According to this, the time *t' _{0_index}* between two consecutive occurrences of the same edge, rising or falling, of the same sensor on a mechanical rotation with index = 1,..., 6

*n*(with

*n*the number of pole pairs of the motor) according to the current edge of the Hall sensors on a mechanical rotation can be used in the Eq. (1) instead of the time

*t*(see below). Moreover, the angle Θ

_{0}*is not fixed according to the current edge of the Hall sensors, but it is the last Θ*

_{0}*(t)*calculated at the occurrence of the same edge on a mechanical rotation. So the Eq. (1):

can be written as:

According to the Eq. 2, during two consecutive edges of the Hall sensors, the current rotor angle will be correctly predicted because the time *t' _{0_index}* corresponds exactly to 360 mechanical degrees (or

*n** 360 electrical degrees) and moreover, for each edge on the Hall sensors, the correct relevant rotor angle will be calculated and used for the prediction of the rotor angle Θ

*(t)*.

Figure 3 (below) shows a possible implementation of the proposed concept. Let's assume a motor with three Hall sensors. The **subsystem 1** includes six *hit crossing* blocks to distinguish the rising and falling edges of the Hall sensors during an electrical rotation and an *OR* operation block. The output of the *OR* block is used as a signal of general synchronization by the subsystems 3 and 4.

**Fig. 3**

The **subsystem 2** generates the *index* value that is included between 1 to 6*n*, with *n* the number of pole pairs of the motor, and has as an input which is the output of the subsystem 1. The subsystem 2 gives the current value of *index* that will be used by the subsystems 3 and 4.

Before explaining the use of *index*, let's see how it is generated. The subsystem 2 includes the *index determination*, the *counter polar pairs*, and the *counter module n*. The block *index determination* gives the *index_e* value, which can be from 1 to 6, according to the current edge of the Hall sensors. The *counter module n* has as an input the synchronization signal, used to identify the current polar pair, and the output of the counter is ranged between 1 to *n*-1. This value is multiplied by 6 and added to the *index_e* value.

The subsystem 3 calculates Θ* _{0_index}* (i.e. Θ

*(t)*in the 6

*n*synchronization times according to the Eq. (2) using the previous value of Θ

*) and stores it in the*

_{0_index}*Register HS offset*with 6

*n*memory cells. The subsystem 3 simply reads the value Θ

*(t)*when an edge of the Hall sensors occurs and stores this value in the correct position using the

*index*value (i.e. it updates the value of Θ

*. For*

_{0_index}*index*= 0, the Θ

*value is always 0° in order to take the relevant Hall sensor's edge as reference.*

_{0_index= 0 }
The **subsystem 4** implements Eq. (2). In particular, the subsystem 4 uses the timer T_{0} in free-running mode in order to calculate *t' _{0_index}* for each edge of the Hall sensors and stores this value using a register with 6

*n*memory cells. The

*t'*is calculated considering that when an edge of the Hall sensors occurs, the current value of the timer T

_{0_index}_{0}is subtracted to the previous value

*t'*according to the current value of

_{0_index}*index*and the new value is stored in the correct position.