Stall Detection

The motor Hall sensor provides a stable periodic signal in the form of pulses, when the motor is running. The absence of these pulses over a long period indicates the motor has stopped or is in a Stall condition. This condition normally happens when the motor load torque is greater than the motor shaft torque. During a Stall condition, the motor draws current that exceeds the rated value, which also causes motor overheating and failure.
Figure 1. HLT Operation

To detect such a condition, a stall detection feature is also implemented. By using the Hardware Limit Timer (HLT) of the TMR2 peripheral, the absence of a Hall signal within a period of time, can be detected. It is set to operate in rollover Pulse mode. In this mode, an input signal is allowed to clear the TMR2 register every time a falling edge transition is detected. When the pulse is absent or has a long periodic time, TMR2 will continuously increment until it reaches its maximum value, setting its Overflow bit. HLT will trigger an interrupt that disables all CWG peripherals, stopping the motor. In this application, the Hall B signal, which is connected to the RC6 input, is used as the reference signal. The signal provided by the Hall sensor has an approximate period of 5 ms in a normal setup. If the timer counter matches the PR value, the interrupt flag will be set as shown in Figure 5-1. The PR value that will be set on TMR2 should be larger than the period of the Hall sensor signal, in order to identify the stall condition of the motor. To calculate TMR2 PR register values, use Equation 5-2.

Figure 2. PR2 Calculation
PR2=TMR2ClockSourceHallSignalPeriod×Prescaler×Postscaler