Professional Documents
Culture Documents
This document presents an overview of the Motor Con- FIGURE 1: CURRENT WAVEFORM
trol PWM module (MCPWM) present on the motor con-
FILTERED BY THE MOTOR'S
trol family of dsPIC30F Digital Signal Controllers. Code
WINDINGS
examples are included for a typical three-phase AC
Induction Motor (ACIM) control application using a
Three-Phase Inverter topology.
PWM1H
Duty Cycle Dead-Time Unit
Generator #1
DTA DTB PWM1L
+V
Period/2
PTPER
PTMR
Value
PDC1
PDC2
PWM1H
PWM2H
PDCx
Value
Period
PTPER = ⎛ --------------- – 1⎞ ÷ 2
F CY
⎝ F PWM ⎠
void InitMCPWM(void)
{
TRISE = 0x0100; // PWM pins as outputs, and FLTA as input
PTPER = (FCY/FPWM - 1) >> 1; // Compute Period for desired frequency
OVDCON = 0x0000; // Disable all PWM outputs.
DTCON1 = DEADTIME; // ~2 us of dead time @ 20 MIPS and 1:1 Prescaler
PWMCON1 = 0x0077; // Enable PWM output pins and enable complementary mode
PDC1 = PTPER; /* 0 Volts on Phase A. This value corresponds to
50% of duty cycle, which in complementary mode
gives an average of 0 Volts */
PDC2 = PTPER; // 0 Volts on Phase B.
PDC3 = PTPER; // 0 Volts on Phase C.
IFS2bits.PWMIF = 0; // Clear PWM Interrupt flag
IEC2bits.PWMIE = 1; // Enable PWM Interrupts
OVDCON = 0x3F00; // PWM outputs are controller by PWM module
PTCONbits.PTMOD = 2; // Center aligned PWM operation
Phase = 0; // Reset Phase Variable
Delta_Phase = _DELTA_PHASE; // Initialize Phase increment for 60Hz sine wave
PTCONbits.PTEN = 1; // Start PWM
return;
}
Driving Three-Phase ACIM with the used as a 16-bit pointer to the table with 0x0000
MCPWM representing 0º and 0xFFFF representing 359.99º. At
each PWM period interrupt (50 µs), the Delta_Phase
This section of the document shows you how to gener- variable is added to Phase. The value of
ate a three-phase sine wave using the MCPWM fea- Delta_Phase determines how fast the code moves
tures described in the previous section. A code through the sinusoidal data table and, as a result, sets
example is provided to show the actual implementation the modulation frequency.
of this application.
Figure 6 shows the look-up table and the three sine
To generate the three phase outputs, sinusoidal data waves achieved with the MCPWM module. You can
for a complete electrical cycle is provided in a 64-word see the average voltage superimposed on the PWM
table. The data is in 16-bit signed fractional format nor- signals, representing the voltage amplitudes to be fed
malized to the range -1 to 1. A variable called Phase is to the motor's windings.
0 PWM1H
...
PWM1L
32767
64 ... PWM2H
Word
Table 0 PWM2L
...
PWM3H
-32767
... PWM3L
FIGURE 7: SCALING OF SINE WAVE TABLE FOR THE DUTY CYCLE REGISTERS
Source from Sine Wave Table Scaling Operation Resulting Offset of Negative Values
PTPER
0.999 (0x7FFF) 2xPTPER
x +
0 x + PTPER
-1 (0x8000) 0
The modulation operations and the associated sine The following code example performs the modulation
wave table are written so that you can reuse them in for Phase B of the three-phase ACIM.
your own code. In practice, you may want to pre-scale
the sine table data so you do not have to do as much
scaling when modulating the sine wave.
The same code applies for the other two phases. For Notice that the multiplication is coded in assembly. This
Phase A, the Phase_Offset value is 0 (0°). For is done to take advantage of the fractional
Phase C, the Phase_Offset value is 0xAAAA (240°). multiplication available in the dsPIC® DSC.
100 KΩ
Phase B Filter Output
10nF
Phase A
• Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
• Microchip is willing to work with the customer who is concerned about the integrity of their code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
07/01/05