go away spammer

Author Topic: Basics: Controlling Volume  (Read 3279 times)

0 Members and 1 Guest are viewing this topic.

Offline krichTopic starter

  • Robot Overlord
  • ****
  • Posts: 165
  • Helpful? 0
Basics: Controlling Volume
« on: June 16, 2008, 06:49:49 PM »
I'm doing some basic experimenting on my breadboard.  This circuit has applications for some of the future things I'll be doing, but is currently very basic. 

I'm experimenting with an atMega168 and a speaker I ripped out of an old speakerphone.  I've been able to make the speaker emit a certain frequency on command with 50% duty cycle PWM with transistor and also with a 555 circuit.  Not terribly hard. 

Now, I'm trying to change the volume of the sound coming from the speaker.  I "think" I need to alter the voltage going through the speaker driving circuit (an astable 555, for now) to lower or increase the amplitude (is that the right word?).  I know I can change the voltage with a couple resistors with a voltage divider, but I'm looking for something I can control from the atmega168.  Can I output a variable voltage through the analog pins, similar to how I can receive a variable voltage?  (guessing no.)  How about PWM on a pin with a capacitor to smooth it to a rough equivilant voltage?  I'm without an oscilloscope right now, or I'd try both before asking.

This has to be a simple thing, since many volume knobs these days are no longer pots.

As with many things I post on this forum, I feel like I'm overthinking this and there's a simple solution.  Usually there is.   ;)


Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
    • izua electronics
Re: Basics: Controlling Volume
« Reply #1 on: June 16, 2008, 07:37:16 PM »
yes, a voltage divider is the simplest solution.
put your output on one side of the pot. put the other side of the pot to ground. the middle position (the cursor) is connected to your speaker.

a more advanced technique is to use the PWM as a dac. generate a frequency by varying the duty cycle by a sin() function. then, the multiplier you will use for the sin() will give you the maximum voltage.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Basics: Controlling Volume
« Reply #2 on: June 18, 2008, 03:41:13 PM »
Here is a simple idea . . . hook up a servo to a volume control knob, then control the servo with the microcontroller :P

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Basics: Controlling Volume
« Reply #3 on: June 19, 2008, 08:00:43 AM »
A possible solution to your problem was just posted here:
http://www.societyofrobots.com/robotforum/index.php?topic=4300.msg35122#msg35122

Offline Asellith

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 648
  • Helpful? 9
  • "I'm a leaf on the wind. Watch how I soar"
    • CorSec Engineering
Re: Basics: Controlling Volume
« Reply #4 on: June 19, 2008, 11:38:26 AM »
Wow a post of mine was quoted by Admin. I feel honored. But in reference to the digital pot and the volume you could also use the pot to change the freq on the timer to easily get pitch change as well. But putting the pot in a voltage divide would work for volume as was posted earlier.
Jonathan Bowen
CorSec Engineering
www.corseceng.com

Offline krichTopic starter

  • Robot Overlord
  • ****
  • Posts: 165
  • Helpful? 0
Re: Basics: Controlling Volume
« Reply #5 on: June 19, 2008, 01:20:17 PM »
Thanks.  I guess I'll go with the voltage divider solution.  I was hoping to avoid the digital pot solution, primarily because i don't  have any in my tackle box.  :)

The value of R2 in the voltage divider doesn't really matter, just high enough not to be a significant drain on the battery, right?  I'm thinking a 100k resistor with a 1k digital pot.  That should give me 1% to 99% resolution on the voltage if my understanding is correct.

Feel free to smack me and correct me, if I'm way off base.  I know it's pretty basic stuff, but I'm not yet confident enough to "know" I'm right without hitting Wikipedia and doing the math.




Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Basics: Controlling Volume
« Reply #6 on: June 19, 2008, 01:27:51 PM »
I recommend just trying several values on a breadboard and then using the one you like most.

Someone correct me if I'm wrong here, but can't it just go in series with the speaker and not a voltage divider?

Offline Asellith

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 648
  • Helpful? 9
  • "I'm a leaf on the wind. Watch how I soar"
    • CorSec Engineering
Re: Basics: Controlling Volume
« Reply #7 on: June 19, 2008, 01:39:51 PM »
Well the speaker is a 4 ohm or 8 ohm resistor. Actually it should act as a inductor not a resistor but still 4 or 8 ohms of coil resistance. It would probably work in series but I think the voltage divider would be easier to control the volume. The voltage divider will split the voltage between the two resistor paths and allow the volume to be regulated because only a percentage of the power is reaching the speaker. Where a resistor would just load the circuit down and force the source to either drive more current or drop voltage. I think the voltage divider would be cleaner.
Jonathan Bowen
CorSec Engineering
www.corseceng.com

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: Basics: Controlling Volume
« Reply #8 on: June 19, 2008, 04:46:13 PM »
ive been a lot in the audio field and here is some advice
1/ ac couple the speaker, dc damages it
2/a voltage divider wont amplify ,,it would decrease the volume and you'll loose current (bad idea)
3/use audio amplifier ICs ,,cheap and very effective
4/your setup should have a preamp and a poweramp, i would use an audio amplifier IC instead of power BJTs to ease design unless you dont want very big volumes
good ol' BeNNy

Offline krichTopic starter

  • Robot Overlord
  • ****
  • Posts: 165
  • Helpful? 0
Re: Basics: Controlling Volume
« Reply #9 on: June 19, 2008, 11:13:18 PM »
Thanks benji.  Would this approach be as relevant for ultrasonic frequencies as it is for audible frequencies?  I plan on starting with something audible for the experiments, but ultimately this project is going ultrasonic.

thanks to everyone for their great input.

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: Basics: Controlling Volume
« Reply #10 on: June 20, 2008, 09:33:22 AM »
ultrasonic and a speaker????
the signal freq is ULTRAsonic ,,so how on earth you would be able to hear it????
good ol' BeNNy

Offline krichTopic starter

  • Robot Overlord
  • ****
  • Posts: 165
  • Helpful? 0
Re: Basics: Controlling Volume
« Reply #11 on: June 22, 2008, 03:50:56 PM »
hehe, no.  I'd like to build a test circuit first using a speaker and audible frequencies.  Then, once I've learned as much as I can, I'll build a new and similar circuit, but replace the speaker with a 40khz transducer and change the frequencies used to ultrasonic.   

 


Get Your Ad Here

data_list