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
Leave a Comment