Sensored brushless DC motor control with Arduino

There are two types of BLDC motors: sensored and sensorless. Sensored BLDC motor uses hall effect sensors to detect rotor position where as the sensorless BLDC motor uses another technique which is BEMF (back electromotive force). This topic shows how to drive a sensored BLDC motor using an Arduino UNO board. The BLDC motor used in this project is just a PC CD-ROM motor (spindle motor).

The BLDC motor (sensored or sensorless) is a 3 phase DC motor which means it has 3 winding on the stator core. Two coils are energized at a time to create a rotating electric field. This method is fairly easy to implement, but to prevent the permanent magnet rotor from getting locked with the stator, the excitation on the stator must be sequenced in a specific manner while knowing the exact position of the rotor magnets.

3 Phase BLDC motor coils

To drive this motor we need a 3-phase bridge, the basic elements of it are the 6 MOSFETs. General circuit schematic diagram of the 3-phase bridge is shown below:

3 Phase bridge for BLDC motor control

The sensored BLDC motor has 3 hall effect sensors (A, B and C) to sense rotor position, these sensors are placed as shown in the following picture. The motor which I used in this project has pinout as shown below (other motors may have a different pinout).
In this motor each hall effect sensor has 4 pins: VCC (H+), GND (H-) and two outputs (some sensors come with 3 pins: VCC, GND and output).

CD-ROM BLDC motor pin configuration

Since I have 4-pin hall effect sensors, I added an analog comparator (I used LM339N quad comparator IC) to each one so each sensor outputs (2 outputs: + and -) are connected to the inputs (2 inputs: non-inverting and inverting) of the comparator as shown in the circuit schematic below, finally I got 3 outputs from the 3 hall effect sensors.

Each sensor outputs a digital high for 180 electrical degrees and outputs a digital low for the other 180 electrical degrees. The following figure shows the relationship between the sensors outputs and the required motor drive voltages for phases A, B and C.

3 Phase BLDC motor phases

According to the hall effect sensors, the 3-phase bridge is controlled as shown in the following table:

brushless dc motor driving sequence

Components Required:

  • Arduino board
  • Sensored brushless DC motor
  • 6 x 06N03LA N-type mosfet (or equivalent)  – datasheet
  • 3 x IR2104S gate driver IC  – datasheet
  • LM339N (or LM339) quad comparator IC  – datasheet
  • 10k ohm (or less) potentiometer
  • 3 x 10k ohm resistor
  • 7 x 100 ohm resistor
  • 3 x IN4148 diode
  • 3 x 10uF capacitor
  • 3 x 2.2uF capacitor
  • 12V source
  • Breadboard
  • Jumper wires

Sensored brushless DC motor control with Arduino circuit:
The overall circuit diagram is shown below.

Arduino BLDC motor control circuit

(All grounded terminals are connected together).

In the circuit there are three IR2104S gate driver IC, each one is used to drive one high side mosfet and one low side mosfet, the switching between the high side and the low side is done according to the control lines which are: IN and SD. The figure below shows input and output timing diagram:

ir2104s timing

The 10k potentiometer is used to control the brushless DC motor speed, it is controlled using PWM technique (pwming high sides only). Any time there is one active high side mosfet and one active low side mosfet, that means always there is one active PWM pin (Arduino pin 2, 4 or 6).

The table below summarizes the active Arduino pins according to the hall effect senors states (pins: 8, 9, and 10):

arduino bldc motor driving sequence table

Sensored brushless DC motor control with Arduino code:
In this project I implemented a simple software PWM code because I had needed an active PWM signal on pin 2, 4 or 6 (only one is active at a time), for that I used Timer2 module and I configured it with a prescaler of 1/8 which means the PWM signal frequency is about 7.8KHz ( equal to: 16MHz/(8 * 256) ) and 8-bit resolution.

The ADC module is configured to read from channel 0 only.

Arduino interrupt on change is activated for pins 8, 9 and 10 (hall effect sensors inputs) for better commutation.

PORTB are Arduino uno pins: 8 … 13.
PORTD are Arduino uno pins: 0 … 7.

The video below shows a hardware circuit of the project:

Related project:
CD-ROM Sensored BLDC motor control with Arduino

4 comments

  1. This article is great. I like it very much
    But I have a liite question. You say Arduino pins 2, 4 and 6 as PWM capable but I find only pins 3,5,6,9,10,11 are PWM cable.
    This is clear from the picture of the UNO in your schematic.
    Could you kindly explain me this discrepancy.
    Thanks

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.