---
# System prepended metadata

title: 'CHAPTER 7: CONTROLLERS'

---

> []# Futuretron EV Course_CHAPTER6

# CHAPTER 7: CONTROLLERS

## 7.1 Basic theory of motor control

A DC motor is a device that converts direct current into mechanical work. It works on the principle of Lorentz law, which states that “the current carrying conductor placed in a magnetic field experience a force”. The motor controller is an electronic circuit that is responsible for controlling the speed and direction of the motor. 

Let us understand the basic principle of motor rotation.
![](https://i.imgur.com/cmrFhLH.jpg)
Fig. 1
![](https://i.imgur.com/U8hhOLr.jpg)
Fig. 2

In the motor the rotor and stator generate interactive force and the motor spins as long as the force acts in the same direction. As seen from Fig. 1, The rotor spins in the direction of the clock, since the force is in the direction of the spin of the rotor. But, after a 180 ° spin, the force direction changes, prevents the rotor from spinning and tries to drag it backwards. Finally, the rotor is not going to spin in the same direction but only to sway.
One efficient way of holding the force in the same direction is to change the current position in the coil as the direction of force varies at the same time. This is called commutation.
All of these functions are carried out by the motor controller.

## 7.2 BLDC motor control methodology
The controller is responsible for guiding the rotor rotation, but the controller requires some way to determine the orientation / location of the rotor (relative to the stator coils). Many designs use Hall Effect Sensors or a rotary encoder to explicitly calculate the position of the rotor. Others measure the EMF back in undriven coils to infer the position of the rotor, eliminating the need for separate Hall effect sensors and are therefore often referred to as sensor less controllers.

**3Phase H-Bridge**

A standard controller has 3 bi-directional outputs (i.e., three-phase frequency-controlled output), which are operated by a logic circuit (usually a microcontroller). The three two-way outputs are operated by switches. Such switches need to be able to turn on and off very quickly in order to spin the motor at appreciable speeds. Mechanical relays and switches do not have the speed required for such applications.    In addition, mechanical devices will wear out really quickly considering the high number of times the switch turns on and off to complete rotation after rotation. We opt for MOSFET to solve this problem.

![](https://i.imgur.com/W9Z4HB1.png)

**PWM Technique**

PWM is an efficient method to change the quantity of power delivered to the load. PWM technique allows for smooth variable speed without reducing the starting torque and reduces harmonics. Operating power to the motors is turned on and off in PWM system to modulate the current to the motor. The on-time to off-time ratio is called a duty cycle. The duty cycle determines speed of the motor. You can get the desired speed by adjusting the duty cycle.

In microcontroller the Pulse Width Modulation (PWM) is used to control the DC motor drive duty cycle. PWM is a completely different approach for controlling a DC motor 's speed. In square wave of constant voltage, but with varying pulse-width or duty-cycle, power is supplied to the motor. Duty cycle refers to the percentage of one cycle during which a continuous pulses train duty cycle. As the frequency is kept constant while the on-off time is changed, the pulse width determines the PWM duty cycle. In PWM, the control thus increases the duty cycle.

![](https://i.imgur.com/TyRhoTe.png)

## 7.3 Sensorless controller

**Back EMF control method**

The Back-EMF sensing technique is based on the fact that only two phases of a DC Brushless motor are coupled at a time, so that a third phase of the Back-EMF voltage can be sensed. Controllers that sense back-EMF-based rotor position have additional challenges when initiating motion, since no back-EMF is generated when the rotor is stationary. This is usually done by starting the rotation from an arbitrary phase, and then skipping it to the correct phase if it is found to be wrong. This can cause the electric motor to briefly run backwards, adding even more complexity to the start-up sequence.

![](https://i.imgur.com/hgtr1eD.png)

Back EMF schematics.

## 7.4 Sensor based controller

**Hall effect sensor-based controllers**
The most common type of sensor used in BLDC motors is the Hall Effect Sensor. The Hall Effect Sensor is a sensing device that delivers a degree of logic based on detection of a magnetic field. Because of the permanent magnets inside a BLDC motor, hall effect sensors are inexpensive and simple to mount in the motor. The Hall effect sensors are usually positioned in such a way that the magnets change their values before the rotor is actually in the next location of commutation. This helps you to do the next commutation until the rotor is actually trapped in one position.

![](https://i.imgur.com/eVcnZlM.png)
Hall effect sensor based controller schematics.


**Working**
The Hall Effect Sensor is a sensing mechanism that outputs a level of logic dependent on the sensed magnetic field. Sensors for the Hall effect (Ha, Hb, and Hc) are inserted into the stator. In principle, the combination of the outputs of all the three sensors would grant 8 status from 000 to 111. For most instances, however, signal 000 and 111 do not exist due to hardware constraint. The other 6 status will split the one electrical 360 ° position into six parts, and the exact point where the commutator switches from one to the other is the location where the switch switches the direction of the magnetic field of the stator.
![](https://i.imgur.com/PzcVf8O.png)

The excitation of the stator windings must be changed six times in one full rotation of 360 electric degrees, and each change is called a commutation. The angle is 60-120 ° between the S-N pole (rotor) and the magnet field (stator windings). commutation happens at 60°. The location of the commutation is when the Hall sensor status changes. Just two phases have current at each moment, while the third is turned off.

**Commutation table**

The six commutation positions are set at 360 electrical degrees, as stated earlier. Therefore, a special table can be built to explain the relationship between the status of the sensor and the winding excitation of the stator, which is called the commutation table. The motor control unit can easily control the switching with this commutation table.
![](https://i.imgur.com/CyVBGDE.jpg)

**Speed control of BLDC motor**

The variable velocity control of a BLDC motor is acquired by utilizing inverter yield which has a variable recurrence and variable voltage source. The speed of the motor is related to the number of poles and frequency of the supplied voltage as below:

N=120f/P

where N—speed in rpm, P—number of poles and f—frequency of the supply.


## 7.5 Hall effect sensor

**Hall effect principle**

If current is flowing through a conductor and a magnetic field is allowed to move through the conductor perpendicular to the current flow, the charged particles drift to the edges of the conductor. These charged particles pool at the surface edges. The magnetic flux imparts a force on the conductor, which causes a voltage drop across the opposite edge. The force exerted on the current flow is called the Lorentz Force.

Let us look at an experimental demonstration of the Hall effect.

Consider a current carrying conductor, under ideal conditions the electrons flowing through the conductor are undeflected and follow a straight path.

![](https://i.imgur.com/BlO8g5C.png)
Credits: https://howtomechatronics.com/

When a magnetic field is brought near the conductor, the straight flow of the charge carriers is disturbed. In such a case the electrons would deflect to one side of the conductor and the positive holes to the other side of the conductor. Thus, a measurable voltage level is obtained across the edge of the conductor. The magnitude of this voltage depends on the strength of the magnetic field provided other conditions remain constant.

![](https://i.imgur.com/a5ZhtXZ.png)
Credits: https://howtomechatronics.com/

**Types of Hall sensors**

**Analogue sensor**

The analogue sensor is composed of a voltage regulator, a Hall Element and an amplifier. These types of sensors are suitable and used for measuring proximity because of their continuous linear output.

**Digital sensor** 

The digital output sensors provide just two output states, either “ON” or “OFF”. In addition to the components of an analogue sensor, digital sensor also consists of Schmitt trigger which provides hysteresis or two different thresholds levels so the output is either high or low. They are often used as limit switches, for example in 3D printers and CNC Machines, as well as for detection and positioning in industrial automation systems.

**Materials**

The following materials are preferred for Hall effect sensors

•	Gallium arsenide
•	Indium arsenide
•	Indium phosphide
•	Indium antimonide
•	Graphene
•   Silicon

The choice of material is primarily driven by the cost prameter, manufacturers usually opt for a material that is easily available and cheaper to produce. Hence, expensive materials such as Silicon and Graphene are generally not chosen for Hall sensors in motors. Such expensive materials are generally used in scientfic and industrial equipments.

**Advantages**

•	Low cost. 
•	Can be operated at higher frequencies when compared to a mechanical switch.
•	It will not be affected by environmental contaminants since the sensor is in a sealed package. Therefore, it can be used under severe conditions.
•	Can measure a wide range of magnetic fields.

**Disadvantages**

•	Low accuracy.

Reference video: https://youtu.be/wpAA3qeOYiI

**Applications**

**Hall-effect sensors**
These are simple, inexpensive, electronic chips that are used in all sorts of widely available gadgets and products.

![](https://i.imgur.com/Ph7ja66.jpg)
Typical silicon Hall-effect sensor.
Credits: https://www.explainthatstuff.com/hall-effect-sensors.html

**Hall-effect probes**

These are more expensive and sophisticated instruments used in scientific laboratories for things like measuring magnetic field strength with very high precision.

![](https://i.imgur.com/XY4rjev.jpg)
Hall-effect probe used by NASA in the mid-1960s.
Credits: https://www.explainthatstuff.com/hall-effect-sensors.html

**Factors affecting the selection of a Hall sensor**

**Sensitivity**

The level of sensitivity is dependent on the sensor being mounted on the magnet, the air gap and the magnet strength. Data sheets would indicate the strength of the magnetic field (measured in Gauss). Usually rated at less than 60 Gauss, a high sensitivity sensor allows for the use of smaller magnets or less powerful magnetic materials. High sensitivity also allows for a wider air gap, meaning that the sensor can be mounted further away from the magnet and still be very accurate, thus offering some versatility in design. Or provided the same air distance, the sensor is more sensitive and thus offers greater reliability and repeatability.

**Repeatability**

Repeatability refers to the time for latching of the Hall-effect sensor. Once the sensor output turns on it directs the current in the stationary part of the motor through the coil windings. This current produces a magnetic field from the permanent magnets on the shaft that interacts with the field and causes the shaft to spin. While the magnet is spinning past the sensor, each time the magnet moves, a highly repeatable sensor changes state at the same angular location.

**Response time** 

The response time is the amount of time it takes to adjust the state of the sensor output. A quicker reaction time to a magnetic field shift allows greater performance when a BLDC is turned on. If a sensor switches to a level of a different magnetic field than what is needed due to slow response or delay, accuracy errors may result. In order to achieve the optimum performance, motors need to turn at a very specific stage.

**Hardware Implementation with Infineon XC866 Microcontroller**

The XC866 microcontroller has a Capture/Compare Unit 6 (CCU6) that takes the hall signals as input and generates the switching patterns for the stator field according to the rotor position obtained from the hall signals. The CCU6 also generates the PWM which is used for speed or torque control. The 3-phase driver IC takes the CCU6 switching patterns as input and provides the output signals for the 3-phase inverter. It is also capable of implementing short-circuit current protection, over-/under-voltage protection and over-temperature protection by making use of the CTRAP functionality of the CCU6. The CTRAP will force the CCU6 outputs into a passive state and no active modulation is possible, immediately stopping motor operation.

![](https://i.imgur.com/YejIEGV.png)
Credits: https://www.infineon.com/dgdl/AP0802610_Hall_Sensor_BLDC_Control.pdf?fileId=db3a304412b407950112b40c61bd0b0f 

There is always a pair of switches which controls one motor phase (e.g. A+ and A- control phase A) – this is called half bridge configuration. There is a high side switch which is connected to the V+ DC-rail voltage and the opposite one which is called low side switch which connects the coil to the GND. Current through the motor will flow if one high side switch is on and another low side switch is on. The current will flow from V+ through one coil in positive direction and through another coil in negative direction to GND. This is called block commutation mode where one phase is always inactive whereas current will flow to the other two phases. Also, a bridge shortcut can occur if the high side and low side switches are on at the same time. This will burn the inverter immediately because very high current will flow very fast (within a few microseconds) and this situation have to be avoided (through hardware protection). Thus timer 12 of the CCU6 has a dead time control module which will delay the switching of either a high side or a low side switch so that a short circuit does not occur.

## 7.6 How to choose a BLDC motor controller?

1. Choose a controller that is appropriate for the type of motor you have chosen. For example, DC brush or DC brushless, Hall sensor or sensorless, etc.
2. Ensure that the maximum power rating of the controller is 2-3 times the rated power of the motor. For example, if the rated power of a motor is 500W then a controller with a maximum rating of 1KW~1.5KW must be chosen.
3. Match motor parameters with that of the controller. If the hall sinusoidal controller has speed output, the motor pole pairs, speed and other parameters shall be matched. When matching a Hall-free sinusoidal wave, parameters of phase inductance, phase resistance, pole logarithm and maximum speed of motor shall be known. 

**Features in a modern day BLDC motor controller**

1.  Intelligence with powerful microprocessor.
2. Electronic reversing.
3. Voltage monitoring on 3 motor phases, bus, and power supply.
4. Voltage monitoring on voltage source 12V and 5V.
5. Current sense on all 3 motor phases.
6. Current control loop.
7. Hardware over current protection.
8. Hardware over voltage protection. It will stop driving if the battery voltage is too high and it will progressively cut back motor drive power as battery voltage drops until it cuts out altogether at the preset “Low Battery Voltage” setting.
9. Configurable limit for motor current and battery current.
10. Battery protection: current cutback, warning and shutdown at configurable high and low battery voltage.
11. Aluminum based PCB board with heat sink plate on the bottom of controller.
12. Waterproof connectors for small signal.
13. Thermal protection: current cut back, warning and shutdown on high temperature.
14. Controller can do auto Identification angle for different degrees of hall sensors.
15. Configurable high pedal protection: the controller will not work if high throttle is detected at power on.
16. Current multiplication: Take less current from battery, output more current to motor.
17. Easy installation: 3-wire potentiometer will work.
18. Standard PC/Laptop computer to do programming.
19. Support motors with any number of poles.
20. Dust and water protected under sealed condition,IP66.
21. Inbuilt connector pins for tail lamps in sych with brake pedal.
22. Extended fault detection and protection.
23. Cruise control.


