Electrical – How to create an output for LED brightness control using PWM in PIC


A PIC is multiplexing multiple common anode 7-segment displays.

An LED driver is being used so PIC does not have to source/sink a lot of current.

To help with multiplexing, each 7-segment display has a PNP transistor connected to its anode. The PIC can control the 7-segment display brightness by controlling duration for which the PNP is on. So basically with 6 7-segment displays, one of them will be on a time, however, on top of that I want to further implement a mechanism like modulated pulse output to the PNP to control the brightness.

I am sure there are multiple ways to do this. What is the most appropriate way to achieve this?

Best Answer

You already have a scheduler that changes your PNP drive (all on separate outputs one assumes), all you need to do is start a Timer that gets triggered each time you change from one digit to the next. The length of the Timer will be from 0 - something just less than your interdigit time.
Your scheduler will output for example a '1' to turn on the PNP digit drive and '0' to turn it off for each of your digits. Your timer value becomes your brightness control and when it times out you set the PNP driver (or all the PNP drivers if that's easier) to off.
The Timer could be either scanned or interrupt driven, your choice.

The waveforms might look like this:

enter image description here