New LED display design, help me perfect it!

Started by RaceDriver205, February 08, 2007, 12:55:59 AM

Previous topic - Next topic

RaceDriver205

Got the idea from another forum member wanting something similar.
It is a dynamic LED bar display which reacts to your playing. Can be used for decoration or whatever.
Here is my preliminary circuit, but I have a few questions for the more experienced.

The 4066 is for automatic gain control, so the microcontroller can adjust the input to the right level.
My questions are, will the microcontroller need the signal filtered or something to allow it to get a good set of readings for an average?
Also, is there anything else which would make this device better?
Cheers all  ;)


Paul Perry (Frostwave)

Well...... I'd use a led bar driver chip myself...... :icon_wink:
That's an interesting point, whether you would need to filter - it isn't obvious! I suspect that just keeping the highest value seen during the last 1/20 of a second would do, if you were sampling fast enough to be sure of catching peaks (say 1,000 times per second).
But a diode, cap, and bleed resistor doesn't cost much! (can you tell I'm a hardware guy?)
Maybe ask in the DSP section......

RaceDriver205

No one seems to visit the DSP section much though, thats all. Maybe someone should move this there.
As for the cap and resistor, what values would I use?

The display is not just going to be a standard volume-style bar-graph display. It will be able to do random things, and different patterns. Maybe it will be the Windows Media Player version of a standard bar-graph display. ;D
Speaking of which, would you all say 20LEDs is too few? Should I do 30 Instead? Im thinking Ill do 30 instead.

Paul Perry (Frostwave)

OK, I'd start with 100K and 1uF. Preferably a tantalum.

RaceDriver205

Like the top circuit or the bottom?:

Will this make the waveform become a DC-ish?

Paul Perry (Frostwave)

Neither of those, just the cap to ground, with the resistor across it.
In fact, I'd put a 1M pot across the cap & adjust to see what resistance you wanted to keep.
And preferably a schottky diode (BAT85 or whatever) for low drop.
As I said, I'm not Mr Micro... but I think the analog inputs of micros are pretty prone to destruction by overvoltages. (that is, more than the micro power supply voltage). So you might want to be careful of that too....

RaceDriver205

Thats OK, the Opamp is powered by 5V, so the best it can ouput is 4.15V.

pjwhite

The arrangement of LEDs is interesting.  If your goal is to be able to light any LED individually, you'll have to rethink things a bit, though.  I'd suggest a row/column array configuration.  With the addition of a 3:8 decoder (like a 74HC138) and by using the unused outputs on the microprocessor you could make a 6 x 8 array (48 LEDs)

RaceDriver205

Thats OK, its special "Complementary LED drive". With only 8 pins, its possible to individually light 56 LEDs! The trick is, at 5V supply, two LEDs in series can't light up.

How many LEDs would you guys say would be reasonable? I can probably go up to a max of 42 on this design.

The Tone God

Are you lighting based on amplitude or frequency ?

Quote from: RaceDriver205 on February 08, 2007, 10:38:39 PM
How many LEDs would you guys say would be reasonable? I can probably go up to a max of 42 on this design.

I really couldn't say but you should decided on those things soon before you get too committed. Watch current consumption.

Andrew

RaceDriver205

Well, now theres an idea! Would it be possible to do both?
Current consumpsion will just have to be how it is. I reckon Ill do 30 LEDs.

The Tone God

Quote from: RaceDriver205 on February 09, 2007, 02:38:45 AM
Well, now theres an idea! Would it be possible to do both?

Yes but it would affect your input filter design hence why I asked the question.

Quote from: RaceDriver205 on February 09, 2007, 02:38:45 AM
Current consumpsion will just have to be how it is. I reckon Ill do 30 LEDs.

It is not the power current I am worried about but the amount of current you are drawing from the uC pins.

Andrew

pjwhite

Quote from: RaceDriver205 on February 08, 2007, 10:38:39 PM
Thats OK, its special "Complementary LED drive". With only 8 pins, its possible to individually light 56 LEDs! The trick is, at 5V supply, two LEDs in series can't light up.

Ah, I was forgetting that you could tri-state some of the outputs.

Quote
How many LEDs would you guys say would be reasonable? I can probably go up to a max of 42 on this design.

If you multiplex the LEDs so that only one is illuminated at a time, the current consumption is not really an issue.  You will be limited by the maximum current source/sink current on the microprocessor pins, and this will affect the apparent brightness.  Remember that with 42 LEDs, you'll only have a 1/42 duty cycle for each one.  Using "Ultra bright" LEDs will help make the display more visible, as will running the maximum current that the micro can supply for each LED.  You will also need to refresh the LEDs fast enough to prevent flickering.

RaceDriver205

Aye, it had occured to me that high-brightness LEDs would be needed, I don't think normal ones will be enough.
QuoteIt is not the power current I am worried about but the amount of current you are drawing from the uC pins
Oh OK, when then yes, ill be sure to keep it at 20 or 25mA, whatever the datasheet says.
QuoteYes but it would affect your input filter design hence why I asked the question
Well, considering I will be left with 2 ADC on the right, would it be better to send a signal optimised for Freq. to one, and one optimised for Amp. to each? What would I do to optimise for frequency? Would I filter out Hi-Freq content and convert to square wave?


RaceDriver205

OK, Ive decided I won't bother with frequency control. I think that would be an overkill and not very usefull to this design (not to mention more effort).
I have updated the design above to allow better resolution. The idea is that the opamp only amplifies the +ve top part of the wave, and the bottom part is cut off at 0V. Then its smoothed to a DC-ish level.
Is this looking OK all?

R.G.

I know that we're all just supposed to substitute parts in and find our own beautiful reality in electronic circuits, but sometimes a little stuffy, hidebound theory can be a help.  :)

If you can digitize the audio directly, you can - theoretically - just do the computation on the numbers you digitized and light up your LEDs with peak, or average, or RMS, or frequency or whatever you can compute from it. Problem is, a guy named Nyquist figured out that for that process to produce good results, you need to sample a minimum of twice per the fastest waveform component in your signal to be able to reconstruct the signal. PIC A-D can't sample that fast yet. One could argue -theoretically at least- that you don't need to reconstruct the stuff you're digitizing in this application, so Nyquist has nothing to say about it. I would need to do some testing and some math before I believed that.

However, if you band limit what is going it, you can do the internal computation OK. But on a PIC you only get up to a few kHz.

Really though, if you are only displaying something that's related to amplitude, you can do that with only the envelope to work from. The envelope is just the overall level of the signal peaks rectified and filtered. A two-opamp precision rectifier can do this relatively well. The PIC can then digitize this envelope and light LEDs from it any way you like.

The opamp rectifier is needed because both in theory and in practice, the forward diode drop you get with silicon or even germanium diodes eats too much of the bottom of the waveform up, and you get 0 output from the bottom 0.2 to 0.5V of signal, which may be all of it for a single coil. So you need to rectify/filter electronically.

The LM391x chips do this in a single analog chip, including driving the LEDs in dot or bar mode. But they won't drive your gain changer very well without more junk.

So on the PIC, if you can give up frequency display, use an electronic envelope rectifier/filter, scale it with gain to be up to 255 counts on the native A-D adapter (that is, 5V or the vref you feed the A-D) then just read the envelope from the A-D converter and decide which LEDs to light.

You're on your own on what switch to turn on for gain change and whether to make that linear or logarithmic.  :icon_biggrin:
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

RaceDriver205

QuoteA two-opamp precision rectifier can do this relatively well.
Cheers, I like the sound of this two-opamp precision rectifier, I will look into it.
Regards to the sampling rate, this new ATTiny26 AVR seems as though it will do 10kHz plus. The ADC clock can be set to 125kHz comfortably, and it performs a sample in 13.5 such cycles. Higher clocking rate can be achieved, but with less precision.

I wanted to use an AVR for this for the versatility, instead of a LM391x. I can get it to auto-correct the gain, allowing for other devices like CD players etc to be used with it too. I can also get it to do wierd patterns in response to the input instead of just up-down.

The Tone God

I think the auto gain thing is adding complexity and the added functionality is not that great. Is there a particular reason as to the auto gain ? Do you have a need to switch gain on the fly while operating ? I can see that portion having problems when writing the code with respect to things like noise and ranging. Why not replace the switching gain with something like a knob ? It would make life much easier. ;)

Doing frequency measurement would be difficult right now and complicate things quite a bit to do it properly and with a decent response time to light the LEDs. Amplitude is easier and even I have done it with relative ease so I think it is a good idea to leave that for the first version.

Andrew

RaceDriver205

Well like I said earlier, Im going to drop the frequency idea because I came to the conclusion it was 'dumb'  ;D.
QuoteI think the auto gain thing is adding complexity and the added functionality is not that great. Is there a particular reason as to the auto gain ?
Well the idea was to allow for any input. I like the idea of just pressing a button each time you want it to calibrate the gain to something. The idea was that when you press the button, it will max out the gain, and decrement it until it drops below the 4.15V threshold (obviously, whilst playing the guitar loudly while it calibrates). This would keep the range of the input signal between 100% and 0% on the ADC.
I guess a knob would work too.
What do you mean by noise problems?