• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
 
Application Note:
Control with PWM Signals using the PIC18F4520
Sean Hatch3/21/08
Executive Summary:
Pulse Width Modulated (PWM) signals are used in a wide variety of electronic controlapplications. Usually, the system under control will feedback a reading to a PWMcontroller, and the PWM controller will adjust its duty cycle so that the subsequentreadings become nearer to the expected output of the system. The PIC18F4520,specifically its Enhanced Capture/Compare/PWM (ECCP) module, can be used toimplement a PWM control system. Many other features of the PIC can be used incombination with the ECCP module to create a versatile controller. For example, thePIC’s interrupt capabilities can be used to change the set-point of the system on the fly.The Analog to Digital Conversion (ADC) module is usually responsible for reading theoutput of the system, or other inputs. Also, as the PIC is a programmed device, any sortof control scheme may be programmed. Although this application note is written for thePIC18F4520, most everything here applies to any PIC with an ADC and the ECCPmodule.
Keywords:
PIC18F4520, PIC applications, control, bang bang control, PWM control
Controlling PWM Signals with the PICF84 1
 
 
1. Introduction:
PWM signals are used in a variety of control applications, including:
DC to DC converters.
Motor controllers.
Power delivery control.In each of the applications, the system under control has a certain output which it issupposed to achieve. The basic operation of a PWM control system is outlined in
Figure 1
. A PWM controller must read the current output, compare it to the specifiedset-point, and adjust a PWM signal’s duty cycle to minimize the error between thecurrent output and the set-point.
Figure 1: Block diagram of a PWM control system using the PICF18 as a controller
 There are many PWM control integrated circuit packages on the market today. However,they are usually limited to one input, and use a specific control scheme. The PIC offersthe ability to control based on multiple inputs. Additionally, any type of control schemecan be programmed. Other modules of the PIC can be used to improve the versatility ofthe controller. For example, the PIC’s interrupt capabilities are useful in changing theset-point of the system on the fly, turning off the control system, or changing betweeninputs to the control system.
Controlling PWM Signals with the PICF84 2
 
 2. Hardware Details:
In order for the PIC to correctly function as a controller, the PIC must be correctlyconnected to the system under control, and it must be correctly configured. For thesegeneral connection and operation configurations, refer to the PIC’s datasheet. The restof the hardware details presented here will be specific to the PIC in a PWM controlsetting.
The PIC must be correctly connected to VDD and VSS, and this voltagedifference must be consistent. The control system will likely need to deal withinput from the ADC module. The potential difference between VDD and VSSmust be constant in order for analog to digital conversions to be accurate andusable.
The output signal from the system under control must be correctly voltagedivided so that all possible input voltages to the ADC fall between VDD and VSS,otherwise the ADC will not convert the values correctly. Also, the voltage dividershould be configured so that the largest possible voltage from the system undercontrol will be divided down to nearly VDD. This will allow the highest conversionresolution.
The PIC cannot source or sink current quickly enough to charge or discharge thegate capacitance of a MOSFET. Therefore, a driver must be used between thePIC and the switching element in order to switch at relatively high frequencies.
In many cases, difficulties can arise if for some reason, the system under controlremains active, while the PIC is powered down. A combination of software andhardware can be implemented to prevent this from occurring.
The system under control can often introduce transients into the system resultingfrom system shutdown, a change in set point, or a change in load. It isnecessary to isolate or protect the PIC from these transients, as the PIC caneasily be damaged from them.
3. Software Details:
Everything having to do with time in regards to the PIC is expressed in terms of clockcycles. The ECCP module is no exception. Before the registers relevant to our PWMsignal are configured, the Timer2 module must be configured. Further informationpertaining to Timer2 configuration can be found in the PIC’s datasheet. We are onlyconcerned with bits 0 – 2.First, bit 2 must be set in order to enable the Timer2 module. Bits 1 – 0 set the prescalefactor. The prescale factor can be used to scale the clock frequency by a factor of 4 or16. For example, if the PIC’s clock frequency is 40 MHz, and the prescale factor is setto 4, the ECCP PWM module will operate at a base frequency of 10 MHz. The prescalefactor does not decrease the clock speed in other modules of the PIC.
Controlling PWM Signals with the PICF84 3
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...