detecting volume

Go To Last Post
21 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi,

it seems like a big problem, maby someone can help me.

i need to detect the current volume on head unit speaker output (not the one from the amp)

the + and - are not referenced to the groud but seems floating on 6V.

i thought i could put a diode and a capacitor and sample the line 100 times but it is a problem as first its deferential voltage and second i need to sample the front and rear. the result is not very accurate and its quite a problem to also conclude the fader possition.

if anyone have any sugestion i will be happy to hear.

Thanks and Regards, Ran.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don't know what particular system you are talking about, but it looks like it is being driven in a bridge configuration. This means both lines are carrying the same signal, only one is inverted. So just monitoring one line per speaker should be enough.

Calculating the fader position is going to be tough. The volume that your system will detect will be dependent on the audio being played at the time. Maybe you should get the original audio signal also, then compare that with the speaker signal.

Regarding level detection, there are several to choose from. Usually a simple peak detector works reasonably well.

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

emuler, your answer helped alot as it gave some reference to internet articles.

if i understand correctly, my car amp is in a bridge configuration and with a DC offset of 6 volts.

i looked at the internet for a peak detector and found this:

http://www.allaboutcircuits.com/vol_3/chpt_3/5.html

this is very simmilar to what i tried to do when trying to convert my audio signal to a DC voltage. the problem with that is that when lowering the volume it takes lots of time for the capacitor to discharge (cheked with an oscilloscope load).

the fader position calculation is indeed tough.
at first i thought i could sample the the two chanel audio (back and front) connected to two "fast discharging peak detector", make an avarage sum of the results and try to understand where am i.

i had several problems with that:

1. my atmel can check voltage between 0 and 5 volts (can i change the reference?)
2. i don't have a debuger in my chip so i couldn't check whats going on but the calculations was anything but accurate and the relay i connected at the output was clicking with strange relation to the volume or fader.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You just need to put a resistor across the capacitor to control the decay. Or a constant current sink, if you prefer. Or if you want to be geeky, have the AVR discharge the cap after each sample has been read. (This makes the circuit a sample and hold).

Quote:

1. my atmel can check voltage between 0 and 5 volts (can i change the reference?)

Sure. Or you can add a voltage divider if the signal is too high, or an amplifier if it is too low (unlikely).

AC couple the signal from the speakers to get rid of the 6V bias, but make sure the pins of the AVR never go below ground (use a diode to clamp it - if the resistance of the divider is high enough, the internal protection diode should be all you need).

What on earth are you doing with a relay? Klutzy. :P At least replace it with an LED until you get your circuit working the way it should. Relays have a limited life, you know.

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks emuler, great stuff.

Quote:

What on earth are you doing with a relay? Klutzy. At least replace it with an LED until you get your circuit working the way it should. Relays have a limited life, you know.

i know, i hate relays too but i think i have no choice.
my amp has only two inputs but my pioneer has 4 (front and back). as i fader to the back speakers i need to switch the inputs to the amp so that the sound won't be lowered. if you can think of another option i would be more than happy to hear.

Regards, Ran.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

(This makes the circuit a sample and hold).

Not quite - more of a track and hold. :oops:

Quote:

my amp has only two inputs but my pioneer has 4 (front and back)

4 outputs, you mean. But then why use the rear outputs at all? Just set the fader to max forward and leave it at that.

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
4 outputs, you mean. But then why use the rear outputs at all? Just set the fader to max forward and leave it at that.

the amp has a fader option, i want to use it. but its commands are not for the pioneer, so i need to make some adjusments.

Regards, Ran.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not getting your setup. Describe your amp and the Pioneer whatever it is (Pioneer makes a massive range of equipment; just saying Pioneer is not helping me understand). What is connected to what?

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The + and - thing, that is called balanced audio output. By using simple differential audio amplifier you can convert the balanced signal to unbalanced (+ and ground) and read it with ADC. You can adjust the differential amplifier's gain so it won't exceed the AVR's max input voltage capability. Oh yeah, don't forget to put a 5.1V zener diode as a protection. :)

KISS - Keep It Simple Stupid!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
The + and - thing, that is called balanced audio output. By using simple differential audio amplifier you can convert the balanced signal to unbalanced (+ and ground) and read it with ADC. You can adjust the differential amplifier's gain so it won't exceed the AVR's max input voltage capability. Oh yeah, don't forget to put a 5.1V zener diode as a protection.

are you talking about a simple op-amp with substraction configuration and 0.x gain?

Quote:
I'm not getting your setup. Describe your amp and the Pioneer whatever it is (Pioneer makes a massive range of equipment; just saying Pioneer is not helping me understand). What is connected to what?

the pioneer is a DVD H.U that have 4 outputs for an amp and 4 outputs for speakers. as i have only two inputs to the amp i am connecting them to the 4 pioneer amp outputs via relay (each time only front OR back connected to the amp). i want to take the other 4 differential apeaker outputs and from them understand the fader. when fader is up switch the relays so sound won't be lowred to the amp.
in addition, my amp can get instructions via communication to change fader position (aldo it had 2 inputs it has 4 outputs and he can fader). in addition to the relay control i need to also calculate the fader position the pioneer is corrently in and send the same position to the amp.

Thanks again, Ran.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can you configure the Pioneer unit to give you standard 2 channel Line out? Or is that hardwired to the fader?

Best recommendation: get another amp and wire that up to the other two outputs of the Pioneer unit. Then you'll have 12 speakers. :roll:

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

big problem! :?

first of all, it is basicly working. the ac coupling terminates the bias, the peak detector is relatively steady, the AVR drop to GND is discharging the capacitor.

BUT, as there is an amp connected to the unit, normal operation of the unit is about 1/4 of the volume, and as i am cheking the normal speakers for fader position, the variations at the peak detector output are very very small and so the reading is very pour. it seems that i need a good amplifier to read it. but it has to be quite clean. at the osciloscope it seems quite hopeless, but i don't know, maby it will work.

Quote:
Can you configure the Pioneer unit to give you standard 2 channel Line out? Or is that hardwired to the fader?

Best recommendation: get another amp and wire that up to the other two outputs of the Pioneer unit. Then you'll have 12 speakers.

this is an idea but only as a last result. the amp is quite good and basicly i don't need another amp for extra watt.

also, i looked at the pioneer options but didn't see something like that, maby i will take another look.

Thanks again, Ran.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How many speakers do you actually need? The amp can drive 4 and the Pioneer DVD can drive 4. What is your desired speaker configuration?

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
How many speakers do you actually need? The amp can drive 4 and the Pioneer DVD can drive 4. What is your desired speaker configuration?

amp can drive 4 but it only has 2 inputs. the fader was previously controlled by the original head unit. i have a pioneer head unit that have 4 outputs for connection to an amp but i don't want to throw the original amp.

Regards, Ran.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

How many speakers do you actually need?

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

2 inputs and 4 outputs.

what i think i will do is make two little amps and try again.

Thanks emuler for the help, you've been of great help :)

Best Regards, Ran.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

emuler wrote:
Quote:

How many speakers do you actually need?

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i don't understand the question emuler.

i want to connect all of the speakers as if i never took the main head unit out and replaced it with the pioneer.

at this amp i have two inputs (stereo) but for outputs i have stereo front and rear, subwoofer and i think a center. by the way, this is for a new land cruiser.

BTW: is there a special type of amp you think might be good for the job, i tried one type but i didn't noticed it needed a very low load (like a speaker) to operate, this is taking lots of power...

Regards, Ran.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you don't need the speaker outputs of the Pioneer head unit, all you need to do is:
1. Set the fader in the Pioneer HU to 'full forward'. Leave it like that permanently. Lock it in place with glue or tape if necessary.
2. Connect the front outputs of the Pioneer HU to the inputs of the amp. Leave the rear outputs of the Pioneer HU unconnected.
3. Connect the speakers to the amp outputs like they were before (like when the old HU was being used).
4. Use the fader on the amp.

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks emuler, i know i can do that but i want to solve this problem.

Regards, Ran.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have followed up with Ran off Avrfreaks on this item. I would like to share what I have come up with in basic terms.

Using an AVR, like the MEGA48, sampling the signal with the A/D(using two channels to get front/back) check each sample coming in with a previous sample MAX and MIN. something like the following code. The sampling rate could be as low as the signal will allow, but likely 4ksps to 8ksps. The below could would be used for each channel sampled.

if(NewSample>OldSample ) 
  Max=NewSample
else if(NewSample

This would place the sample as a max or min for as long as the AVR has been sampling. These max and min would need to be reset each time a new fader position was being detected... once a second possiblely.

After doing the above for each channel of interest, a peak for each channel, and the differance between chan would be computed.

Function ComputePeak()
{
 Peak=Max-Min
}



Function FaderPosition()
{
 fader=PeakA-PeakB

If (fader > 0) fader to front
If (fader < 0) fader to back

}

This is the basic overview of how I would start solving this problem.

By placing the peak detection inside the avr, the sampling rate can be vaired without need to adjust the Cap. and Res. values during sampling as would be need when using an external Peak detect. The AVR has lots of CPU power to sample and convert the values to a meaningfull number.

There would need to be some tuning of the system to get it to work well enough to know fader level's that are to close to center.

Caleb