Cd-Rom 3 phase Sensored BLDC Motor Arduino ControllerBLDC
(brushless dc) motors are three phase dc motors, unlike the simple
dc motors the bldc motors are more difficult to control. These
motors are used in many applications for examples rc airplans and
rc cars.
In this post we will see how to control cd-rom sensored BLDC
motor using Arduino uno board. But first there are some things we
should know in order to control the motor in easy way.The bldc
motor that we are going to use is sensored via hall effect sensors
(position sensors) attached with the motor(3 sensors). Each sensor
outputs digital high for 180 electrical degrees and low for the
other 180 electrical degrees.these sensors are used to tell us
where is the position of the motor, then when we know the position
of the motor we will energize just tow windings (of three). The
below figure shows how sensors outputs and the corresponding
voltage applied to the motor:
The motor is driven by a 3 phase bridge which contains 6 mosfets
like the figure below:
And for the bridge I used to run the motor visit this post
below:Three Phase BLDC Motor BridgeWe can run the bldc motor in the
cw or ccw rotaion but the sensor of the cw rotaion is different
from the sensor of the ccw direction. The tow tables below show the
sensor and the coils that activated at each phase:
Also for more information for the hall effect sensors and how to
test it visit this link:Sensored Cd-Rom BLDC Motor Hall Effect
SensorsThe complete circuit is shown below:
The Arduino code is below:I used timer 2 interrupt every about
30ms to read the analog value and generate the corresponding pwm
signal. For the pwm I used PWM.h library to generate 20KHz easily.
Also in the code there are tow functions one for forward rotation
and the other for the backward
rotation.#includeint32_tfrequency=20000;//pwm frequency in
Hzunsigned int n = 0, timer2_initial_value, s = 0;void
setup(){InitTimersSafe();boolsuccess=SetPinFrequencySafe(9,
frequency);pinMode(3, OUTPUT);pinMode(4, OUTPUT);pinMode(5,
OUTPUT);pinMode(6, OUTPUT);pinMode(7, OUTPUT);pinMode(8,
OUTPUT);pinMode(13, OUTPUT);pinMode(0, INPUT);pinMode(1,
INPUT);pinMode(2, INPUT);pinMode(10, INPUT_PULLUP);pinMode(11,
INPUT_PULLUP);pinMode(12, INPUT_PULLUP);// initialize timer2
interrupt for adc reading noInterrupts(); // disable all
interruptsTCCR2A=0;TCCR2B=0;timer2_initial_value=0;TCNT2=timer2_initial_value;//
preload timerTCCR2B|=(1