Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Vu meter arduino input signal

Status
Not open for further replies.
Hi. I have been searching all over the internet for 3 hours now and i cant find my answer

I want to build ARDUINO VU METER.

The only problem is that i dont know what input signal do i need to have:
1) + from 3.5mm jack directly to A0
2) + from 3.5mm jack through voltage divider to A0
3) + from 3.5mm jack through some amplifiers or noise reductors to A0
4) or something else?

My VU meter would have 16 LEDs..
 
Whether or not you need to amplify or attenuate your signal depends on the amplitude of the signal. What is the signal source feeding the jack?
 
So can i plug + of 3.5mm jack from computer directly to Analog input of atmega 328p?
I read somewhere that that signal swings around 0V, and that i need to shift that signal to 2.5v (i dont know how?), and is that true?
 
hi,
I would agree that the audio signal output will swing +/- thru 0V.

You need to shift the audio signal to half the Vdd supply of the atmega, so that the analog has only 0V thru +Vdd input.

E
 
That should suffice. Read the datasheet regarding source impedance. The input is probably ~1V or so peak-to-peak, so won't cover the full range of the ADC, but as you are only resolving to 1 part in 16 that shouldn't be a problem.
 
That should suffice. Read the datasheet regarding source impedance. The input is probably ~1V or so peak-to-peak, so won't cover the full range of the ADC, but as you are only resolving to 1 part in 16 that shouldn't be a problem.
I think you are right.
What capacitor should i use here? And what capacity should it be?
 
A 3.3uF (plastic film or ceramic) cap will give you a -3dB point at ~10Hz.
 
I can't get a file to upload. So I won't send a schematic.
I would take the circuit above and add a 1k resistor to the ADC input. This will limit the input current. If the audio signal is too loud it should not be allowed to drive the ADC input beyond the supply rails. Add some resistance should save the ADC.
 
I second Ron's suggestion. If you're concerned about going beyond the supply rails you could also add a couple of reverse-biased Schottky diodes from the ADC input to respective supply rails.
 
I am not. If something happen to atmega328p, than it would be a problem. If it would work with 2 resistors and one capacitor than that is it :)
 
When building a VU meter there are several options.
Peak, RMS, Average, etc......
You need to do this in software.
Many circuits do this in hardware before the ADC. (rectify, filter, average.....)
You will need to do these things in software. Zero volts=1/2 supply. First do a absolute value thing. [values below the mid point need to be inverted] Then filter (average) with a certain response time. (attack and release time) Normally there is a value for how fast the meter swings up and (much slower) how fast the meter falls back down. In the case of a peak meter the attack time is very fast and the release time might be 1 to 2 seconds. Doing it all in software you need to read the ADC as fast as you can.
 
I am not. If something happen to atmega328p, than it would be a problem.
Driving the atmega ADC input with a voltage beyond the supply rails could damage it. That's why Ron suggested the 1k and I suggested the Schottkys.
 
Driving the atmega ADC input with a voltage beyond the supply rails could damage it. That's why Ron suggested the 1k and I suggested the Schottkys.

You mean if voltage on ADC is over +5V?
That was what i was concerned about too, but i cant measure 3.5mm uotput when music is playing, because it is too fast for my multimeter. But i think the voltage i can get is very low even when loud music is playing, isnt it?

And i know about softever problem, but i have LM3915 on my first vu meter and it is not interesting. I want to have an options. And i hope i would be able to make it work with atmega. I like one mode that i have seen: its like regular vu meter bar mode, but with upper led going down very slow. Thats what i want to do :)

Here is my inspiration:
 
You mean if voltage on ADC is over +5V?
That was what i was concerned about too, but i cant measure 3.5mm uotput when music is playing, because it is too fast for my multimeter. But i think the voltage i can get is very low even when loud music is playing, isnt it?

And i know about softever problem, but i have LM3915 on my first vu meter and it is not interesting. I want to have an options. And i hope i would be able to make it work with atmega. I like one mode that i have seen: its like regular vu meter bar mode, but with upper led going down very slow. Thats what i want to do :)

Here is my inspiration:

The input of the ADC can probably only handle 10mA. I don't know about your audio. If is is designed to drive little head phones it can drive 100mA. If if it is designed to only drive the input of a amplifier the sending amplifier probably can exceed, or get close to 10mA. AND When you first plug in there will probably be a static spark. For the cost of a 1k resistor you can protect the ADC. [1k resistor, 10mA is 10volts so the input can take a +/- 10 volt signal]
You mean if voltage on ADC is over +5V?
If the voltage is over +5 or below 0V (negative)
Because you AC coupled with a cap the voltage at the ADC is 2.5V when the input is 0V. So then the audio is swinging form -2.5 through 0 to +2.5 the ADC sees 0v, 2.5v, 5V. As you get to 0 and 5V the ADC input clamps and draws current. If there is no current limiting resistor the current is only limited you the drive current in the audio source. If your audio is +/- 5 volts the ADC will be over driven. The extra +/- 2.5 volts will be across the 1k resistor I want to add. This will limit the current to 2.5mA.
 
Thank you for explaining that to me :)
Ill put 1k resistor then.
One more question: on lm3915 i have potentiometer to adjust how high leds go. It depends on voltage and how loud music is.. How can i adjust it here? I know how can i do it in software but maybe hardware-way is easier :)
 
One option that will work well with strong signals.
Signal to one end of pot. Other end of pot to ground. Wiper of pot to cap. (maybe a 1k pot)
Will not help with week signals.

I am doing something like this with a XMEGA and they have a gain amplifier in front of the ADC. So you can set the gain to 1,2,4,8 or what you need.

You will soon have this working. Save the biggest number over 1000 samples. This way you can see how big the signal is. Maybe 10,000 samples. If you are getting FF and 00 hex then your signal is too large. (using 8 bit numbers)

Most of these output log not linear. Your ear is log not linear.
 
Hi! I was investigating on this same subject, we all love the leds and the sound... so I conect this voltage divider and I recive the input as was
planing, but is too low to acomplish an good VU I think.... Any way am not an expert but I found this guy doing a pre-amplification with
a comom LM 234 I think... You can see the diagram in here:

https://www.instructables.com/id/Arduino-Audio-Input/

Cheers ! Keep us posted...
 
On the same line of thought... I am writing a program that will test radio harnesses custom pinned for a customer. I have messed with some simple VU meter program code and can get 1 line to work fine. My issue is when I connect all 4 (left front, right front, left rear, right rear) that I get all 4 lines triggering even when there is no signal going to them. I don't need to know what the levels are... basically is there signal or no. I'd be game for each speaker lead to trigger a transistor allowing 5V to be read by digital pins. This needs to be simple and as few discrete components as possible. Triggering the transistor is looking better than direct connect to an analog input. The speaker values are in mV.
Any help would be appreciated!
Thanks!
Doug
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top