Control LEDs with Pulse-Width Modulation (PWM)
Last modified by Microchip on 2023/11/09 09:02
Contents
There are multiple ways to generate Pulse-Width Modulation (PWM) control signals to control power circuits such as an LED driver.
- Devices with the Capture-Compare-PWM (CCP) module can generate PWM signals to control power circuits using an on-chip digital timebase. The signal pulse width is controlled by the MCU clock and duty cycle register.
- The Enhanced CCP (ECCP) module allows one PWM signal to control two or four output pins for half-bridge or H-bridge control, respectively.
- Devices that have a comparator and the ECCP module can use the comparator signal to control the turn-off time of the PWM signal.
- Devices with comparators and a PWM Switched Reluctance (SR) latch can use comparator signals and/or clock pulses to turn the latch output on and off.
- An external PWM peripheral Integrated Circuit (IC) may be used. This option is useful when additional high-speed PWM channels are required.
- PWM signals can be generated using software and I/O pins. This option is less costly when PWM frequency and duty cycle resolution requirements are not too high. A PIC® microcontroller with an on-chip comparator such as the PIC12F609 can be used to implement a simple LED driver. The PIC12HV609 has an internal regulator, allowing operation from a Direct Current (DC) bus that is higher than 5V.
8-, 14-, and 20-Pin PIC® Microcontroller Mixed Signal Features
Device | Pins | Voltage Reference | Comparator | Op Amps | ADC | Digital PWM Module | PWM SR Latch |
---|---|---|---|---|---|---|---|
PIC12F609/PIC12HV609 | 8 | – | 1 | – | – | – | – |
PIC12F615/PIC12HV615 | 8 | – | 1 | – | 10-bit | 1 | – |
PIC12F1822 | 8 | Yes | 1 | – | 10-bit | 1 | 1 |
PIC16F610/PIC12HV610 | 14 | – | 2 | – | – | – | 1 |
PIC16F616/PIC16HV616 | 14 | – | 2 | – | 10-bit | 1 | 1 |
PIC16F785/PIC16HV785 | 20 | Yes | 2 | 2 | 10-bit | 1 | 2 |
PIC16F1828 | 20 | Yes | 2 | – | 10-bit | 4 | 1 |
HV part numbers have an internal shunt voltage regulator.