pulse width modulation

Download Pulse Width Modulation

If you can't read please download the document

Upload: jacqui

Post on 08-Jan-2016

58 views

Category:

Documents


3 download

DESCRIPTION

Pulse Width Modulation. By: Val Tocitu Jason Kulpe Alexandre Mariuzza. ME 4447/6405 October 29 th , 2009. Presenter: Val Tocitu. Introduction and definitions Types of PWM Methods of generation Characteristics of PWM Applications and examples Implementation on the HCS12. - PowerPoint PPT Presentation

TRANSCRIPT

  • By: Val TocituJason KulpeAlexandre MariuzzaME 4447/6405October 29th, 2009

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • 10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza* Introduction and definitions Types of PWM Methods of generation Characteristics of PWM Applications and examples Implementation on the HCS12Presenter: Val Tocitu

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • What is it?Output signal alternates between on and off within specified periodControls power received by a deviceThe voltage seen by the load is directly proportional to the source voltage10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • DefinitionsDuty Cycle: on-time / periodVlow is often zero

    10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Types of Pulse WidthPulse center fixed, edges modulatedLeading edge fixed, tailing edge modulatedTailing edge fixed, leading edge modulatedPulse Width constant, period modulated

    10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Types of Pulse Width10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Analog PWM signals can be made by combining a saw- tooth waveform and a sinusoid10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*PWM output is formed by the intersection of the saw-tooth wave and sinusoidAnalog Generation of PWM

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Digital Methods of Generating PWMDigital: Counter used to handle transitionDelta : used to find the PWM at a certain limitDelta Sigma: used to find the PWM but has advantage of reducing optimization noise10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Delta MethodOutput signal compared with limitsEvery time limits reached, changes state10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Delta Sigma MethodPWM signal generated by Delta methodError = output referenceError integratedState changes when integration reaches limitsAdvantageCircuit simplerReduces quantization noise by high pass filter10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Applications to DC Motors10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*The voltage supplied to a DC motor is proportional to the duty cycleBoth brushed and brushless motors can be used with PWMBoth analog and digital control techniques and components are available

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Three Phase AC motors with PWM3 different AC currents at different phasesPhase: 120 degrees apartCreates constant power transferRotating magnetic fieldPulses substitute for AC current10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Space Vector ModulationUsed for three-phase AC motorsConvert DC current to AC currentGates turned on/off at different intervals3 PWM created10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Motor Control Diagrams10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • average value proportional to duty cycle, Dlow power used in transistors used to switch the signalfast switching possible due to MOSFETS and power transistors at speeds in excess of 100 kHzdigital signal is resistant to noise less heat dissipated versus using resistors for intermediate voltage values

    10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*Advantages of PWM

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • 10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*CostComplexity of circuitRadio Frequency InterferenceVoltage spikes Electromagnetic noiseDisadvantages of PWM

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • 10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza* Introduction and definitions Types of PWM Methods of generation Characteristics of PWM Applications and examples Implementation on the HCS12Presenter: Jason Kulpe

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • In the past, motors were controlled at intermediate speed by using resistors to lower delivered powerElectric stove heaterLamp dimmersVoltage regulation convert 12 volts to 5 volts by having a 41.7% duty cycleSound production: PWM controlled signals give sound effects similar to a chorusPower transfer: PWM used to reduce the total power given to a load without relying on resistive losses

    10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*Applications of PWM

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • commonly used in toyslowpass filter smooths out transients from harmonic effectsfrequency values of harmonics doesnt change, but the amplitude does, which adjusts the analog output signal10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*PWM used with D/A conversion

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • 10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza* clock signal is found inside PWM signal more resistant to noise effects than binary data alone effective at data transmission over long distance transmission linesPWM used to transmit data in telecommunications

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Ripple is the noise in the output signalAppropriate PWM controllers can minimize these effects10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*Concerns: Ripple of PWM Signal

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Must be at least 10 times higher than the control system frequencyHigher than 20kHz audible frequency of sounds to avoid annoying sound disturbances, caused by magnetostrictionIf too low the motor is pulsed, not continuous, because the motors inductance can not maintain the currentInverse of frequency should be much less than the motor/load time constantHigher error from ripple voltages

    Frequency of the PWM SignalUpper LimitsLower LimitsIf too high the inductance of the motor causes the current drawn to be unstableMOSFET transistor generates heat during switchingLimited by resolution of controllerEddy currents generated in electromagnetic coils which lead to adverse heatingHeat losses in electromagnetic materials is proportional to frequency squared

    10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Potentiometer is used to adjust the duty cycle

    10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*Example: PWM with 555 Timer

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Maxon EC-16 brushless motor, Time constant = 8.75 ms

    2. Want to avoid audible frequenciesf 20 kHz3. PID control loop running at 150 Hzf 10 150 Hz

    Requirements10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*Example: Specifying circuit elements

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Set f to 25 kHz to add in a factor of safety

    Choosing C1 to be 100 nF, R1 is 576 ~ 500

    Recalculating with these values f = 28.8 kHzThis circuit has a PWM frequency according to: 117 Hz 20 kHz 1.5 kHz

    f Check constraints10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*Example: Specifying circuit elements

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Matlab can do PWM!10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*The procedure works similar to the generation of analog PWM using a sinusoid and saw-tooth wave

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • 18 kHz frequencyContinuous 28 amps$55.95Where can I buy a PWM controller?Texas InstrumentsDigikeyMouser ElectronicsCritical Velocity Motor ControlTexas Instruments TAS5508B8-Channel Digital Audio PWM Processor64 pin chip, max 192 kHz frequency$7.25120 amps, used for hybrid vehicles$469.00SMALLBIGGERHUGE10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • 10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza* Introduction and definitions Types of PWM Methods of generation Characteristics of PWM Applications and examples Implementation on the HCS12Presenter: Alex Mariuzza

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM ImplementationThe signal is outputted through Port PSix ChannelsDedicated Chip

    10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM Module Each channel has a dedicated counter Programmable duty and periodIndependently adjustable clock, polarity, and alignment

    10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM Module- Other Features 8-bit and 16-bit resolution supportedTwo PWM channels can be concatenated togetherFour source clocks (A, SA, B, SB)Emergency ShutdownSome changes take a complete cycle to be implemented Modes of Operation:Normal: everything is availableWait: Low-power consumption and clock disabledFreeze: Option to disable clock is available10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM ConfigurationConfigured through specific registersRegisters are located from $00E0 to $00FEThere are repeated registers (ex. 0013-0017)

    10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM Enable RegisterLocated at $00E0Code Warrior variable: PWMESet PWMEx to 0 to disable the channelSet PWMEx to 1 to enable itChannel is activated when bit is set If 16-bit resolution used, then PWME4/2/0 are deactivated

    10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM Polarity RegisterLocated at $00E1Code Warrior variable : PWMPOLSet PPOLx to 0, signal goes from low to highSet PPOLx to 1, signal goes from high to low

    10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM Clock Select RegisterLocated at $00E2Code Warrior variable : PWMCLKSet PCLK5/4/1/0 to 0 to use clock ASet PCLK5/4/1/0 to 1 to use clock SASet PCLK3/2 to 0 to use clock BSet PCLK3/2 to 1 to use clock SB10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM Prescaler RegisterLocated at $00E3Variable: PWMPRCLKUsed to prescale clocks A and B

    10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM Scale A RegisterLocated at $00E8Code Warrior variable: PWMSCLAStore a hexadecimal value in order to change the clock frequency of SANote: if set to $00, PWMSCLA is set to 256

    10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM Scale B RegisterLocated at $00E9Code Warrior variable: PWMSCLBStore a hexadecimal value in order to change the clock frequency of SANote: if set to $00, PWMSCLB is set to 256

    10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM Center Align RegisterLocated at $00E4Code Warrior variable: PWMCAESet CAEx to 0 for left align signalSet CAEx to 1 for center align signalNote: can only be set when channel is disabled10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Signal AlignmentSignal changes when counter is equal to period registerIn the center aligned mode, the PWM counter goes from a down-count to a up-count to down-count, etc.In the left aligned mode, the PWM counter is a up-counter and rests to zero when it overflows 10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM Control RegisterLocated at $00E5Code Warrior variable: PWMCTLSet CONxy to 0 to keep PWM channels separate (8-bit)Set CONxy to 1 to concatenate PWM channels x and y together (16-bit).Channel y determines the configurationx becomes the high byte and y becomes the low byteBits PSWAI and PFRZ set either wait or freeze modeChanges only occur when channels are disabled10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM Counter RegisterLocated at $00EC through $00F1Code Warrior variable: PWMCNTxOne per channelIt tracks the cycle countsIt can be readIf written to, the count is reset to $00 and a up-count starts10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM Period RegisterLocated at $00F2 through $00F7 Variable: PWMPERxStore a hexadecimal value to limit maximum value of counterChanges occur when:Current period endsCounter is written toChannel is disabledLeft-Aligned:Center-Aligned:10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM Duty RegisterLocated at $00F8 through $00FDCode Warrior variable: PWMDTYxStore a hexadecimal value to control when signal changes Changes occur when:Current period endsCounter written toChannel is disabledPolarity = 0:10/29/2009*Polarity = 1:

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • PWM Shutdown RegisterLocated at $00FECode Warrior variable: PWMSDNPWMENA: Enables and disables emergency shut downPWMIF (Interrupt flag): Set when an input is detected in pin 5PWMIE (Interrupt Enable): Enables and disables CPU interruptsPWMRSTRT: Resets the countersPWMLVL (Shutdown Output Level): Determines if output is high or low when shutdownPWM5IN (Input Status): Reflects status of pin 5PWM5INL: Determines active level of pin 5*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • How it all worksClock A, SA, B, or SB10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • ExampleDesired Signal:8 kHz PWM signalDuty Cycle of 30%Left AlignedChannel 1Low High8-bit channel10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Assembly CodePWME EQU$00E0 PWMPOLEQU$00E1 PWMCLKEQU$00E2 PWMPRCLKEQU$00E3 PWMCAE EQU$00E4 PWMCTL EQU $00E5 PWMPER1EQU $00F3PWMDTY1EQU $00F9

    ORG$1000LDAA#$00STAAPWMCLK; Sets source clocks to clock ASTAAPWMPOL; The signal goes from low to highSTAAPWMCTL; Makes all channels 8-bitSTAAPWMCAE; Signals are left alignedLDAA#$FASTAAPWMPER1; Sets the period to 250 clock cycles LDAA#$AFSTAAPWMDTY1 ; Makes the duty cycle equal to 30%LDAA#$02STAAPWMPRCLK; Sets the prescaler to 4STAAPMWE; Enables and starts channel 110/29/2009*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • C Code#include /* common defines and macros */ #include /* derivative information */ #pragma LINK_INFO DERIVATIVE mc9s12c32

    // Set up chip in expanded modeMISC = 0x03;PEAR = 0x0C;MODE = 0xE2;

    //Set up PWM RegistrerPWMCLK = 0;// Sets source clocks to clock APWMPOL = 0;// The signal goes from low to highPWMCTL = 0;// Makes all channels 8-bitPWMCAE = 0;// Signals are left alignedPWMPER1 = 250;// Sets the period of the signal to 250 clock PWMDTY1 = 175;// Makes the duty cycle equal to 30%PWMPRCLK = 2;//Sets the prescaler to 4PMWE = 2;//Enables and starts channel 1.10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • http://en.wikipedia.org/wiki/Pulse-width_modulationhttp://www.netrino.com/Embedded-Systems/How-To/PWM-Pulse-Width-ModulationCetinkunt, Sabri. Mechatronics. Hoboken, NJ: Wiley, 2006. Print.http://www.jimfranklin.info/microchipdatasheets/00538c.pdfhttp://www.allaboutcircuits.com/vol_6/chpt_6/9.htmlhttp://www.dprg.org/tutorials/2005-11a/index.htmlhttp://www.4qdtec.com/pwm-01.htmlhttp://skywalker.cochise.edu/rgill/ch02elec.ppthttp://pcbheaven.com/wikipages/PWM_Modulation/Matlab 2009 online documentationhttp://www.epanorama.net/links/motorcontrol.html#acMC9S12C Family, MC9S12GC Family Reference Manual, (pp. 347-382)

    REFERENCES10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

  • Questions?10/29/2009Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza*

    Pulse Width Modulation - Val Tocitu, Jason Kulpe, Alex Mariuzza

    *****************************Emergency Shutdown- can be triggered with input from pin 5 of Port P*There are 30 registers, lots of them are repeated*Clock A and B are independent prescaled clocksClock SA and SA are based on clocks A and B

    *Clock A and B are independent prescaled clocksClock SA and SA are based on clocks A and B

    *Clock A and B are independent prescaled clocksClock SA and SA are based on clocks A and B

    *Clock A and B are independent prescaled clocksClock SA and SA are based on clocks A and B

    *Clock A and B are independent prescaled clocksClock SA and SA are based on clocks A and B

    *Clock A and B are independent prescaled clocksClock SA and SA are based on clocks A and B

    *Clock A and B are independent prescaled clocksClock SA and SA are based on clocks A and B

    *Clock A and B are independent prescaled clocksClock SA and SA are based on clocks A and B

    *Polarity 0- counts low timePolarity 1- counts high time

    *Polarity 0- counts high timePolarity 1- counts low time

    **