Professional Documents
Culture Documents
using
dSPIC Microcontroller
How to Guide
PANTECH PROLABS INDIA PVT LTD.
No:41 Santhosh nagar, Rajeshwari street, Kandhanchavadi, Chennai - 600 096
Ph: 044 – 6452 4445/46/47 | Fax: 044 – 4260 6350| www.pantechsolutions.net
BRANCHES @ CHENNAI | COIMBATORE | MADURAI | HYDERABAD | BANGALURU | COCHIN | PUNE
BLDC Motor Control using DSPIC Microcontroller
Table of Contents
Introduction ................................................................................................................. 3
BLOCK DIAGRAM OF BLDC MOTOR SPEED CONTROL ................................. 4
Block Diagram ............................................................................................................ 6
BLDC Motor Specifications........................................................................................ 7
Motor Working Pattern ............................................................................................... 9
Commutation details for BLDC 3 Phase Inverter Card ........................................... 10
3 Phase H-Bridge Inverter (MOSFET/IGBT) BOARD ............................................ 11
TLP 250 DRIVER BOARD ...................................................................................... 12
dSPIC30F4011 Evaluation Board ............................................................................. 14
dSPIC30F4011 connection details ............................................................................ 15
Feedback Block From Motor To Dspic30f4011 ....................................................... 17
Flowchart Of BLDC Motor Speed Control ............................................................... 18
Source Code For BLDC Motor Speed Control ......................................................... 20
www.pantechsolutions.net Page 2
BLDC Motor Control using DSPIC Microcontroller
Introduction
This project describes the speed control of BLDC motor with the
dsPIC30F4011 Digital Signal Controller. By using the Hall effect
sensors of BLDC Motor, the dsPIC30F4011 controller generates the
controlled switching pulses for inverter. The speed control is done by
changing the duty cycle of PWM from dsPIC30F4011. The motor speed
is measured by using the proximity sensor placed on the BLDC Motor
and displayed on LCD.
This development kit used to design and develop controller for BLDC. All the parts
are separately available in the DIY market.
www.pantechsolutions.net Page 3
BLDC Motor Control using DSPIC Microcontroller
Rotational Phase A
A Phase Comparator Top
Increment PWM Phase A Bottom
Generator Unit A
Push Switch Bottom
3 Phase
Phase B Top
B Phase Comparator
A Unit B Phase B Bottom
Get Hall Bottom
Sensor B Phase C Top
Signals C Phase
C Comparator Phase C Bottom
Unit C Bottom
PWM
Unit
From BLDC
Motor
The Hall Effect sensor signals are read from the BLDC motor and
it fed as inputs to the DSPIC30F4011 device. A 3-bit code can be
obtained with values ranging from 1 to 6 by reading the Hall sensor. The
duty cycle of the PWM is varied by using an rotational increment push
switch. These PWM pulses are enabled as based on the 3-bit code
getting from Hall Effect sensor signal. There are six PWM pulses are
generated to operate the three phase inverter. The BLDC Motor speed is
adjusted by varying the PWM duty cycle.
www.pantechsolutions.net Page 4
BLDC Motor Control using DSPIC Microcontroller
Bundle of Contents
www.pantechsolutions.net Page 5
BLDC Motor Control using DSPIC Microcontroller
Block Diagram
In this project the BLDC motor is controlled by dSPIC30F4011 DSP Processor. The
24V BLDC Motor power is converted from 24V AC and Full wave rectifier. The
3Ph Inverter circuit formed using IRFP250 MOSFET and its gate is driven by
TLP250 with separate isolator for TOP and BOTTOM MOSFET from dSPIC
Processor.
230/24V
Rectifier BLDC
AC, 3 Phase Inverter
With Filter Motor
Transformer
230/12V
AC, TLP250 Based Driver
Transforme
r
9V Adaptor dSPIC30F4011
Evaluation Board
www.pantechsolutions.net Page 6
BLDC Motor Control using DSPIC Microcontroller
The BLDC Motor is highly reliable and having torque. In industry the BLDC motor
is used widely. The rotor part of the motor is rotated based on the stator excitation.
The entire operation of BLDC motor can be divided into 6 modes. Each mode has
separated 60 degree. All the Hall Sensors (A,B, C) are mounted at 120 degree phase
shift. And will be HIGH for 180 degree of 360 degree rotation.
SPECIFICATION
Power : 60W
Voltage : 24V
Speed : 3000 RPM
www.pantechsolutions.net Page 7
BLDC Motor Control using DSPIC Microcontroller
PWM Outputs
Pulse 1 H1
Pulse 2 L1
Pulse 3 H2
Pulse 4 L2
Pulse 5 H3
Pulse 6 L3
Phase Winding
Red Phase1
White Phase2
Black Phase3
Forward:
Reverse:
www.pantechsolutions.net Page 8
BLDC Motor Control using DSPIC Microcontroller
HALL A
60 120 180 240 300 360 degree
HALL B
HALL C
PWM1
PWM2
PWM 3
PWM4
PWM5
PWM 6
VAB
VBC
VCA
www.pantechsolutions.net Page 9
BLDC Motor Control using DSPIC Microcontroller
The inverter card comes with inbuilt full bridge rectifier and filter capacitor. 6 Nos
of IRFP250 MOSFETs are mounted with Heat sink. The output of the inverter is
terminated with 3 pin PTB Connector. The user should get soldered on back side of
the board for gate pulse interface.
6 Nos of IRFP250 MOSFET are mounted with proper Heat sink
5A Bridge Rectifier with DC Filter Capacitor(1000uF/100V)
3 Pin PTB Connector provided to connect Motor
www.pantechsolutions.net Page 10
BLDC Motor Control using DSPIC Microcontroller
INVERTER BOARD
Specification
6 Nos of IRFP250 MOSFET with Heatsink
Input Voltage 100V/AC/50Hz
Operating Frequency 25 KHz
Input and Outputs are terminated with PTB Connectors
www.pantechsolutions.net Page 11
BLDC Motor Control using DSPIC Microcontroller
www.pantechsolutions.net Page 12
BLDC Motor Control using DSPIC Microcontroller
Block Diagram
12V
AC
G1
11
S1
2VA 11
G2
C 1
S2
12V
AC
G3
S3
12V G4
AC1
S4
GND
PWM1
Pulse G5
PWM2
From S5
PWM3
MCU/DSP G6
PWM4
PWM5 /FPGA S6
PWM6
PIN Details
www.pantechsolutions.net Page 13
BLDC Motor Control using DSPIC Microcontroller
www.pantechsolutions.net Page 14
BLDC Motor Control using DSPIC Microcontroller
www.pantechsolutions.net Page 15
BLDC Motor Control using DSPIC Microcontroller
www.pantechsolutions.net Page 16
BLDC Motor Control using DSPIC Microcontroller
BLDC
Motor
Hall Effect
Sensor
dsPIC30F4011
Controller
www.pantechsolutions.net Page 17
BLDC Motor Control using DSPIC Microcontroller
START
Is Increment switch
pressed?
BLDC Motor
www.pantechsolutions.net Page 18
BLDC Motor Control using DSPIC Microcontroller
www.pantechsolutions.net Page 19
BLDC Motor Control using DSPIC Microcontroller
void forward();
void reverse();
unsigned int
duty,deg,Set_point=556,duty_value,frequen,flag=0,flag1=0,flag2,
Speed,direction=0,cap2_count,Prev_cap5;
unsigned long int count,count1;
www.pantechsolutions.net Page 20
BLDC Motor Control using DSPIC Microcontroller
www.pantechsolutions.net Page 21
BLDC Motor Control using DSPIC Microcontroller
{
cap2_count = 0;
TMR2 = 0;
count1 = 0;
PR2 = 65535;
T2CON = 0x8000;
flag1 = 1;
}
else if(flag1 == 1)
{
T2CON = 0x0000;
count = TMR2 + (count1 * 65535);
flag1 = 0;
}
if(direction == 1) {POVD2H = 0;POUT3L = 0;}
else if(direction == 2) {POUT2L = 0;POVD3H = 0;}
}
else if(!cap8)
{
if(direction == 1) {POUT2L = 0;POVD3H = 0;}
else if(direction == 2) {POVD2H = 0;POUT3L = 0;}
}
}
www.pantechsolutions.net Page 22
BLDC Motor Control using DSPIC Microcontroller
int main(void)
{
cmd_write();
ADPCFG = 0xFFFF;
ADPCFGbits.PCFG3 = 1;
TRISBbits.TRISB3 = 1;
ADPCFGbits.PCFG4 = 1;
TRISBbits.TRISB4 = 1;
ADPCFGbits.PCFG5 = 1;
TRISBbits.TRISB5 = 1;
tcap5 = 1;
cap5 = 0;
tcap7 = 1;
cap7 = 0;
tcap8 = 1;
cap8 = 0;
PTCON = 0x8002;
PTPER = 250;
PDC1 = 50;
PDC2 = 50;
PDC3 = 50;
OVDCON = 0x0000;
CNEN1 = 0x0020;
CNPU1 = 0x0020;
IFS0bits.CNIF = 0;
www.pantechsolutions.net Page 23
BLDC Motor Control using DSPIC Microcontroller
IEC0bits.CNIE = 1;
IC7CON = 0x0001;
IEC1bits.IC7IE = 1;
IC8CON = 0x0001;
IEC1bits.IC8IE = 1;
IEC0bits.T1IE = 1;
T1CON = 0x8000;
PR1 = 277;
IEC0bits.T2IE = 1;
T5CON = 0x8000;
T5CONbits.TCKPS = 3;
PR5 = 195; // 10ms.
IEC1bits.T5IE = 1;
data_write("PANTECH PROLABS ",0x80,16);
data_write(" INDIA PVT LTD ",0xc0,16);
delay(1000);
data_write(" BLDC MOTOR ",0x80,16);
data_write(" CONTROL ",0xc0,16);
delay(1000);
Init_Keys();
delay(500);
while(1)
{
if(flag == 0)
{
direction = 1;
flag = 1;
data_write("D.CYCLE = % ",0x80,16);
data_write("SPEED = RPM",0xc0,16);
LCDDisp_INT(duty,0x89,2);
LCDDisp_INT(Speed,0xc9,4);
delay(500);
PWMCON1 = 0x0077;
}
else if(flag == 1)
{
if(!key1) {if(Set_point < 3000) Set_point += 10;else Set_point =
556;}
duty_value = Set_point * (float)(0.1125); // 90%
On time.
duty = duty_value * (float)(0.2);
www.pantechsolutions.net Page 24
BLDC Motor Control using DSPIC Microcontroller
LCDDisp_INT(duty,0x89,2);
LCDDisp_INT(Speed,0xc9,4);
delay(100);
}
}
}
void forward()
{
deg = 0;
if(!cap5 && !cap7 && cap8) // 001.
{
POUT1L = 1;
POVD1H = 0;
POUT2L = 0;
POVD2H = 0;
POUT3L = 0;
POVD3H = 1;
}
else if(!cap5 && cap7 && !cap8) // 010.
{
POUT1L = 0;
POVD1H = 0;
POUT2L = 0;
POVD2H = 1;
POUT3L = 1;
POVD3H = 0;
}
else if(!cap5 && cap7 && cap8) // 011.
{
POUT1L = 1;
www.pantechsolutions.net Page 25
BLDC Motor Control using DSPIC Microcontroller
POVD1H = 0;
POUT2L = 0;
POVD2H = 1;
POUT3L = 0;
POVD3H = 0;
}
else if(cap5 && !cap7 && !cap8) // 100.
{
POUT1L = 0;
POVD1H = 1;
POUT2L = 1;
POVD2H = 0;
POUT3L = 0;
POVD3H = 0;
}
else if(cap5 && !cap7 && cap8) // 101.
{
POUT1L = 0;
POVD1H = 0;
POUT2L = 1;
POVD2H = 0;
POUT3L = 0;
POVD3H = 1;
}
else if(cap5 && cap7 && !cap8) // 110.
{
POUT1L = 0;
POVD1H = 1;
POUT2L = 0;
POVD2H = 0;
POUT3L = 1;
POVD3H = 0;
}
T1CON = 0x0000;
}
void reverse()
{
deg = 0;
if(!cap5 && !cap7 && cap8) // 001.
{
www.pantechsolutions.net Page 26
BLDC Motor Control using DSPIC Microcontroller
POUT1L = 0;
POVD1H = 1;
POUT2L = 0;
POVD2H = 0;
POUT3L = 1;
POVD3H = 0;
}
else if(!cap5 && cap7 && !cap8) // 010.
{
POUT1L = 0;
POVD1H = 0;
POUT2L = 1;
POVD2H = 0;
POUT3L = 0;
POVD3H = 1;
}
else if(!cap5 && cap7 && cap8) // 011.
{
POUT1L = 0;
POVD1H = 1;
POUT2L = 1;
POVD2H = 0;
POUT3L = 0;
POVD3H = 0;
}
else if(cap5 && !cap7 && !cap8) // 100.
{
POUT1L = 1;
POVD1H = 0;
POUT2L = 0;
POVD2H = 1;
POUT3L = 0;
POVD3H = 0;
}
else if(cap5 && !cap7 && cap8) // 101.
{
POUT1L = 0;
POVD1H = 0;
POUT2L = 0;
POVD2H = 1;
POUT3L = 1;
www.pantechsolutions.net Page 27
BLDC Motor Control using DSPIC Microcontroller
POVD3H = 0;
}
else if(cap5 && cap7 && !cap8) // 110.
{
POUT1L = 1;
POVD1H = 0;
POUT2L = 0;
POVD2H = 0;
POUT3L = 0;
POVD3H = 1;
}
T1CON = 0x0000;
}
www.pantechsolutions.net Page 28