AC Induction Motor (ACIM) Control Using PIC18Fxx31 AC Induction Motor (ACIM) Control Using PIC18Fxx31 © 2003 Microchip Technology Incorporated. All Rights Reserved. AC induction Motor Control Using PIC18Fxx31 Slide 1 Welcome to the Microchip Web Seminar on AC Induction Motor Control using the PIC18Fxx31. My name is Jon Burroughs, I am the AMAD applications engineer for the PIC18Fxx31. This Web Seminar is a summary of the application note “VF Motor Control of AC Induction Motors Using the PIC18F4431”, which will soon be available on the Microchip website. © 2004 Microchip Technology Inc. Page 1 AC Induction Motor (ACIM) Control Using PIC18Fxx31 Agenda ● ● ● Overview of motor control solutions from Microchip PIC18Fxx31 peripherals for motor control ACIM motor control using PIC18Fxx31 ● ● ● ● Open V/F loop control Closed loop control using Quadrature encoder Comparison to other PICmicro® microcontroller solutions Recommended resources © 2003 Microchip Technology Incorporated. All Rights Reserved. AC induction Motor Control Using PIC18Fxx31 Slide 2 This presentation is divided into the following topics: •First, a brief overview of motor control solutions from Microchip, •Second, a summary of the PIC18F4431 peripherals for motor control. •Next, the main body of the presentation will be a discussion of ACIM control using the PIC18Fxx31 in standard open loop V/F control and in closed loop with an optical encoder for speed feedback. •Finally, we will compare ACIM control solutions implemented with several other PIC® microcontrollers. •Because this presentation is relatively short, additional resources for learning more are recommended at the end of the presentation. © 2004 Microchip Technology Inc. Page 2 AC Induction Motor (ACIM) Control Using PIC18Fxx31 Motor Control from Microchip ● ● ● ● Complete solutions for Stepper, Brushed DC, BLDC, ACIM & SR motors utilizing PIC16, PIC18 & dsPIC devices Microchip Opamps & International Rectifier drivers Provide everything a design engineer needs: ● Low-risk product development ● Lower total system cost ● Faster time to market ● Outstanding technical support ● Dependable delivery & quality Visit us at www.microchip.com/motor © 2003 Microchip Technology Incorporated. All Rights Reserved. AC induction Motor Control Using PIC18Fxx31 Slide 3 Microchip Technology offers a broad product portfolio that provides a complete system solution for your brushed DC motor, variable speed brushless DC motor, AC induction motor, switched reluctance motor and stepper motor applications. This includes the microcontroller with firmware to drive the motor, analog op amps and comparators for sensors or feedback and power electronics from Microchip and International Rectifier. With our sophisticated development systems and technical documentation, Microchip makes it easy for designers of all experience levels to complete a high performance electronic motor control design quickly and cost effectively. Microchip provides everything a motor control design engineer needs: low-risk product development, lower total system cost, faster time to market, outstanding technical support and dependable delivery and quality. For access to Microchip’s complete motor control design resources, visit the Motor Control Design Center at www.microchip.com/motor. © 2004 Microchip Technology Inc. Page 3 AC Induction Motor (ACIM) Control Using PIC18Fxx31 PIC18Fxx31 Overview Timer0 Timer1 Timer2 Data EEPROM 256 Bytes Flash Program Memory (16KB) CCP (2K) RAM (768B) PBOR LVD © 2003 Microchip Technology Incorporated. All Rights Reserved. SSP 200 Ksps 10-Bit ADC Timer5 14-Bit Power Control PWM Motion Feedback - 3 input captures - Quadrature Encoder Fault Interface AC induction Motor Control Using PIC18Fxx31 Slide 4 PIC18Fxx31 family of microcontrollers features 4 parts, having 28 pin and 40 pin packages with 8Kbytes and 16Kbytes of program memory. The major peripherals that are useful in motor control are indicated above in the darker blue blocks. Power Control PWM, Motion Feedback Module, Fault Inputs, and High speed Analog-to-Digital Converter, make the family well-suited to a variety of motor control tasks. Main features of PCPWM include: • Up to 8 channels output or 4 pairs complimentary outputs • Up to 14 bits PWM of resolution • Center aligned or edge aligned PWM operation. •Programmable dead band control for complementary outputs • Hardware Fault interface pins for fast PWM shut down in the event of fault. Main features of High speed ADC include: • Up to 9 channels input, with 2 Sample and Hold circuits • Simultaneous and sequential conversion capabilities • 4 word deep FIFO with flexible interrupt settings Main features of Motion Feedback Module include: •QEI for measuring, position velocity and direction of rotation •3 Input Capture pins with multiple modes for pulse width and frequency measurements. In this presentation we’ll examine how to use the PCPWM, Fault Inputs, and Motion Feedback Module to control a 3-phase induction motor. © 2004 Microchip Technology Inc. Page 4 AC Induction Motor (ACIM) Control Using PIC18Fxx31 Drive Topology VDC+ H2 H1 H3 Phase B Phase C Phase A L1 L2 L3 VDC© 2003 Microchip Technology Incorporated. All Rights Reserved. AC induction Motor Control Using PIC18Fxx31 Slide 5 As you may already know, control of a 3-phase AC induction motor requires pulsewidth modulated control of the six switches of a 3-phase inverter bridge connected to the 3 legs of the motor’s windings. The six switches form 3 pairs of “half-bridges”, which can be used to connect each leg to the positive or the negative high-voltage DC bus. As can be seen from the figure, two switches on the same “half-bridge” must never be on simultaneously, otherwise the positive and negative buses will be shorted together. When one switch is on, the other must be off; thus they are driven as complementary pairs. It should also be noted that the switching devices used in the half-bridge (in this case, IGBT’s) often require more time to turn off than to turn on. For this reason, a minimum dead-time must be inserted between the off and on time of complimentary channels. The PCPWM is well-suited for this application because it can provide up to four pairs of complimentary outputs with programmable dead-time. © 2004 Microchip Technology Inc. Page AC Induction Motor (ACIM) Control Using PIC18Fxx31 3 Phase Action R Y B -ΦB +ΦY 120° +ΦR 120° 120° -ΦY 0 60 120 180 240 © 2003 Microchip Technology Incorporated. All Rights Reserved. 300 -ΦR +ΦB 360 AC induction Motor Control Using PIC18Fxx31 Slide 6 To drive the AC induction motor, the duty cycles of the PWM outputs to the 3phase bridge are modulated to synthesize sinusoidal waveforms (three-phase AC) across the 3 motor windings, as depicted in this slide. When 3-phase AC is applied to the three stator windings (sinusoidal currents, equal in amplitude and frequency, but offset from each other by 120 degrees) the current in the stator windings generates a rotating magnetic field (shown here as the rotating vectors on the x-axis.) This rotating field induces electromotive force in the rotor, which in turn produces a magnetic field in the rotor that attempts to align with the rotating magnetic field in the stator. This causes the rotor to rotate. See the ap notes listed in the resource section at the end of this presentation, for a more detailed discussion of motor construction which makes this happen.. © 2004 Microchip Technology Inc. Page 6 AC Induction Motor (ACIM) Control Using PIC18Fxx31 Open Loop Control AC in AN0 Potentiometer AN1 AN2 AN3 AN4 AVdd AVss OSC1 OSC2 RC0 DC bus current Reference + + 1 28 RB7/PGD 2 27 RB6/PGC 3 26 PWM4 B-Low 4 25 PWM5 B-High 5 24 PWM3 Y-High 23 PWM2 Y-Low 22 PWM1 21 PWM0 R-High R-Low 20 Vdd 19 Vss 6 7 8 9 10 PIC18F2431 /MCLR 11 18 RC7/RX/DT /FLTA/CCP2 12 17 RC6/TX/CK /FLTB/CCP1 13 16 RC5/INT2 RC3/INT0 14 15 RC4/INT1 © 2003 Microchip Technology Incorporated. All Rights Reserved. - DC bus Motor 3 phase Inverter bridge DC bus current AC induction Motor Control Using PIC18Fxx31 Slide 7 Here’s a typical example of how the PIC18F4431 is configured to control a 3-phase AC induction motor: A speed reference is provided by a potentiometer connected to analog channel 0. The PCPWM within the microcontroller is used in complimentary mode to generate three pairs of complimentary outputs on PWM channels 0-6. A built-in dead-time generator is used to insert the necessary deadtime between complimentary channels. The PWM outputs drive a 3-phase inverter bridge, which can be an integrated gate driver and 3-phase inverter, such as the IRAMS10UP60A from International Rectifier. The 3 motor phases of the ACIM are connected to a three-phase inverter bridge. DC bus current is monitored by measuring voltage across a shunt resistor and feeding it to a comparator. The bus current signal is compared to a reference. The comparator output is connected to the FLTA input of the PIC18F4431. When operated in cycle-by-cycle mode, an overcurrent condition will result in shut-off the PWM outputs in hardware for as long as the overcurrent condition exists. In addition, a flag is set which enables firmware to take corrective action, such as reducing the target speed. © 2004 Microchip Technology Inc. Page 7 AC Induction Motor (ACIM) Control Using PIC18Fxx31 Open Loop VF Control ● Vary Voltage and frequency at fixed ratio ● ● ● ● ● PCPWM used in complimentary mode with dead-time to generate 3 output pairs. A sine table is used for calculating the PWM duty cycle of each output pair. 120° phase shift between output pairs. Timer defines the frequency by determining how often the duty cycle is updated. Scaling the maximum duty cycle determines the voltage. © 2003 Microchip Technology Incorporated. All Rights Reserved. AC induction Motor Control Using PIC18Fxx31 Slide 8 The algorithm for controlling the AC induction motor requires that the voltage (amplitude of the sinuisodal inverter drive) and the frequency be varied in a fixed ratio. Speed is controlled by varying the input frequency of the applied alternating current, and torque is maintained constant by varying the voltage in direct proportion to the frequency. To accomplish this, the PCPWM is used in complimentary mode with programmable deadtime to generate 3 complimentary output pairs. A sine table is used for varying the duty cycle of each output pair. A 120 degree offset is maintained between phases by using three offset pointers to the sine table. A timer is used to set frequency by determining how often the duty cycle values are updated. Amplitude is determined by scaling the maximum duty cycle based on the frequency. © 2004 Microchip Technology Inc. Page 8 AC Induction Motor (ACIM) Control Using PIC18Fxx31 Implementing VF Control ● Sine table ● ● ● 3 offset pointers, to give 120° phase shift Timer0 Motor frequency. Timer0 reload value depends up on ● ● ● ● PWM duty cycle the potentiometer setting(frequency) operating frequency number of Sine values in the table In Timer0 overflow ISR, new PWM duty cycles are calculated based on the Frequency and phase angle on the Sine table and loaded to the duty cycle registers. © 2003 Microchip Technology Incorporated. All Rights Reserved. AC induction Motor Control Using PIC18Fxx31 Slide 9 Let’s look at this a little more closely. The duty cycle of the three PWM channels are changed in a regular manner using a Timer0 interrupt in order to synthesize the three-phase waveforms that drive the motor. •A sine table is stored in program memory. Three registers are used as offsets to the table. Each of these offset values is used to point to one of the values in the table, such that there is always a 120 degree phase shift between the phases. •The preload value of Timer0 determines how quickly it will overflow, and therefore how quickly new PWM values are loaded from the sine table. •In this example, the potentiometer connected to AN1 determines the target motor speed. The microcontroller uses the ADC measurement to calculate the maximum PWM duty cycle and the update rate. These parameters determine the amplitude and frequency of the synthesized sine waves that drive the ACIM. •New PWM duty cycles are calculated within the Timer0 interrupt service routine, and Timer0 is preloaded to determine the time until the next Timer0 interrupt. © 2004 Microchip Technology Inc. Page 9 AC Induction Motor (ACIM) Control Using PIC18Fxx31 Closed Loop Control - QEI Potentiometer Motor current Temp. sensor Vdd Vss OSC2 OSC1 DC Bus Current Reference + 11 12 13 14 RC0 15 FLTA/CCP2 16 FLTB/CCP1 17 INT0/RC3 18 RD0 19 RD1 20 © 2003 Microchip Technology Incorporated. All Rights Reserved. RB7/PGD 4 0 RB6/PGC 39 PWM4 B-Low 38 B-High PWM5 37 PIC18F4431 QE interface AC in /MCLR 1 AN0 2 INDX 3 QEA 4 QEB 5 AN4 6 AN5 7 AN6 8 AN7 9 AN8 10 36 PWM3 35 PWM2 34 PWM1 33 32 31 30 29 28 27 26 25 24 23 22 21 + - DC bus Y-High Y-Low R-High R-Low PWM0 Vdd Vss RD7 RD6 RD5 RD4 RC7/RX/DT RC6/TX/CK RC5/INT2 RC4/INT1 RD3 RD2 Motor 3 phase Inverter bridge QE DC Bus current AC induction Motor Control Using PIC18Fxx31 Slide 10 ACIM motors are usually operated in open-loop with no velocity or position feedback. The V/f ratio is maintained constant to provide a constant maximum torque over the operating range. The rotor is assumed to follow the rotating magnetic field created by the 3-phase AC input to the stator windings with the slip frequency being the difference between the frequency of the applied AC in the stator and the rotational frequency of the rotor. The actual torque generated depends upon the degree of slip, Velocity feedback can be used for more precisely controlling motor speed by controlling the slip, and therefore the torque, or by altering the drive frequency to make the rotor speed more closely match the reference speed. To obtain velocity feedback from the rotor, a quadrature encoder mounted to the rotor may be connected directly to the QEA and QEB pins of the microcontroller. By using the Motion Feedback module as a quadrature encoder interface in velocity measurement mode, measuring the the rotational velocity of the motor is easy. © 2004 Microchip Technology Inc. Page 10 AC Induction Motor (ACIM) Control Using PIC18Fxx31 Closed Loop VF Control ● Variety of closed loop methods exist ● ● ● ● ● Speed error = Reference speed - actual speed Output frequency is increased if speed error is positive. Output frequency is reduced if speed error is negative PID algorithm can be implemented to modify output frequency based on speed error. V/F ratio is maintained constant © 2003 Microchip Technology Incorporated. All Rights Reserved. AC induction Motor Control Using PIC18Fxx31 Slide 11 A variety of closed-loop algorithms may be used, ranging from the relatively simple to the very complex. A basic form of closed loop control is to calculate the speed error by comparing the actual speed (as measured by the Quadrature Encode interface) with the reference speed (the target speed as determined by the potentiometer). If the speed error is positive (the target speed is greater than the actual speed) then the drive frequency to the stator is increased. If the speed error is negative, then the drive frequency to the stator is reduced. A PID algorithm can be used to adjust the drive frequency based on the speed error. The voltage is maintained in a constant ratio with the drive frequency as with normal V/F control. As long as the the load does not exceed the maximum torque available, the speed of the rotor can be controlled accurately using this method. © 2004 Microchip Technology Inc. Page 11 AC Induction Motor (ACIM) Control Using PIC18Fxx31 Comparison Microcontroller PWM outputs Deadtime PIC18F452 PIC16F7X7 2 CCP 1 generated in firmware 3 CCP PIC18F4431 8 PCPWM Requires external hardware Requires external hardware Built in to PCPWM © 2003 Microchip Technology Incorporated. All Rights Reserved. Complimentary Signal Generation Requires external hardware Requires external hardware Built in to PCPWM AC induction Motor Control Using PIC18Fxx31 Velocity Feedback None None QEI/IC Slide 12 We’ll end this discussion by comparing several possible PICmicro MCU solutions for 3-phase AC induction motor control. •A standard PIC18 part, such as the PIC18F452, may be used by using the PWM feature of its 2 CCP modules and creating a third PWM in firmware. However, complimentary signal generation and dead-time must be generated with external hardware. •The PIC16F7X7 may be used. With its 3 CCP modules, it is not necessary to simulate a PWM in firmware. Complimentary signal generation and dead-time still must be generated with external hardware. •The PIC18F4431 features the power control PWM module, and can therefore provide up to 4 pairs of complimentary outputs, with programmable deadtime. It also features a motion feedback module with a Quadrature Encoder Interface that is well-suited to closed loop control. Each of these devices can be viable for implementing 3-phase AC induction motor control, depending upon a customer’s cost and performance requirements. Greatest performance potential is provided by the PIC18F4431, due to its specifically designed motor and power control peripherals. © 2004 Microchip Technology Inc. Page AC Induction Motor (ACIM) Control Using PIC18Fxx31 Summary ● ● PIC18Fxx31 peripherals for motor control ACIM motor control using PIC18Fxx31 ● ● ● Open V/F loop control Closed loop control using Quadrature encoder Comparison to other PICmicro MCU solutions © 2003 Microchip Technology Incorporated. All Rights Reserved. AC induction Motor Control Using PIC18Fxx31 Slide 13 In summary, we’ve discussed the PIC18Fxx31 peripherals for motor control. We’ve discussed the basics of open loop VF control for 3-phase induction motors, how to utilize current feedback with hardware fault input to the PCPWM, and how to implement closed loop control by using the Quadrature Encoder Interface of the Motion Feedback Module. We’ve also briefly compared how AC induction motor control can be implemented with other PICmicro MCUs. © 2004 Microchip Technology Inc. Page 13 AC Induction Motor (ACIM) Control Using PIC18Fxx31 Resources ● Application notes: ● ● ● ● ● Demo and development board ● ● AN887 : AC Induction Motor Fundamentals AN843 : Speed Control of 3-phase Induction Motor Using PIC18 Microcontrollers AN889: VF Control of 3-Phase Induction Motors Using PIC16F7X7 Microcontrollers AN627: 3-Phase AC Induction Motor Control Using the PIC18F4431 Microcontroller PICDEMTM MC - Completely isolated, low cost design Microchip motor control web-page at: www.microchip.com/motor © 2003 Microchip Technology Incorporated. All Rights Reserved. AC induction Motor Control Using PIC18Fxx31 Slide 14 For more in-depth exploration of this topic, you are encouraged to examine the following application notes: AN887 gives an overview of the operating principals of AC Induction motors. AN843 shows how to implement 3-phase AC induction motor control using a PIC18 using two CCP modules and a firmware PWM. AN889 shows how to implement 3-phase AC induction motor control using the PIC16F7X7, which has three CCP modules, obviating the need for a firmware PWM. AN627 shows how to implement control of a 3-phase ACIM using the PIC18F4431 with the PCPWM and MFM. (Available at the end of January.) An excellent development board for motor control applications is the PICDEM MC, which provides a fully isolated platform that can be safely used with an ICD2 or ICE2000 development tool. For the latest updates, please refer to Microchip’s motor control page at www.microchip.com/motor. © 2004 Microchip Technology Inc. Page 14