Go Down

Topic: Help with LED VU Meter (Read 4539 times) previous topic - next topic

wally_z


So, 15 decimal is 8 + 4 + 2 + 1, so 1111 in binary.
And 12 decimal is 8 + 4, so 1100 in binary.

Just like a binary clock. NICE!

Im still stumped on why the Arduino does the light show and is unresponsive. The Arduino really needs a manual. I already read "Getting Started With Arduino". Its very basic, written mainly for people new to hobby electronics (of which I am not one of those people).

I'm up to number 132 so far. So the number 1023 is a ten BIT number eh? itll take a while but ill get there.

AWOL

#31
Aug 10, 2011, 11:39 pm Last Edit: Aug 10, 2011, 11:49 pm by AWOL Reason: 1
Quote
Just like a binary clock. NICE!

The problem is, a lot of people wimp-out, and implement a binary clock that is really a BCD (binary-coded decimal) clock.
Binary-coded decimal is very wasteful (of bits).
BCD reserves four bits for the numbers 0..9.
So 19 decimal is represented as 00011001

(to give you an idea of how wasteful BCD is, it takes eight bits to represent the numbers 0..99, whereas in binary, those eight bits could represent numbers 0..255. The problem gets worse the more decimal digits you add)

Quote
I'm up to number 132 so far.

132 is 128 + 4, so 10000000 + 00000100 = 10000100

I'm afraid you're going to come across two's complement pretty soon...stay clam.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

wally_z


Quote
Just like a binary clock. NICE!

The problem is, a lot of people wimp-out, and implement a binary clock that is really a BCD (binary-coded decimal) clock.
Binary-coded decimal is very wasteful (of bits).
BCD reserves four bits for the numbers 0..9.
So 19 decimal is represented as 00011001

Quote
I'm up to number 132 so far.

132 is 128 + 4, so 10000000 + 00000100 = 10000100

I'm afraid you're going to come across two's complement pretty soon...stay clam.

I'm going to go for at least 1023. I will not give up, I did it in notepad so if I need a binary number I can just look it up. What I did is made it so the number of the line is the number counted. Example:
Line 4: 100
Line 5: 101
etc.

wally_z

@AWOL are there any shortcuts you can use to count really high really fast?

Magician

#34
Aug 11, 2011, 03:00 am Last Edit: Aug 11, 2011, 02:42 pm by Magician Reason: 1
Quote
My initial problem of having the LED's not light up is already fixed, I just didn't connect ground to a few LED's so it works now. I am just curious as to why the system stops working if there is too much input. Is there an error message or anything as to why this happens?


Most likely you overdrive / overload arduino with your audio input signal.
Data sheet for Atmega328 says that voltage present at any input, including analogs must be:
Quote
Voltage on any Pin except RESET with respect to Ground .........-0.5V to VCC+0.5V
*NOTICE:
Stresses beyond those listed under "Absolute Maximum Ratings" may cause permanent dam-
age to the device. This is a stress rating only and functional operation of the device at these or
other conditions beyond those indicated in the operational sections of this specification is not
implied. Exposure to absolute maximum rating conditions for extended periods may affect
device reliability.


Audio signal is AC or Alternating current, which means it's positive for half period of time and negative for other half period.
http://en.wikipedia.org/wiki/Alternating_current

edited:
Arduino couldn't tolerate negative voltage, if it's more than 0.5V, so bare minimum protection circuitry should include schottky diode + resistor to cut off this.
For positive voltage, maximum is Vcc +0.5V, it could be 5.5V ( or 3.8V for boards with power line 3.3V). The easiest way  to protect against "overdrive" in positive area is a zener diode at the input Vz = 5.1V , 1N5231B,  (Vz =  3.6, 1N5227B, for boards with VCC = 3.3V).

And next, it's nice to have envelope detector at the input, as amplitude of the audio signal varying too fast for arduino to catch up with. Microprocessor has other stuff to do, it doesn't measure voltage continuously, and simple capacitor + resistor would help to hold peak till arduino find a time to check it.
You can buy a VU shield, or build your own according to attached schematic.



Techone

I read this tread...interesting project...

So Wally_z.... the analog pin CAN NOT go negative.. ok   Use Magician zener protection circuit and here an idea call a signal "ridding" on a DC line.  Most Line Out signal , the voltage is about 3 V peak to peak max volume ( at my sound card output ) It mean 1.5 V plus and 1.5 V negative. So you simply ADD a DC voltage to it. Arduino is 0 to 5. 5 V window , signal 3 V <-- Can fit the "window"  Got me so far ? So add a 2.5 V DC by using a voltage divider. A 47 K + 47 K should be fine.  Therefore the Arduino pin will "see" a 2.5 V when no audio signal is present. At max level, the pin will "see" 2.5 V + 1.5 V = 4 V ( positive - up side ) and 2.5 - 1.5 = 1 V ( negative - down side ) THAT is call a Sine Wave "ridding" a DC line or Voltage.  I hope you understand me so far.

So when a leftlevel= analog( pinanalog); ----> leftlevel = 0 --> 0 V at analog pin   leftlevel = 1023 --- > 5 V at analog pin  leftlevel=512 ---> 2.5 V at analog pin.  Ok so far... AT max level - 4 V --> leftlevel = 820 positive swing, 1 V --> leftlevel =204

The analog pin doing this : 5 V / 1024  = 4.88 mV per step ( bit )  a step is a leftlevel = 1. 

I hope this help.

Magician

It require cap at the input. Initially, I thought just to post a link:
http://interface.khm.de/index.php/lab/experiments/arduino-realtime-audio-processing/
(I like this drawings, post it all the time).
Then I realize, if someone (newbe or artist, who has no clue what line level is)  connect input to speakers, there is no protection from "too much" level, and arduino would have a heart attack again as it was described,  by blinking led on pin #13 rapidly. =(
I start to google, trying to find a some kind of schematics to save time not to draw it. I was not able to find anything for couple hours! This is why I create it myself.  :D

wally_z

#37
Aug 11, 2011, 01:59 pm Last Edit: Aug 11, 2011, 02:14 pm by wally_z Reason: 1
@Magician. I've heard of diodes, but never used on except LED's. Is there a certain type of diode to use?
(First schematic) I see a diode in the line, and then a resistor. What type of diode (rating? zener or whatever its called?)
(Second schematic) Now there is a second diode saying "5.1v" going to PGND which I'm guessing is ground but I don't know what PGND is. (I googled PGND and i'm still confused. What's with the 5.1v?)
(Third schematic) Now it gets a bit complicated. What is an envelope detector and why would I need one?

How does the "protection" of these schematics vary? My Arduino is working fine, no problems, I don't have the signal maxed out or anything so if I don't turn it up it'll be fine.
------------------------------------------------------------------------------
@Techone the analog pin is apparently getting negative voltage from the AC coming from the audio signal. Does hZ in electricity matter for this kind of thing? (hZ or Hertz, is electricity flowing through a wire, at all times, not sure about AC, the electricity is off for 60 times a second and on for 60 times a second. I guess AC is a bit slower than that to consider it AC.)
I've heard of voltage dividers. Don't speakers work by using the wattage in a circuit instead of the voltage?

AWOL

You really need to slow down and start understanding basic concepts before you damage your Arduino or yourself (or, more likely, both)

Watts (W) measure the power in a system, and are the product of volts (V) and amperes (A).

Hertz is the unit of frequency.

Quote
My Arduino is working fine, no problems

That may not actually be the case - you have no way of knowing.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Magician

Quote
Is there a certain type of diode to use?
(First schematic) I see a diode in the line, and then a resistor. What type of diode (rating? zener or whatever its called?)

Good question, I slightly modified my drawings, now it include words "schottky" diode.
Quote

(Second schematic) Now there is a second diode saying "5.1v" going to PGND which I'm guessing is ground but I don't know what PGND is. (I googled PGND and i'm still confused. What's with the 5.1v?)

Yes, PGND is a ground, it marked so in gEDA, never mind. "5.1V" is zener diode voltage, for example, 1N5231B has such Vz.
Quote
(Third schematic) Now it gets a bit complicated. What is an envelope detector and why would I need one?

Look for on-line resources, wikipedia or similar.
Quote
Don't speakers work by using the wattage in a circuit instead of the voltage?

Voltage and wattage bind by formula: P = V^2 /  R.

wally_z

#40
Aug 11, 2011, 03:54 pm Last Edit: Aug 11, 2011, 04:03 pm by wally_z Reason: 1

You really need to slow down and start understanding basic concepts before you damage your Arduino or yourself (or, more likely, both)

Watts (W) measure the power in a system, and are the product of volts (V) and amperes (A).

Hertz is the unit of frequency.

Quote
My Arduino is working fine, no problems

That may not actually be the case - you have no way of knowing.

That is true, but I see no problems.
---------------------------------------------------------------------
@magician Alright, I will look into getting a few diodes to try this out. Just a few questions. Where PGND is, where would that go, to ground on the Arduino, along with the audio signal ground? Does the whole "minimum protection" circuit go on JUST the signal wire(s) or use one on each wire coming from the signal? I don't think ground would get this but I would like confimation on what to do. I checked Radioshack.com and there is no such thing as a Schottky diode, or 1N5231B. Could I use a Zener instead? Or a 1N4733A, 1N5399-S, or 1N914/4148? If I can use one of those I'll run to my Radioshack and get one and build this. I might do the Envelope Detector, for the diode put in backwards is it a Zener? I'm just curious as to what the line on the left side is, maybe it means its backwards? I can't find that specific symbol. For the capacitor im guessing a polarized 1uF electrolytic? Thank you for all you've done for me so far.

Magician

#41
Aug 11, 2011, 04:48 pm Last Edit: Aug 11, 2011, 04:54 pm by Magician Reason: 1
Ground on arduino board usually mark GND, should be a few (3?) of this pins available. And your audio jack ground wire should be connected to any of this pins, of course. Shown circuitry is for one analog pin in use, it's mean if you combine left/right channel at the audio jack, you need only one resistor + diode.
The same time for separate left / right stereo channel connected to different analog inputs, you'd need two protection circuits.
1N4733A  - zener 5.1V , o'k
1N5399-S - general rectifier, not o'k
1N914/4148 - could works, not so efficient as schottky
Quote
I might do the Envelope Detector, for the diode put in backwards is it a Zener? I'm just curious as to what the line on the left side is, maybe it means its backwards? I can't find that specific symbol.

http://www.kpsec.freeuk.com/symbol.htm
http://en.wikipedia.org/wiki/Electronic_symbol
And capacitor is electrolytic.

wally_z

@Magician. Awesome, i'll do that then. Thank you for helping me. Just 2 last questions, I will be using two of the same type of diode correct? And the second diode in the circuit with the extra line on the symbol goes in BACKWARDS correct?

Magician

If you choose schematic #2 with two diodes, I'd suggest to increase value of resistor up to 100 kOhm, so with lower current,  forward voltage would stay below 0.5V across diodes.
If you gonna follow #2 with zener + resistor and diode, than actually you don't have to install diode if it's not schottky,  only resistor and zener. Don't have current/voltage chart for this type of zener, probably, you would have to lower resistor value to 1 kOhm or so if there would be a problem with lower reading of the signal level at the input.
Quote
And the second diode in the circuit with the extra line on the symbol goes in BACKWARDS correct?

Yes, it's how zener works, in reverse area.

wally_z

@magician Is there anything I have to change in schematic #3? Also, if I use a resistor of different resistance, will it decrease performance?

Go Up