MCU-based LED-VU Meter
From time to time, I see people trying to build an audio VU meter. In the analog era, that’s typically done with a voltage divider + a series of comparators; or using chips like LM3914/3915.
Those chips are harder and harder to find, or you may need more resolution, or a different output profile. What to do?
Modern MCUs offer an easy solution.
- their build-in ADC (10-bit or more) is more than enough for this type of applications;
- their fast speed allows easy multiplexing so a few pins can control lots of output;
- their PWM capabilities also allow them to drive analog coil meters.
In this post, we will explore #1 and #2 and leave #3 to those of you who want to explore more on their own.
Picking a MCU:
For the purposes of this application, we need to pick a MCU with built-in adc, and sufficient pins. Because we are using multiplexing, we also want to control the timing via a timer interrupt. So a mcu with the following features is needed:
- built-in adc;
- port operations;
That’s pretty much any modern MCU, :).
When I started coding for this project, I had a PIC16F684 in my mind, and I thought to pick 6 output pins (“segments”) over 4 multiplexing lines (“digit”, or “channel”) for one adc input, making it a VU-meter driving up to 24 leds. But to make the code more versatile, I decided to write one that supports 6 – 16 segments, 2 – 4 digits so it is good for a total of 12 – 64 LEDs, over 1 or 2 adc channels.
I actually didn’t find a PIC16F684 in my part box so instead I wrote it for a PIC16F690 – but I only used a few pins and used a random number generator so simulate the adc for demo purposes.
Basic Principles of Operations:
Essentially, we are going to take the adc input – in this case, 10-bit adc, and convert it to a 12-bit logarithmic value to be displayed on the LED. For flexibility, I want to support both bar patterns and dot patterns.
For more detail: MCU-based LED-VU Meter
Leave a Comment
You must be logged in to post a comment.