Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

AVR492: Brushless DC Motor Control using AT90PWM3

Features

BLDC Motor Basics PSC use Hardware Implementation Code Example

AVR Microcontrollers

Application Note

Introduction
This application note describes how to implement a brushless DC motor control in sensor mode using AT90PWM3 AVR microcontroller. The high performance of AVR core fitted with Power Stage Controller module of AT90PWM3 enable the design of high speed brushless DC motor applications. In this document, we give a short description of brushless DC motor theory of operation, we detail how to control brushless DC motor in sensor mode and also give the hardware description of ATAVRMC100 reference design used in this application note. Software implementation is also discussed with software control loop using PID filter. This application note deals only with BLDC motor control application using Hall effect position sensors to control commutation sequence.

7518AAVR07/05

Theory of Operation

Brushless DC motors are used in a growing number of motor applications as they have many advantages: 1. They have no brushes so they required little or no maintenance. 2. They generate less acoustic and electrical noise than universal brushed DC motors. 3. They can be use in hazardous operation environment (with flammable products). 4. They have a good weight/size to power ratio... Such types of motor have a little rotor inertia, the coils are attached to the stator. The commutation is controlled by electronics. Commutation times are provided either by position sensors or by coils Back Electromotive Force measuring. In sensor mode, Brushless DC motor usually consists of three main parts. A Stator, a Rotor and Hall Sensors.

Stator

A basic three phases BLDC motor Stator has three coils. In many motors the number of coils is replicated to have a smaller torque ripple. Figure 1 shows the electrical schematic of the stator. It consists of three coils each including three elements in series, an inductance, a resistance and one back electromotive force. Figure 1. Stator Electrical Configuration (Three phases, three coils)

L L,R

bemf A bemf C bemf B L,R L,R

Rotor

The rotor in a BLDC motor consists of an even number of permanent magnets. The number of magnetic poles in the rotor also affects the step size and torque ripple of the motor. More poles give smaller steps and less torque ripple. The permanent magnets go from 1 to 5 pairs of poles. In certain cases it can goes up to 8 pairs of poles.(Figure 2).

AVR 492 Application Note


7518AAVR07/05

AVR 492 Application Note


Figure 2. Three phases, three coil BLDC motor stator and rotor
coils A coils A

Stator Rotor

Stator Rotor

coils C

coils C

N S

S N

coils B

coils B

1 pair of poles

2 pairs of poles

The coils are stationary while the magnet is rotating. The rotor of the BLDC motor is lighter than the rotor of a conventional universal DC motor where the coils are placed on the rotor. Hall Sensor For estimating the rotor position, three hall sensors are positioned. These hall sensors are separated by 120 each. With these sensors, 6 different commutations are possible. Phase commutation depends on hall sensor values. Power supply to the coils change when hall sensor values change. With right synchronized commutations, the torque remain nearly constant and high. Figure 3. Hall Sensors signals for CW rotation
Hall_A Hall_B Hall_C

t t t t t t

Coil_A Coil_B Coil_C

Phases Commutation

To simplify the explanation of how to operate a three phases BLDC motor a typical BLDC motor with only three coils is considered. As previously shown, phases commutation depends on the hall sensor values. When motor coils are correctly supplied, a magnetic field is created and rotor moves. The most elementary commutation driving method used for BLDC motors is an on-off scheme: a coil is either conducting or not conducting. Only two windings are supplied at the same time the third winding is floating. Connecting the coils to the power and neutral bus induces the current flow. This is referred to as trapezoidal commutation or block commutation.

3
7518AAVR07/05

To command brushless DC motors, a power stage made of 3 half bridges is used. Figure 4 below shows 3 half bridges schematic. Figure 4. Power Stage

+DC
CmdSW1 CmdSW3 CmdSW5

+
VDC

A B C

CmdSW2

CmdSW4

CmdSW6

Reading hall sensor value, indicate which switch should be closed. Table 1. Switches commutation for CW rotation
Hall Sensors Value (Hall_CBA) 101 001 011 010 110 100 Phase A-B A-C B-C B-A C-A C-B Switches SW1 ; SW4 SW1 ; SW6 SW3 ; SW6 SW3 ; SW2 SW5 ; SW2 SW1 ; SW4

For motors with multiple poles the electrical rotation does not correspond to a mechanical rotation. A four pole BLDC motor uses four electrical rotation cycles to have one mechanical rotation. The strength of the magnetic field determines the force and speed of the motor. By varying the current flow through the coils the speed and torque of the motor can be adjusted. The most common way to control the current flow is to control the average current flow through the coils. PWM(Pulse Width Modulation) is used to adjust the average voltage and thereby the average current, including the speed. The speed can be adjusted with a high frequency from 20 khz to 60 khz. For a three phase, three coils BLDC motor, the rotating field is described in Figure 5.

AVR 492 Application Note


7518AAVR07/05

AVR 492 Application Note


Figure 5. Commutation steps and rotating field
Hall_CBA 011
coil A coil A

001
coil C

010

coil C

101
coil B

110
coil B

Step1
coil A coil A

100

Step2

coil C

coil C

coil B

coil B

Step3
coil A coil A

Step4

coil C

coil C

coil B

coil B

Step5

Step6

Commutation creates a rotating field. Step1 Phase A is connected to the positive DC bus voltage by SW1 and Phase B is connected to ground by SW4, Phase C is unpowered. Two flux vectors are generated by phase A (red arrow) and phase B (blue arrow) the sum of the two vectors give the stator flux vector (green arrow). Then the rotor tries to follow stator flux. As soon as the rotor reach a certain position when the hall sensors state changes its value from 010 to 011 a new voltage pattern is selected and applied to the BLDC motor. Then Phase B is unpowered and Phase C is connected to the ground. It results in a new stator flux vector Step2. By following the commutation schematic Figure 3 and Table 1, we obtain six differents stator flux vectors corresponding to the six commutation steps. The six steps provide one rotor revolution.

5
7518AAVR07/05

Starter KIT ATAVRMC100

After this brief theoretical presentation of Brushless DC Motor Control, the practical implementation will be introduced with the help of an example. The next part of this application note will deal with the hardware and the software implementation based on the starter kit ATAVRMC100 running with a microcontroller AT90PWM3. Electrical schematics are available Figure 21, Figure 22, Figure 23 and Figure 24 at the end of the document. They describe the reference design for the Starter Kit ATAVRMC100. The software includes the control of the speed through a PID corrector. Such a corrector is composed of three main coefficients : KP, KI, and KD. KP is the proportionnal gain coefficient, KI is the integral gain coefficient and KD is the derivative gain coefficient. The error between the desired speed and the real speed (called error in the Figure 6) is multiplied by each gain. Then, the sum of the three thermes give the command to apply to the motor to get the right speed (Figure 6).

Figure 6. PID diagram

KP

desired_speed + -

error

KI
d KD dt

+ +

command

BLDC Motor + Power Stage

PID corrector real_speed


d command ( t ) = KP eror ( t ) + KI error ( t ) d( t ) + KD error ( t ) dt error ( t ) = desired _ speed ( t ) real _ speed ( t )

The KP coefficient fixes the motor response time, the KI coefficient is used to cancel the static error and the KD is used in particular for position regulation(refer to regulation loop in software description for tuning the coefficients).

AVR 492 Application Note


7518AAVR07/05

AVR 492 Application Note


Hardware Description
As shown in Figure 7 the microcontroller contains 3 Power Stage Controller (PSC). Each PSC can be seen as a Pulse Width Modulator with two output signals. To avoid cross conduction a Dead Time control is integrated (see AT90PWM3 datasheet for more information about PSC or Figure 9 below). A fault input (Over_Current) is linked to PSCIN. This fault input enables the microcontroller to disable all PSC outputs. Figure 7. Hardware implementation
AT90PWM3
PSC00 PSC10 PSC20 PSC01 PSC11 PSC21 Over_Current Current HallA HallB HallC PH_A PH_B PH_C

PSCOUT

Power Bridge + Shunt resistor

Motor

PSCIN AMP1+;AMP1ACMP0 ACMP1 ACMP2

PSCij : Power Stage Controller i (i = 0,1,2) output j (j = 0,1) ACMPi : Analog Comparator Positive input (i = 0,1,2) AMPi+/- : Analog Differential Amplified channel Positive/Negative inputs (i = 0,1,2)

Its possible to measure the current with two differential amplified channels with programmable 5, 10, 20 and 40 gain stage. The Shunt resistor has to be adjusted to the amplifier conversion range. The Over_Current signal results from an external comparator. The comparators reference can be adjusted by the internal DAC. The phase commutation has to be done according to hall sensors value. HallA, HallB and HallC are connected to external interrupt sources or to the three internal comparators. The comparators generate the same type of interrupts as the external interrupts. Figure 8 shows how the microcontroller I/O ports are used in the starter kit.

7
7518AAVR07/05

Figure 8. Microcontroller I/O Ports use (SO32 package)


O p e ra tin g M o d e PORTB P B 0 /M IS O /P S C O U T 2 0 P B 1 /M O S I/P S C O U T 2 1 P B 2 /A D C 5 /IN T 1 P B 3 /A M P 0 P B 4 /A M P 0 + P B 5 /A D C 6 /IN T 2 P B 6 /A D C 7 /P S C O U T 1 1 /IC P 1 B P B 7 /A D C 4 /P S C O U T 0 1 /S C K PORTC P C 0 /IN T 3 /P S C O U T 1 0 P C 1 /P S C IN 1 /O C 1 B P C 2 /T 0 /P S C O U T 2 2 P C 3 /T 1 /P S C O U T 2 3 P C 4 /A D C 8 /A M P 1 P C 5 /A D C 9 /A M P 1 + P C 6 /A D C 1 0 /A C M P 1 P C 7 /D 2 A PORTD P D 0 /P S C O U T 0 0 /X C K /S S _ A P D 1 /P S C IN 0 /C L K O P D 2 /P S C IN 2 /O C 1 A /M IS O _ A P D 3 /T X D /D A L I/O C 0 A /S S /M O S I _A P D 4 /A D C 1 /R X D /D A L I/IC P 1 A /S C K_A P D 5 /A D C 2 /A C M P 2 P D 6 A D C 3 /A C M P M /IN T 0 P D 7 /A C M P 0 PORTE P E 0 /R E S E T /O C D P E 1 /O C 0 B /X T A L 1 P E 2 /A D C 0 /X T A L 2 P IN 12 13 20 27 28 30 31 32 2 7 10 11 21 22 26 29 1 4 5 6 16 17 18 19 3 14 15 P o rt F u n c tio n H _C L_C VMOT EXT1 EXT2 EXT5 L_B L_A H _B EXT3 EXT4 L IN _ N S L P V _ S h u n tV _ S h u n t+ H a llB / B E M F _ B D AC _O U T H _A O v e r_ C u rre n t M IS O / E X T 1 0 M O S I / L IN T x D / T x D / EXT7 S C K / L IN R x D / R x D / POT / EXT8 H a llC / B E M F _ C V M O T _ H a lf H a llA / B E M F _ A NRES / EXT9 EXT6 LED SENSOR H _C L_C VMOT D e p e n d o n th e c o m m u n ic a tio n m o d e L_B L_A H _B D e p e n d o n th e c o m m u n ic a tio n m o d e V _ S h u n tV _ S h u n t+ H a llB D AC _O U T H _A O v e r_ C u rre n t D e p e n d o n th e c o m m u n ic a tio n m o d e H a llC V M O T _ H a lf H a llA D e p e n d o n th e c o m m u n ic a tio n m o d e

VMOT and VMOT_Half are implemented but not used. They can be used to get the value of the motor supply. The outputs H_x and L_x are used to control the power bridge. As previously seen, they depend on the Power Stage Control (PSC) which generate PWM signals. For such application the recommended mode is the Center Aligned Mode (see Figure 9), the register OCR0RA is used to adjust ADC synchronization for current measurement.

Figure 9. PSCn0 & PSCn1 Basic Waveforms in Center Aligned Mode


OCRnRB OCRnSB OCRnSA 0 On Time 0 PSCn0 On Time 1 PSCn1 On Time 1

PSC Cycle

AVR 492 Application Note


7518AAVR07/05

AVR 492 Application Note


On Time 0 = 2 * OCRnSA * 1/Fclkpsc On Time 1 = 2* (OCRnRB - OCRnSB + 1) * 1/Fclkpsc PSC Cycle = 2 * (OCRnRB + 1) * 1/Fclkpsc |OCRnSB - OCRnSA| * 1/Fclkpsc

The dead time value between PSCn0 and PSCn1 is : The input clock of PSC is given by CLKPSC. Clock input from I/O clock or from PLL. Two strategies can be employed for the PWM signals applied on the power stage. The first consists in applying the PWM signals on the high side AND the low side of the power bridge and the second in applying the PWM signals only on the high side of the power bridge.

9
7518AAVR07/05

Software Description
Microcontroller Configuration and Initialization Software Implentation Diagram

Atmel provides libraries to control Brushless DC motors. The first step is to configure and initialize the microcontroller. The function to be used is named mc_init_motor(). It calls hardware and software initialization functions and initialize all motor parameters (motor direction, motor speed and stop the motor). After microcontroller configuration and initialization, the motor can be started. Only few functions are needed to control the motor. All user functions are define in mc_lib.h:
void mc_motor_run(void)

Used to start the motor. The regulation loop function is launched to set the duty cycle. Then the first phases commutation is executed.
Bool mc_motor_is_running(void)

Get the motor state. If TRUE the motor is running. Else if FALSE the motor is stopped.
void mc_motor_stop(void)

Used to stop the motor.


void mc_set_motor_speed(U8 speed)

Set the user requested speed.


U8 mc_get_motor_speed(void)

Return the current user requested speed.


void mc_set_motor_direction(U8 direction)

Set the motor direction, CW or CCW.


U8 mc_get_motor_direction(void)

Return the current direction of rotation of the motor.


U8 mc_set_motor_measured_speed(U8 measured_speed)

Save the measured speed in the measured_speed variable.


U8 mc_get_motor_measured_speed(void)

Get the measured speed.


void mc_set_Close_Loop(void) void mc_set_Open_Loop(void)

Set type of regulation Open Loop or Close Loop. See Figure 13 for more information.

10

AVR 492 Application Note


7518AAVR07/05

AVR 492 Application Note


Figure 10. AT90PWM3 Configuration

mc_init_motor()

mc_init_HW()

mc_init_SW()

+ motor direction initialization + motor speed initialization + Stop the motor

mc_init_port() Enable_Interrupt() mc_init_pwm()

PSC0_Init() PSC1_Init() PSC2_Init()

mc_init_IT()

mc_configestimation_speed()

Timer0 configuration

mc_config_samplin g_time() mc_init_comparator0() mc_init_comparator1() mc_init_comparator2() mc_init_DAC() mc_init_ADC()

Timer1 configuration

mc_init_current_measure() mc_set_Over_Current()

11
7518AAVR07/05

mc_estimation_speed()
mc_measured_speed

Figure 11. Software Implentation Diagram.

HallA

mc_hall_a() Set_QxQy() mc_switch_commutation() mc_duty_cycle()


mc_get_duty_cycle()
duty_cycle

ovf_timer

TCNT0

mc_motor_is_runing()

mc_get_motor_direction()

mc_motor_run()

mc_motor_stop()

mc_get_motor_direction()

mc_set_motor_speed()

Hardware

Software

mc_set_motor_direction()

main()

mc_get_motor_speed()

g_tic

mc_set_Close_Loop()

mc_set_Open_Loop()

all 250us

mc_set_motor_measured_speed()

mc_get_motor_measured_speed()

12
ovfl_timer() mc_hall_b() mc_hall_c()
H_A L_A H_B L_B H_C L_C

Timer0

TIMER0_OVF_vect

t_timer = 8us

HallB

HallC

AVR 492 Application Note


mc_regulation_loop()
mc_get_motor_speed()
mc_cmd_speed mc_run_stop mc_direction

HallA HallB HallC

Timer1

TIMER1_COMPA_vect

mc_launch_sampling_period()

Hardware

7518AAVR07/05

AVR 492 Application Note


Figure 11 shows four variables mc_run_stop, mc_direction, mc_cmd_speed and mc_measured_speed. They are the main software variables which can be accessed by user functions previously described. The software can be seen as a black box named Motor Control (Figure 12) with inputs ( mc_run_stop, mc_direction, mc_cmd_speed, mc_measured_speed) and output (All power bridge signals). Figure 12. Main Software Variables.
mc_run_stop mc_direction mc_cmd_speed Power Bridge Signals H_A<=> L_A H_B<=> L_B H_C<=> L_C

Motor Control

mc_measured_speed

Most of the functions are available in mc_drv.h. Only a few depends on the motor type. Functions can be distributed in four main class : Hardware initialization
void mc_init_HW(void);

All hardware initialization are made in this function. We can found ports initialization, interrupts initialization, timers and PSCs.
void mc_init_SW(void);

Used to initialized software. Enable all interrupts.


void mc_init_port(void);

Microcontroller I/O ports initialization with DDRx register initialization to choose if the pin acts as an Output or an Input and PORTx to activate or not the pull-up on Input.
void mc_init_pwm(void);

This function start the PLL and sets all PSC registers with their initial values.
void mc_init_IT(void);

Modifie this function to enable or disable types of interrupts.

13
7518AAVR07/05

void PSC0_Init ( unsigned int dt0, unsigned int ot0, unsigned int dt1, unsigned int ot1); void PSC1_Init ( unsigned int dt0, unsigned int ot0, unsigned int dt1, unsigned int ot1); void PSC2_Init (unsigned int dt0, unsigned int ot0, unsigned int dt1, unsigned int ot1);

PSCx_Init allows the user to select the configuration of the Power Stage Control (PSC) of the microcontroller.

Phases commutation functions


U8 mc_get_hall(void);

Get the Hall sensors value corresponding to the six commutations steps (HS_001, HS_010, HS_011, HS_100, HS_101, HS_110).
_interrupt void mc_hall_a(void); _interrupt void mc_hall_b(void); _interrupt void mc_hall_c(void);

These functions are executed when an external interrupt is detected (Hall sensor edge). They allow phases commutation and speed calculation.
void mc_duty_cycle(U8 level);

This function set the PSC duty cycle according to PSC configuration.
void mc_switch_commutation(U8 position);

The phases commutation is done according to hall sensors value and only if the user start the motor.

Sampling time configuration


void mc_config_sampling_period(void);

Initialize the timer1 to generate an interrupt all 250 us.


_interrupt void launch_sampling_period(void);

When the 250us interrupt is activated, a flag is set. It can be use for sampling time control.

14

AVR 492 Application Note


7518AAVR07/05

AVR 492 Application Note


Estimation speed
void mc_config_time_estimation_speed(void);

Configuration of the timer0 to be use for the speed calculation.


void mc_estimation_speed(void);

This function calculate the motor speed with the hall sensor periode measure principle.
_interrupt void ovfl_timer(void);

When an overflow occurs on the timer0 a 8bits variable is increased to obtain a 16bits timer with a 8bits timer.

Current measure
_interrupt void ADC_EOC(void);

As soon as the amplifier conversion is finished, the ADC_EOC function is executed to set a flag usable for the user.
void mc_init_current_measure(void);

This function initializes the amplifier 1 for the current measure.


U8 mc_get_current(void);

Get the current value if the conversion is finished.


Bool mc_conversion_is_finished(void);

Indicate if the conversion is finished.


void mc_ack_EOC(void);

Reset the End Of Conversion flag.

Over Current detection


void mc_set_Over_Current(U8 Level);

Set the level of detection of an over current. The level is output by the DAC on external comparator.

15
7518AAVR07/05

Regulation Loop

Two functions select the regulation loop. Open loop or close loop. Figure 13 shows the regulation loop implemented in the software.The two functions are mc_set_Close_Loop() and mc_set_Open_Loop(). Figure 13. Regulation Loop 2
mc_cmd_speed error

2
duty_cycle Motor

PID

mc_measured_speed

1 : mc_set_Close_Loop() 2 : mc_set_Open_Loop()

1 : mc_set_Close_Loop() 2 : mc_set_Open_Loop()

The close loop consists in a speed regulation loop with the PID corrector. We will further explain how to adjust the coefficients KP and KI. The KD coefficient is present in the regulation loop but not used. As previously shown, the KP coefficient is used to regulate the motor response time. In a first time set KI and KD to 0.Try different value of KP to get a right motor response time. If the response time is too slow increase KP gain. If the response time is quick but unstable decrease KP gain.

Figure 14. Kp tuning


160 140 Speed Measured 120 100 80 60 40 20 0 0 0,32 0,64 0,96 1,28 1,92 2,24 2,56 2,88 1,6 3,2 Kp = 1 Kp = 2 Kp = 3 Kp = 6
Requested Speed Speed Consign

time (s)

16

AVR 492 Application Note


7518AAVR07/05

AVR 492 Application Note


KI parameter is used to cancel the static error. Leave the KP coefficient unchanged and set the KI parameter. If the error is still different from zero increase KI gain. If the error is cancelled but after oscillations decrease KI gain.

Figure 15. Ki tuning


250 200 Speed Measured 150 100 50 0
0 0, 4 2 2, 4 1, 6 2, 8 3, 2 0, 8 1, 2 3, 6 4

Ki=1 ; Kp=1 Ki=2 ; Kp=1 Ki=0,5 ; Kp=1

Requested Speed Speed Consign

time (s)

In the Figure 14 and Figure 15 example, the right parameters are KP = 1, KI = 0.5 and KD = 0. To adjust KD parameter : If the reponse is still low increase KD gain. If the reponse is still unstable decrease KD gain.

One another significant point is the sampling time. It has to be chosen according to the response time of the system. The sampling time must be at least twice smaller than the response time of the system (according to the Shannon-Nyquist criterie). Two functions are available for the sampling time configuration (explained previously). They result in a global variable called g_tick which is set all 250us. With this variable its possible to configure the sampling time.

CPU & Memory usage

All measurements has been realized with Fosc = 8MHz. It also depends on the motor type too (numbers of pair of poles). With a motor of 5 pair of poles, hall sensor frequency is five times slower than motor rotation. All results in Figure 16 are obtained with a three phases BLDC motor with five pairs of poles and a maximum speed of 14000 rpm.

17
7518AAVR07/05

Figure 16. Microcontroller utilization rate


Function ovfl_tim er() m c_estim ation_speed() m c_s witch_com m utation() m c_regulation_loop() Param eters all cas e Speed = 14000 rpm Speed = 2800 rpm Speed = 14000 rpm Speed = 2800 rpm Open Loop Clos e Loop activation tim e 2us 31 us 17 us 4,5 us 45 us activation period 2,05m s 857,14 us 4,29 m s 142,86 us 714 us 80 m s 80 m s Ratio uc % 0,1 3,62 0,72 11,89 2,38 0,0056 0,056

In the worst case, the microcontroller utilization ratio is about 18% with a sampling time of 80ms at 14000 rpm. A first estimation can be made for a faster motor and with a current regulation added. Activation time for mc_regulation_loop() grows up from 45us to 55us (we have to take into account the conversion time of the ADC about 7us). For this estimation, a BLDC motor with a current response time about 2-3ms, five pairs of poles and a maximum speed of 50000 rpm is chosen. The maximum speed of the motor is about 50000 rpm, with a rotor of 5 pairs of poles we obtain a Hall sensors frequency of (50000rpm/60)*5 = 4167 Hz. The function mc_estimation_speed() is launched at each rising edge of hall sensor A, so every 240us with an activation time of 31us. For mc_switch_commutation() the three hall sensors have to be considered. The function is executed at each edges of the three hall sensors (rising edge and falling edge) we have six interrupts in one Hall sensor period. It results in an activation period of 240/6us = 40us. Finally, the sampling time of the regulation loop must to be at least twice smaller than the current reponse time of the motor (about 1ms). All results are summarized Figure 17. Figure 17. Microcontroller utilization rate estimated
Function ovfl_timer() mc_estimation_speed() mc_switch_commutation() mc_regulation_loop() Parameters all case Speed = 50000 rpm Speed = 50000 rpm Close Loop activation time 2us 31 us 17 us 55 us activation period 2,05 ms 240 us 40 us 1 ms Ratio uc % 0,1 12,91 42,5 5,5

In such case the utilization ratio of the microcontroller is about 61%. All ratio measurement have been made with the same software. No communication mode are used (no UART, no LIN...). In these conditions, the microcontroller memory usage is : 3175 bytes of CODE memory (Flash occupation = 38.7% ). 285 bytes of DATA memory (SRAM occupation = 55.7%).

18

AVR 492 Application Note


7518AAVR07/05

AVR 492 Application Note


ATAVRMC100 Configuration and Use
Figure 18 shows us the complet schematics of the various operating mode of the starter kit ATAVRMC100.

Figure 18. Microcontroller I/O Ports use and communication modes


Communication Mode Operating Mode PORTB PIN PB0/MISO/PSCOUT20 12 PB1/MOSI/PSCOUT21 13 PB2/ADC5/INT1 20 PB3/AMP027 PB4/AMP0+ 28 PB5/ADC6/INT2 30 PB6/ADC7/PSCOUT11/ICP1B 31 PB7/ADC4/PSCOUT01/SCK 32 PORTC PC0/INT3/PSCOUT10 2 PC1/PSCIN1/OC1B 7 PC2/T0/PSCOUT22 10 PC3/T1/PSCOUT23 11 PC4/ADC8/AMP121 PC5/ADC9/AMP1+ 22 PC6/ADC10/ACMP1 26 PC7/D2A 29 PORTD PD0/PSCOUT00/XCK/SS_A 1 PD1/PSCIN0/CLKO 4 PD2/PSCIN2/OC1A/MISO_A 5 PD3/TXD/DALI/OC0A/SS/MOSI 6 _A PD4/ADC1/RXD/DALI/ICP1A/SC 16 K_A PD5/ADC2/ACMP2 17 PD6ADC3/ACMPM/INT0 18 PD7/ACMP0 19 PORTE PE0/RESET/OCD 3 PE1/OC0B/XTAL1 14 PE2/ADC0/XTAL2 15 Port Function H_C L_C VMOT EXT1 EXT2 EXT5 L_B L_A H_B EXT3 EXT4 LIN_NSLP V_ShuntV_Shunt+ HallB / BEMF_B DAC_OUT SENSOR H_C L_C VMOT Depend on the communication mode L_B L_A H_B Depend on the communication mode V_ShuntV_Shunt+ HallB DAC_OUT LIN H_C L_C VMOT EXT1 EXT2 EXT5 L_B L_A H_B EXT3 EXT4 LIN_NSLP V_ShuntV_Shunt+ DAC_OUT H_A Over_Current EXT10 LIN TxD LIN RxD VMOT_Half PC Link H_C L_C VMOT EXT1 EXT2 EXT5 L_B L_A STK500 Switchs/LEDs H_C L_C VMOT EXT1 EXT2 EXT5 L_B L_A JTAGICE mkII Debug Wire H_C L_C VMOT EXT1 EXT2 EXT5 L_B L_A ISP H_C L_C VMOT EXT1 EXT2 EXT5 L_B L_A H_B EXT3 EXT4 LIN_NSLP V_ShuntV_Shunt+ DAC_OUT H_A Over_Current MISO MOSI SCK VMOT_Half

H_B H_B H_B EXT3 EXT3 EXT3 EXT4 EXT4 EXT4 LIN_NSLP LIN_NSLP LIN_NSLP V_ShuntV_ShuntV_ShuntV_Shunt+ V_Shunt+ V_Shunt+ Depend on the operating mode DAC_OUT DAC_OUT DAC_OUT H_A Over_Current EXT10 TxD RxD H_A Over_Current EXT10 POT EXT8 H_A Over_Current EXT10 EXT7 EXT8

H_A H_A Over_Current Over_Current MISO / EXT10 MOSI / LIN TxD / TxD Depend on the / EXT7 communication mode SCK / LIN RxD / RxD / POT / EXT8 HallC / BEMF_C HallC VMOT_Half VMOT_Half HallA HallA / BEMF_A NRES / EXT9 EXT6 LED Depend on the communication mode

Depend on the operating mode VMOT_Half VMOT_Half VMOT_Half Depend on the operating mode EXT9 EXT6 LED EXT9 EXT6 LED NRES EXT6 LED

EXT9 EXT6 LED

NRES EXT6 LED

Operating mode

Two differents operating modes are available, set jumpers JP1, JP2 and JP3 according to Figure 19 to select between both modes. In this application, only Sensor mode is used. Refer to the ATAVRMC100 User Guide for complete description of hardware.

19
7518AAVR07/05

Figure 19. Sensor mode selection

Figure 19 shows the default jumpers setting to use the software associated with this application note. The software delivered with the ATAVRMC100 board allows two operating modes : No external component, the motor start with a speed of 100%. One external potentiometer use to adjust the speed of the motor.

Figure 20. Potentiometer connection. J4: IO-COM

R 10K

1 2 3 4
ADC5

10K

GND VCC5V

5 6 7 8 9 10

20

AVR 492 Application Note


7518AAVR07/05

AVR 492 Application Note


Conclusion
This application note provides a software and hardware solution for sensor brushless DC motors applications. All source code is available on the Atmel web site. The software library provides functions to start and control the speed of any sensor three phases brushless DC motors. The hardware is based on the minimal design with minimal external components required for control sensor brushless DC motors. The AT90PWM3 CPU and memory usage allow a developer to expand his horizons with new functionalities.

21
7518AAVR07/05

Figure 21. Schematic page 1/4

22
4 3 2 1

TP11 BEMF_C PH_C 15K R35 22K C28 R36 22K 100pF 470pf (Not Mounted) C29 100K R33 R34 BEMF_C

BEMF_C

PH_C

TP12 BEMF_B PH_B 15K 100K R39 22K C30 R40 22K 100pF 470pF (Not Mounted) C31 R37 R38 BEMF_B

BEMF_B

AVR 492 Application Note


PH_B
B

TP13 BEMF_A PH_A 15K R41 22K C32 R44 22K 100pF C33 100K R42 R43 BEMF_A

BEMF_A

PH_A

470pF (Not Mounted)

Drawn By: G ALLAIN


Title Size

ATAVRMC1 (ZCD Detection)


Document Number

A4
Date: 11 April 2005
4 3 2

Rev 1.6 Sheet 4


1

of

7518AAVR07/05

GND

47uF

100nF

100nF 100nF 10uF GND D6 LED_Green

7518AAVR07/05
4 3 2 1

VBUS U6 D5 R25 10 VCC5V MC78M05CDT

VBUS_D

1 VIN
R26 4.7K C22 TP10 10nF C21 C23

VOUT

2
D

Figure 22. Schematic page 2/4

LL4001 C19 C20

C18

POWER
VBUS_D VBUS_D R29 10K EXT8/SCK/LIN_RxD/RxD/POT LIN_NSLP VMOT LIN_NWAKE EXT7/MOSI/LIN_TxD/TxD LIN_NWAKE EXT7/MOSI/LIN_TxD/TxD LIN_NSLP EXT8/SCK/LIN_RxD/RxD/POT U7 R30 33 VBUS

VBUS_D

R27 15K

R28 100K

1 2 3 4

RxD NSLP NWAKE TxD


ATA6661

INH BAT LIN GND

8 7 6 5

J1
B

VMOT

LIN

1 2 3
C25 100nF C26 220pF LIN Connector

R31 22K

C24 2.2nF

VMOT_Half VMOT_Half

LIN
Drawn By: G ALLAIN
Title Size
A

R32 22K C27 100nF

ATAVRMC1 (POWER + LIN)


Document Number

V measurement
4 3

A4
Date: 11 April 2005
2

Rev 1.6 Sheet 3


1

of

AVR 492 Application Note

23

Figure 23. Schematic page 3/4

24
4 3 2 1

VCC5V R1 10 R45 1K U1

H_A R46 1K

H_A

1 PD0/PSCOUT00/XCK/SS_A PC0/INT3/PSCOUT10 PE0/RESET/OCD PD1/PSCIN0/CLKO PD2/PSCIN2/OC1A/MISO_A PD3/TXD/DALI/OC0/SS/MISO_A PC1/PSCIN1/OC1B


C2

PB7/ADC4/PSCOUT01/SCK PB6/ADC7/PSCOUT11/ICP1B PB5/ADC6/INT2 PC7/D2A PB4/AMP0P PB3/AMP0M PC6/ADC10/ACMP1 AREF AGND AVCC PC5/ADC9/AMP1P PC4/ADC8/AMP1M PB2/ADC5/INT1 PD7/ACMP0 PD6/ADC3/ACMPM/INT0 PD5/ADC2/ACMP2 17 18
VMOT_Half

32
L_A L_B EXT5 DAC_OUT EXT2 EXT1 HallB BEMF_B JP2 HallB BEMF_B

L_A L_B EXT5 DAC_OUT EXT2 EXT1

H_B

H_B

2 3 4 5 6 7 8 VCC GND PC2/T0/PSCOUT22 PC3/T1/PSCOUT23 PB0/MISO/PSCOUT20 PB1/MOSI/PSCOUT21 PE1/OCB0/XTAL1 PE2/ADC0/XTAL2 PD4/ADC1/RXD/DALI/ICP1A/SCK_A


AT90PWM3 VCC5V R3 100K J2 VCC5V

31 30 29 28 27 26 25 24 23 22
V_Shunt+ C4 V_ShuntVMOT HallA BEMF_A VMOT_Half V_Shunt+ V_ShuntVMOT 1uF C3 100nF AGND 100nF

NRES/EXT9

NRES/EXT9

Over_Current

Over_Current

MISO/EXT10

MISO/EXT10

EXT7/MOSI/LIN_TxD/TxD

EXT7/MOSI/LIN_TxD/TxD

VCC5V R48

EXT3

EXT3 C1

1 2 3
Sel_Sensor_Sensorless_B

10

100nF

9 10 11
R47 1K

EXT4

EXT4

VCC5V

LIN_NSLP

LIN_NSLP

H_C

H_C

12 13 14 15 16 19 20

21

L_C

L_C

JP1 HallA BEMF_A

R2 4.7K

AVR 492 Application Note


1 2 3
Sel_Sensor_Sensorless_A JP3 HallC 1 HallC 2 BEMF_C 3 BEMF_C Sel_Sensor_Sensorless_C
B

D1

EXT6

EXT6

LED_Green

EXT8/SCK/LIN_RxD/RxD/POT

EXT8/SCK/LIN_RxD/RxD/POT

MISO/EXT10 EXT8/SCK/LIN_RxD/RxD/POT NRES/EXT9

MISO/EXT10 EXT8/SCK/LIN_RxD/RxD/POT NRES/EXT9

1 3 5 MISO SCK RST


JTAG ISP

VCC MOSI GND

2 4 6

EXT7/MOSI/LIN_TxD/TxD

EXT7/MOSI/LIN_TxD/TxD

J3 H_A H_B H_C V_Shunt+ VMOT_Half J4 EXT2 EXT2 EXT6 EXT8/SCK/LIN_RxD/RxD/POT EXT2 Drawn EXT4 Title EXT6 EXT8/SCK/LIN_RxD/RxD/POT H_A H_B H_C V_Shunt+ VMOT_Half

1 3 5 7 9

H_A H_B H_C V+ Vmot

L_A L_B L_C VOCur


STK500_CON

2 4 6 8 10

L_A L_B L_C V_ShuntOver_Current

L_A L_B L_C V_ShuntOver_Current

EXT1 EXT3 EXT4

EXT1 EXT3 EXT5 EXT7/MOSI/LIN_TxD/TxD

By: G ALLAIN

EXT7/MOSI/LIN_TxD/TxD PORT_COM CON 2x5 VCC5V


4

1 3 5 7 9 EXT1 EXT3 EXT5 EXT7 GND EXT2 EXT4 EXT6 EXT8 VCC

2 4 6 8 10

ATAVRMC1 (MicroController)
Size Document Number

A4
Date: 11 April 2005
3 2

Rev 1.6 Sheet 1


1

of

7518AAVR07/05

4.7K

4.7K

Figure 24. Schematic page 4/4

R4 22 100nF

R9

Q1 SUD35N05-26L

R6

R7

10K C7 PH_C TP1 100nF R10 22 VIR2101 VBUS_D C8 100nF U3 D3 BAS21 HallC HallB HallA Q2 SUD35N05-26L R13 R12 R11 PH_C PH_B PH_A 100 100 100 HallC HallB HallA TP2 TP3 TP4

10K

HO VS COM LO
HallB HallC HallA
IR2101S PH_C

R8

7 6 5

4.7K

C9 1nF

C10 1nF

H_B L_B

H_B L_B

2 3 HIN VCC LIN VB


R15 22 C12 PH_B TP5 100nF R19 22 VIR2101 VBUS_D C14 R20 15K 100nF U4 D4 BAS21 C16 R23 22 C17 TP9 100nF R24 22 PH_A Q6 SUD35N05-26L Q5 SUD35N05-26L 10nF Q4 SUD35N05-26L PH_B Q3 SUD35N05-26L

1 8

R16

R14

C11 1nF

H_A L_A

HIN VCC LIN VB

R21

R22

DAC_OUT

10K IR2101S

10K

HO VS COM LO

7 6 5

PH_A

Drawn By: G ALLAIN


Title Size

ATAVRMC1 (POWER BRIDGE)


Document Number

A4
Date: 11 April 2005
4 3 2

AVR 492 Application Note

7518AAVR07/05
VIR2101 VBUS_D VBUS_D 100nF U2 D2 BAS21 VCC5V C6 R5 VCC5V
D

VBUS_D C5

R49

VIR2101

D7

SMBJ18(not mounted)

H_C L_C

H_C L_C

2 3 HIN VCC LIN VB

1 8

J5 HS_C HS_B HS_A PH_C PH_B PH_A

8 7 6 5 4 3 2 1
C

BLDC Con

4
IR2101S

10K

10K

HO VS COM LO

7 6 5

TP6 R17 4.7K R18 R_Shunt V_Shunt+ V_Shunt+ C13 1nF V_ShuntV_ShuntTP7 TP14 VCC5V C15 Cur_Dtc 100nF TP8 U5 V_ShuntB

V_Shunt+

H_A L_A

2 3

1 8

Over_Current Over_Cur LMV7219M5

Over_Current

Rev 1.6 Sheet 2


1

of

25

Atmel Corporation
2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 487-2600

Atmel Operations
Memory
2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314

RF/Automotive
Theresienstrasse 2 Postfach 3535 74025 Heilbronn, Germany Tel: (49) 71-31-67-0 Fax: (49) 71-31-67-2340 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759

Regional Headquarters
Europe
Atmel Sarl Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland Tel: (41) 26-426-5555 Fax: (41) 26-426-5500

Microcontrollers
2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 La Chantrerie BP 70602 44306 Nantes Cedex 3, France Tel: (33) 2-40-18-18-18 Fax: (33) 2-40-18-19-60

Biometrics/Imaging/Hi-Rel MPU/ High Speed Converters/RF Datacom


Avenue de Rochepleine BP 123 38521 Saint-Egreve Cedex, France Tel: (33) 4-76-58-30-00 Fax: (33) 4-76-58-34-80

Asia
Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369

ASIC/ASSP/Smart Cards
Zone Industrielle 13106 Rousset Cedex, France Tel: (33) 4-42-53-60-00 Fax: (33) 4-42-53-60-01 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Scottish Enterprise Technology Park Maxwell Building East Kilbride G75 0QR, Scotland Tel: (44) 1355-803-000 Fax: (44) 1355-242-743

Japan
9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan Tel: (81) 3-3523-3551 Fax: (81) 3-3523-7581

Literature Requests
www.atmel.com/literature

Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise,to anyintellectualproperty right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN ATMELS TERMS AND CONDI-TIONS OF SALE LOCATED ON ATMELS WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORYWARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULARPURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDEN-TAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUTOF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes norepresentationsor warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specificationsand product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmels products are not intended, authorized, or warranted for useas components in applications intended to support or sustainlife.

Atmel Corporation 2005 . All rights reserved. Atmel, logo and combinations thereof, are registered trademarks, and Everywhere You Are SM are the trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others. Printed on recycled paper.
7518AAVR07/05

You might also like