You are on page 1of 94

1590 BDC

Cheap and Easy Control of


Brushed DC and AC Induction
Motors
2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

Objectives

Understand brushed DC motors


Learn simple control techniques
Understand Pulse Width Modulation
Explain the benefits of variable speed
control
Explain AC Induction Motor operation
Learn variable speed control technique
for ACIM

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

Cheap and Easy Control


of Brushed DC Motors

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

BDC Agenda

BDC Basics

Control Types

DC Motor Construction
Motor Types

PIC MCU Peripherals


Drive Types

Demo using PIC16F1947

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

BDC Basics

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

BDC Motor

Rotary Parts

Motor Shaft
Commutator
Windings

Stationary Parts

Stator
Brushes

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

BDC Rotor

The rotor shaft mounts to the case with either


bearings or bushings
The rotor is supplied current through a
commutator
Multiple windings in laminated steel
Shaft

Commutator

Windings
2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

BDC Stator

Mounts to the inside of the case


Surrounds the Rotor / Armature
Generates a stationary magnetic field
Permanent
magnets

2011 Microchip Technology Incorporated. All Rights Reserved.

Electromagnetic
windings

1590 BDC

Slide

BDC Motor Types

The type of stator defines the motor

Permanent Magnet
Shunt wound
Series wound
Compound wound

Shunt + Series

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

Permanent Magnet

Most common
Used in fractional horsepower applications
More cost effective than wound stators
Torque, limited due to constant stator field

Good low end ( low speed ) torque


Limited high end ( high speed ) torque

Responds very quickly to voltage changes (good speed control)


Brushes
DC
Voltage
Supply

Rotor

S
Permanent
Magnetic Poles

Drawback, Magnets lose their magnetic properties over time

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

10

Shunt Wound

Decreasing torque at high speed


At low speed, higher more consistent torque
Excellent speed control
Typically used in Industrial and automotive applications
No loss of magnetism over time as with PMDC motors

ITot
DC
Voltage
Supply

ITot = IShunt + IMotor

IShunt
Shunt
Field

IShunt

IMotor
IMotor

Rotor

Brushes

Heavy
Load

More expensive than PMDC motors


Motor Runaway, if the shunt current goes to zero

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

11

Series Wound

Great slow speed torque ( low end )

But, as load is removed, speed increases sharply

Ideally suited for heavy loads, examples: cranes and winches

I = ISeries + IMotor

Series
Field
DC
Voltage
Supply

I
Rotor

Brushes

Heavy
Load

Poor high speed torque ( high end )


More expensive than PMDC
Poor speed control due to the series stator field
Motor Runaway, if the series field is shorted

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

12

Compound Wound

Has the performance properties of both SHWDC and SWDC motors


High torque at low speed w/ heavy loads, SHWDC motors
Great speed control, SWDC motors
Great for Industrial and automotive applications. Example:
generators
Motor Runaway, less likely b/c shunt current must go to zero and
series field must short

ITot
DC
Voltage
Supply

ITot = I1 + I2

Series
Field

I2

I2 = ISeries + IMotor

Shunt
Field
Rotor

Brushes

IShunt = I1

Heavy
Load

More expensive then PMDC, SHWDC, and SWDC

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

13

Brushes and Commutation


Commutator

Brushes

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

14

Brushes and Commutation


Stator Magnets

Rotor
Windings
Brushes

Commutator

Terminals

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

15

Control Types

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

16

Control Types

Chopper

Half Bridge

Low Side Drive


High Side Drive

Low Side Drive


High Side Drive

Full Bridge (H-Bridge)

Bi-directional

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

17

Low Side Drive

Simple On/Off
One I/O port to
control
No high side
driver
Inexpensive

One direction

D1

Motor

Micro

R1

Controlled

SW1
R2

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

18

High Side Drive


High Side Drive

One direction

R2

Micro

One I/O port to


control
High side driver
needed
Simple On/Off
Safety

R1

SW1

Controlled

Motor

2011 Microchip Technology Incorporated. All Rights Reserved.

D1

1590 BDC

Slide

19

Half Bridge
VBUS

Low Side Drive


Motor
D1

SW2
OFF

Micro
Controlled

ON

Micro

SW1

Controlled

Forward
2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

20

Half Bridge
VBUS

Low Side Drive


Motor
D1
Micro

SW2
ON

Controlled

OFF
SW1

Micro
Controlled

Brake
2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

21

Half Bridge
VBUS

Low Side Drive


Motor
D1
Micro

SW2
ON

Controlled

ON
SW1

Micro
Controlled

Warning
2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

22

Half Bridge
VBUS

High Side Drive

Micro

SW1
ON

Controlled

Micro

OFF

Controlled

SW2

D1

Motor

Forward
2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

23

Half Bridge
VBUS

High Side Drive

Micro

SW1
OFF

Controlled

Micro

ON
SW2

Controlled

D1

Motor

Brake
2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

24

Half Bridge
VBUS

High Side Drive

Micro

SW1

Controlled

ON

Micro
Controlled

ON

SW2

D1

Motor

Warning
2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

25

Half Bridge

Advantages

Ability to brake the motor


Safety (High Side Drive)

Disadvantages
Only one direction
More parts, 2 outputs to control
Shoot-Through (both FETS ON)

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

26

Full Bridge
VBUS

D1

Micro
Controlled

Micro
Controlled

D2

ON

SW3
OFF

OFF

ON

SW1

SW2

Motor

SW4

D3

D4

Micro
Controlled

Micro
Controlled

Forward
2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

27

Full Bridge
VBUS

D1

Micro
Controlled

Micro
Controlled

SW1
OFF

ON
SW2

D2

Motor

D3

D4

Micro

SW3
ON

Controlled

OFF

Micro

SW4

Controlled

Reverse
2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

28

Full Bridge
VBUS

D1

D2

Micro

Controlled

Micro
Controlled

SW1
OFF

ON
SW2

SW3
OFF

Motor

ON
SW4

D3

D4

Micro
Controlled

Micro
Controlled

Brake
2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

29

Full Bridge
VBUS

D1

Micro
Controlled

Micro
Controlled

SW1
ON

ON
SW2

D2

SW3
ON

Motor

ON
SW4

D3

D4

Micro
Controlled

Micro
Controlled

Warning
2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

30

Full Bridge

Advantages

Bi-Directional control
Braking
Safety (High Side Drive)

Disadvantages
Most complicated
4 outputs to control
Shoot-Through (both FETS ON)

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

31

Topology Review

Chopper

Simple, one output control


Fewest features

Half Bridge
A little more complex, two output control
Adds the Braking features

Full Bridge
Most complicated
Adds the features of Braking and Reverse

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

32

Speed Control

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

33

Firmware Control
VBUS

D1

Motor

Simple On/Off

Firmware
intensive

Lots of
attention to
control

Micro
R1

Controlled

SW1
R2

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

34

PWM Control
(Pulse Width Modulation)
We control the speed by varying the voltage
across the motor
Voltage Across MotorAvg.Volt = VoltageSupply Duty Cycle
= VDD

Pulse Width

Period

2011 Microchip Technology Incorporated. All Rights Reserved.

(Pulse Width / Period)

1590 BDC

Slide

35

PWM Control
Voltage Source

MOUTON MOTOR COMPANY

PWM
Equates to

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

36

PWM Control

Brushed DC Motor acts like an Inductor


Current doesnt change instantaneously
As inductance increases, the slower the current
changes
V(t) = L
di/dt

Voltage across motor is directly proportional to RPM

100% RPM = 100% Duty cycle

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

37

PWM Control
Voltage Across Motor

Actual Current

Average Current

Time

Accelerate

Decelerate

2011 Microchip Technology Incorporated. All Rights Reserved.

Voltage
Actual Current
Average Current
1590 BDC

Slide

38

CCP
Capture/Compare/PWM

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

39

PWM Control
Signal Period

Pulse Width

TMR2 = PR2
TMR2 = 0

TMR2 = CCPR1L:CCP1CON(<5:4>)

Equations
Period PWM(seconds) = (PR2 + 1)

Tosc

TMR2 Prescaler

Duty Cycle PWM(ratio) = (CCPR1L:CCP1CON<5:4>) / 4 ( PR2 + 1 )

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

40

ECCP
(Enhanced Capture/Compare/PWM)

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

41

PWM Control

Half-Bridge PWM
Generates a PWM signal on two outputs
Microcontroller
P1A Modulated

P1B Modulated

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

42

PWM Control
Examples:
VDD
ON

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

43

PWM Control

Full-Bridge PWM, Forward Mode


All four pins are used as outputs
Microcontroller

High

P1A Active
P1B Inactive

Low

P1C Inactive

Low

P1D Modulated

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

44

PWM Control
Example:
Microcontroller
ON

ON

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

45

PWM Control

Full-Bridge PWM, Reverse Mode


All four pins are used as outputs
Microcontroller
Low

P1A Inactive

P1B Modulated
High

P1C Active
Low

P1D Inactive

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

46

PWM Control
Example:
Microcontroller

ON

ON

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

47

BDC Demos
F1 LV Eval. Board

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

BDC Add-on

Slide

48

BDC DEMOS

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

49

Further Reading

AN847 RC Model Aircraft Motor Control


AN893 Low-Cost Bidirectional Brushed DC Motor
Control Using the PIC16F684
AN894 Motor Control Sensor Feedback Circuits
AN898 Determining MOSFET Driver Needs for
Motor Drive Applications
AN905 Brushed DC Motor Fundamentals
DS41233 DC Motor Control Tips n Tricks
DS41214 CCP and ECCP Tips n Tricks

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

50

Cheap and Easy Variable


Speed ACIM Control

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

51

ACIM Agenda

Benefits of variable speed ACIM control


3-ph ACIM Basics
Motor construction
How does an ACIM produce torque?
Variable Speed Control
Hardware Requirements
V/Hz Control Method
Software for V/Hz Control
Demo using PIC16LF1947

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

52

Variable Speed Benefits

AC induction motors designed to operate from line


power
Operate motor at reduced load when possible
Example fans, pumps
Replace inefficient mechanical drive-train with
variable speed
Typical chain/sprocket drive 90%
Typical pulley drive 93%
Typical worm gear drive 69%

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

53

ACIM Basics

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

54

ACIM Stator

Terminal box

Motor casing

Stator coils

Stator slots
2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

55

AC Stator
Stator supplied
with 3-phase AC
voltage source for
fixed speed
operation
Va

2011 Microchip Technology Incorporated. All Rights Reserved.

3 Phase
ACIM
Vb

1590 BDC

Vc

Slide

56

ACIM Stator

Rotating flux

Generated by alignment of
3 phase windings on Stator

Synchronous
speed of field
depends on
number of poles

2 pole@ 60 Hz,
3600 rpm
4 pole(shown) @
60 Hz, 1800 rpm

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

57

ACIM Rotor
Bearings

Driving end

Shorting rings

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Internal fan

Slide

58

ACIM Rotor

Rotor currents generated by stator


field
Energized rotor generates a
secondary field, allowing motor to
produce torque
Field speed must be different from
rotor speed, the motor must have
slip to operate

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

59

ACIM Equations

Flux

Im

Torque
Is

Im

ns

Ir
Ir

2011 Microchip Technology Incorporated. All Rights Reserved.

120 f
p

ns

nr
ns

1590 BDC

Slide

60

ACIM Torque vs. Slip


Torque
Stall Torque
Starting Torque
Operating Point
Motor

Braking

Synchronous Speed

Rotor Speed

Generator

SLIP
1.5

1.0

0.5

2011 Microchip Technology Incorporated. All Rights Reserved.

-0.5

1590 BDC

-1.0

Slide

61

Variable Speed Control

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

62

ACIM Torque vs. Slip


Variable Frequency
15 Hz

30 Hz

45 Hz

60 Hz

Torque

Variable Speed Operating Region

Rotor Speed

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

63

V/Hz Profile
240

Volts RMS

200

160

High Amplitude
Limit

Boost
Region

120
Constant V/F
Region

80

40
Low Frequency
Cutoff
20

40

60

Frequency (Hz)
2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

64

V/Hz Control

PID
r

+-

Limits

VF curve

P
W
M

Motor

Feedback
device

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

65

ACIM Hardware

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

66

Resources For 3-Phase


ACIM

Need 1 Timer
and 3 ECCPS
PIC16F193X
PIC16F194X
PIC18F2XK22
PIC18F4XK22

ECCP1
Timer2
ECCP2

Timer4

ECCP3

CCP4
Timer6
CCP5

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

67

ACIM Inverter
+V
P1A

ECCP1

P1B

P2A

P3A

P2B

3 Phase
ACIM

P3B

ECCP2
ECCP3

Timer2

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

68

Dead Time

Use ECCPs in half bridge mode


with dead time
ECCP duty cycle will set average
voltage applied to motor phase
Dead Time

P1A
P1A

P1B
P1B

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

69

Software
Implementation

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

70

Sinusoidal PWM
Modulation

PWM voltage applied


to each motor phase
Motor integrates
PWM voltage and
produces sinusoidal
current with small
ripple at carrier
frequency
Average phase
current proportional
to duty cycle
Duty cycle for each
phase is modulated
over time to get
desired frequency
and phase

2011 Microchip Technology Incorporated. All Rights Reserved.

Motor Phase Current

VDC

PWM Applied to Motor Phase

1590 BDC

Slide

71

Modulation Function

Lookup from
wavetable of
size 2N
Wavetable
contains one
cycle of
waveshape
Use 16-bit
variable to
track phase

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Phase

angle

0x0000

0 deg

0x4000

90 deg

0x5555

120 deg

0x8000

180 deg

0xAAAA

240 deg

0xFFFF

359.99 deg

Slide

72

Modulation Function

Phase variable will be used as index


to LUT
Periodically add a constant value to
Phase variable to create the desired
frequency
Adjust adder value to change
frequency

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

73

Modulation Function
15

Phase

Add at Timer interrupt


DeltaPhase

6-bit lookup index

2011 Microchip Technology Incorporated. All Rights Reserved.

DeltaPhase value is added to


Phase value at a fixed
periodic rate to set the
modulation frequency

64 Entry
Sine Wave
Table

1590 BDC

Slide

74

Sinusoidal PWM
Modulation
Motor Phase Current

VDC

const int Wave[] =


{0,11,23,34,44,54,63,71,77,82,85,88,89,88,87,84,81,76,71,
66,60,54,48,42,36,31,25,20,16,11,7,3,-1,-5,-9,-13,-18,
-22,-27,-32,-38,-44,-50,-56,-62,-67,-73,-78,-82,-86,-88,
-90,-90,-90,-87,-84,-78,-65,-56,-46,-36,-24,-13};

DutyCycle Wave[index ] Amplitude HALF _ DUTY


2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

75

Phase Offsets

We need LUT values for 3 phases


Add 0x5555 to Phase to get Phase 2
lookup value
Add 0xAAAA to Phase to get Phase 3
lookup value
Each lookup value is then scaled to
set amplitude
8-bit match used for scaling to
conserve 8-bit CPU resources

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

76

Modulation Interrupt Rate and


Modulation Frequency

Modulation Frequency
PWM Frequency = 20,000 Hz
Postscaler = 10:1 2000 Hz
interrupt rate
f mod

2000
DeltaPhase
16
2

DeltaPhase 0.0305

For 60 Hz, DeltaPhase = 1966

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

77

Wave Lookup Table

Motor sees line-line voltage, NOT


phase voltage
Sinusoidal modulation does not
make maximum use of inverter DC
bus
Because of 3-phase system, only get
86% of DC bus line-to-line

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

78

Sine Wavetable
1.50

Modulation Index

1.00
0.50

Sine Va
Sine Vb
Line to Line

0.00
0

60

120

180

240

300

-0.50
-1.00
Angle (degrees)

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

79

Sine + 3rd Harmonic


86% fundamental + 14% 3rd harmonic

1.50
1.00
0.50
0.00
0

60

120

180

240

300

Va
Vb
Line to Line

-0.50
-1.00
-1.50

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

80

V/Hz Profile

User speed input


needs to be
translated to a
voltage and
frequency
For our demo, we
will use a
potentiometer
Translate ADC
result to simple
linear profile

2011 Microchip Technology Incorporated. All Rights Reserved.

DeltaPhase
0

ADCresult 2

DeltaPhase 2046

ADCresult
ModVoltage
8
0 ModVoltage 127

1590 BDC

Slide

81

Modulation Function
Benchmarks

PIC16F1XXX + HI-TECH C Compiler


742 Cycles
19% CPU at 2000 Hz rate
PIC18 + C18 Compiler
524 cycles
7% CPU at 2000 Hz rate

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

82

Processor Choice

16-bit, 32 bit, and DSC solutions


provide:
Algorithms for better dynamic
response
Algorithms to eliminate sensors
8-bit fine for many applications

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

83

ACIM Demo

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

84

ACIM Summary

8-bit MCUs with the right


stuff can readily support
variable speed ACIM
Some apps may require
16-bit performance
Questions?

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

85

Appendix
ACIM Source Code and Device

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

86

PIC16 Devices for ACIM


Pins

LCD

10-bit
ADC

Timers
8b/16b

ECCP/
CCP

COMMS

256

28

60

11

4/1

3/2

UART, I2C, SPI

256

256

40/44

96

14

4/1

3/2

UART, I2C, SPI

8K

512

256

28

60

11

4/1

3/2

UART, I2C, SPI

Now

8K

512

256

40/44

96

14

4/1

3/2

UART, I2C, SPI

PIC16F1938

Now

16K

1K

256

28

60

11

4/1

3/2

UART, I2C, SPI

PIC16F1939

Now

16K

1K

256

40/44

96

14

4/1

3/2

UART, I2C, SPI

PIC16F1946

Now

8K

512

256

64

184

17

4/1

3/2

2xUART, 2xI2C,
2xSPI

PIC16F1947

Now

16K

1K

256

64

184

17

4/1

3/2

2xUART, 2xI2C,
2xSPI

FLASH RAM
DataEE
(Words) (Bytes) (Bytes)

Device

Available

PIC16F1933

Now

4K

256

PIC16F1934

Now

4K

PIC16F1936

Now

PIC16F1937

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

87

PIC18 Devices for ACIM

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

88

Interrupt Service Routine


static void interrupt ISR(void)
{
if(PIR1bits.TMR2IF)
{
PIR1bits.TMR2IF = 0;
// Add phase difference to adjust modulation angle
Phase += Delta_Phase;
// Perform sine + 3rd harmonic modulation
Modulate(ModVoltage,Phase,&PWM);
// Write the new duty cycles to the PWM outputs
WriteDutyCCP1(PWM.Phase1);
WriteDutyCCP2(PWM.Phase2);
WriteDutyCCP3(PWM.Phase3);
}
}

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

89

Modulate () Function
void Modulate(int volts, unsigned int angle, tDuty *dutycycle)
{
union{
unsigned int ui;
unsigned char uc[2];
}phase_index;
int temp;
if(volts > 127) volts = 127;
// Calculate the duty cycle for Phase 1
phase_index.ui = angle;
// Get the lookup value using upper 6 bits of phase index.
temp = sinplus3rd[phase_index.uc[1] >> 2];
// Scale the sine table value by the volts parameter.
temp = (temp * volts) >> 7;
// Introduce a 50% offset into the sine value.
dutycycle->Phase1 = (temp << 2) + HALF_DUTY;
// Calculate the duty cycle for Phase 2
// Everything is the same as phase 1, except for the phase offset.
phase_index.ui += ONE_TWENTY_DEG;
temp = sinplus3rd[phase_index.uc[1] >> 2];
temp = (temp * volts) >> 7;
dutycycle->Phase2 = (temp << 2) + HALF_DUTY;
// Calculate the duty cycle for Phase 3
// Everything is the same as phase 1, except for the phase offset.
phase_index.ui += ONE_TWENTY_DEG;
temp = sinplus3rd[phase_index.uc[1] >> 2];
temp = (temp * volts) >> 7;
dutycycle->Phase3 = (temp << 2) + HALF_DUTY;
}
2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

90

Shunt Wound
ITot
DC
Voltage
Supply

ITot = IShunt + IMotor


IShunt
Shunt
Field

IShunt

IMotor
IMotor

Rotor

Brushes

Heavy
Load

As VSupply , ITot , stator/rotor field , speed , Torque


As motor load , IMotor , IShunt , stator field , rotor field , speed ,
Torque

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

91

Series Wound
I = ISeries + IMotor

Series
Field
DC
Voltage
Supply

I
Rotor

Brushes

Heavy
Load

As VSupply , I , Stator/Rotor field , speed , Torque


As motor load , I , Stator/Rotor field , speed , Torque

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

92

Compound Wound
ITot = I1 + I2

Series
Field

ITot

I2 = ISeries + IMotor

I2

DC
Voltage
Supply

Shunt
Field
Rotor

IShunt = I1

Brushes

Heavy
Load

As motor load , IShunt , shunt field , I2 , Series field/Rotor


field , speed , thus torque

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

93

Trademarks

The Microchip name and logo, the Microchip logo, dsPIC, KeeLoq, KeeLoq
logo, MPLAB, PIC, PICmicro, PICSTART, PIC32 logo, rfPIC and UNI/O are
registered trademarks of Microchip Technology Incorporated in the U.S.A.
and other countries.
FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor, MXDEV,
MXLAB, SEEVAL and The Embedded Control Solutions Company are
registered trademarks of Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, chipKIT, chipKIT logo,
CodeGuard, dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN,
ECONOMONITOR, FanSense, HI-TIDE, In-Circuit Serial Programming,
ICSP, Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB, MPLINK,
mTouch, Omniscient Code Generation, PICC, PICC-18, PICDEM,
PICDEM.net, PICkit, PICtail, REAL ICE, rfLAB, Select Mode, Total
Endurance, TSHARC, UniWinDriver, WiperLock and ZENA are trademarks
of Microchip Technology Incorporated in the U.S.A. and other countries.
SQTP is a service mark of Microchip Technology Incorporated in the
U.S.A.
All other trademarks mentioned herein are property of their respective
companies.
2011, Microchip Technology Incorporated, All Rights Reserved.

2011 Microchip Technology Incorporated. All Rights Reserved.

1590 BDC

Slide

94

You might also like