go_away

Author Topic: Speaker for Axon2...  (Read 2412 times)

0 Members and 1 Guest are viewing this topic.

Offline KurtEckTopic starter

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 12
Speaker for Axon2...
« on: February 16, 2010, 11:00:57 AM »
Sorry if this has been asked before, but my searches did not find any...

I am really enjoying programming in C on the Axon2.  But one thing I miss from my Lynxmotion Bot Board 2 with a Basic Atom Pro installed is a simple speaker to make sound.  I am not talking about any complicated sounds, but some simple different tones.  I find this comes in handy for things like: Start of Program (so I know if it rebooted).  Maybe a different sound for enable/disable of the robot, likewise different sounds for different modes or speed selects...

For many things the built-in LED works great but only if I am looking at it :)

Suggestions?

Thanks

Kurt

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,660
  • Helpful? 169
    • Society of Robots
Re: Speaker for Axon2...
« Reply #1 on: February 17, 2010, 12:15:27 AM »
You just need a piezo buzzer attached between a digital pin and ground, and you can create various sounds using PWM in WebbotLib. The latest version of Axon II demo code has a PWM example.

A MOSFET can be used to amplify the sound if its not loud enough.



Offline enekux

  • Jr. Member
  • **
  • Posts: 23
  • Helpful? 0
Re: Speaker for Axon2...
« Reply #2 on: December 28, 2010, 09:37:59 AM »
Hi people!

The last week I have been messing around with just what you guys are mentioning and I would like to share some very useful links about how to use hardware PWM signal in order to create some music using an AVR processor and a Piezo Buzzer:

http://aquaticus.info/pwm-music

http://www.ermicro.com/blog/?p=580

http://www.societyofrobots.com/member_tutorials/node/235

I have based this info to make my own project using the Axon2 and the WebBotLib and everything works fine!

Still if you have further questions just let me know!

good luck!

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Speaker for Axon2...
« Reply #3 on: December 28, 2010, 03:48:16 PM »
Hi,

I'd advice putting a capacitor in series with the piezo - DC kills piezos.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,207
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: Speaker for Axon2...
« Reply #4 on: December 28, 2010, 06:14:08 PM »
I also advice not to use a piezo or even worse a magnetic speaker directly with a microcontroller...

Capacitive and/or inductive loads, respectively, can kill microcontroller pins with reverse currents... Although piezos aren't a problem...A speaker will be.... Use a simple bipolar transistor... If you don't want to mess with BJT then use a simple FET...

That's all ;-)
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

Offline VegaObscura

  • Robot Overlord
  • ****
  • Posts: 153
  • Helpful? 6
Re: Speaker for Axon2...
« Reply #5 on: December 28, 2010, 06:24:40 PM »
Hi,

I'd advice putting a capacitor in series with the piezo - DC kills piezos.


Then how do you make them work?  Don't microcontrollers always put out DC?  Do you mean you need to add a capacitor in series and use PWM? 

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,660
  • Helpful? 169
    • Society of Robots
Re: Speaker for Axon2...
« Reply #6 on: December 28, 2010, 06:34:17 PM »
PWM signals are AC :P

A capacitor in series basically stops current from flowing when the voltage isn't changing - which stops DC currents.

Offline enekux

  • Jr. Member
  • **
  • Posts: 23
  • Helpful? 0
Re: Speaker for Axon2...
« Reply #7 on: December 29, 2010, 03:17:45 AM »
@Soeren,
yes you are right and I confirm that the DC kills, (probably) piezos (not tested yet) and magnetic speakers (fried like a cheese stick) ;)

so in case you use magnetic speakers I would use as a protection a capacitor in series yes, and for piezos I don't know. Also what it is important to know here is that both components work like a low pass filters, converting the square wave into a sine wave signal, so there is no need of pre conditioning the signal.

by the way I want to share some more interesting links about the topic:

http://www.uchobby.com/index.php/2007/11/11/arduino-sound-part-1/
http://www.uchobby.com/index.php/2007/11/14/arduino-sound-part-2-hello-world/
http://www.uchobby.com/index.php/2007/11/22/arduino-sound-part-3-playing-a-melody/

cheers!

Offline Crunchy Theory

  • Full Member
  • ***
  • Posts: 80
  • Helpful? 0
  • "Well great is ok, but amazing would be great."
Re: Speaker for Axon2...
« Reply #8 on: January 04, 2011, 12:21:47 PM »
Can the piezo buzzer handle the speech synthesizer sounds in webbotlib? Or do we need an actual speaker for that?

I've actually been looking around for small speakers and they are surprisingly hard to find. There was only one on sparkfun, but I was hoping to find something a lot smaller - like a speaker from a cellphone. Any suggestions?
The only way to top an upright screen, keyboard, and mouse is to eliminate the need for humans to touch a PC at all. Oh, hello there Mr. Robot... what would I like you to do, you ask?

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,660
  • Helpful? 169
    • Society of Robots
Re: Speaker for Axon2...
« Reply #9 on: January 04, 2011, 01:23:13 PM »
I'm not sure if a piezo can handle it or not . . . probably sound very buzzy . . . let us know what you find!

Mouser.com has lots of speakers, all listed by the ohmage, too.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,150
  • Helpful? 110
Re: Speaker for Axon2...
« Reply #10 on: January 04, 2011, 05:30:34 PM »
Yep - I wouldn't use a buzzer. My speech synth stuff first appeared in the member tutorials on this site. Look in there and you will see a circuit for a small amplifier.

To get the best from the synth code then you need to get good bass on the output. I found that putting the speaker into a box, with acoustic padding or something similar made a real difference.

When you buy the speaker - try to find one that has mounting screw holes on board. Otherwise, if its just the speaker, then you will have to 'hot glue' it in place - which needs more 'kit'.

Also if your bot goes outside then try to find a speaker with a plastic cone (eg Mylar) rather than a paper one - they survive the damp much better.

Something like this (UK) :- http://www.maplin.co.uk/Module.aspx?ModuleNo=3275&OrderCode=VC84F
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline enekux

  • Jr. Member
  • **
  • Posts: 23
  • Helpful? 0
Re: Speaker for Axon2...
« Reply #11 on: January 05, 2011, 03:25:54 AM »
... those speakers that Webbot is showing us are similar to the ones in iRobot, which I used it in Axon II and I burned it, when I connected, by mistake, to the pins Vcc/Gnd instead of PWM_pin/Gnd ;)

So then I bought a piezo and I developed a program for playing some music using PWM signals and everything worked fine!

but no idea about speech synth...

Offline VegaObscura

  • Robot Overlord
  • ****
  • Posts: 153
  • Helpful? 6
Re: Speaker for Axon2...
« Reply #12 on: January 05, 2011, 08:44:58 AM »
PWM signals are AC :P

A capacitor in series basically stops current from flowing when the voltage isn't changing - which stops DC currents.
What size capacitor is good to go with a piezo?  Around 0.1uF or more like 200uF?

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,150
  • Helpful? 110
Re: Speaker for Axon2...
« Reply #13 on: January 05, 2011, 02:55:18 PM »
... those speakers that Webbot is showing us are similar to the ones in iRobot, which I used it in Axon II and I burned it, when I connected, by mistake, to the pins Vcc/Gnd instead of PWM_pin/Gnd ;)

So then I bought a piezo and I developed a program for playing some music using PWM signals and everything worked fine!

but no idea about speech synth...

Yep - so nothing wrong with the speakers - just badly connected. Lesson learnt and then piezo worked.
I've used these speakers with my WebbotLib Tone library just fine - with a 1k resistor in series with the speaker. No blown speaker, no blown chip port. But for the speech synth then you really DO need a proper amplifier.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Speaker for Axon2...
« Reply #14 on: January 05, 2011, 11:17:18 PM »
Hi,

@Soeren,
yes you are right and I confirm that the DC kills, (probably) piezos (not tested yet) and magnetic speakers (fried like a cheese stick) ;)
DC kills piezos (100% for sure) by de-poling the piezo x-tal material. They can be re-poled, but it takes a bit of know-how and involves high voltages.

A plain old speaker is an entirely different component and the two doesn't compare at all.
The DC should have some energy to kill a speaker and can be determined by Ohms law, as a speaker being fed DC behaves 100% like a resistive load (until the windings melt).

Piezos are like capacitors and will not pass a DC, but the DC will bend the crystal one way making it look slightly like this "(" (and like ")" if you reverse the polarity) and keeping the DC on will, as mentioned, de-pole it. With a high enough voltage, the crystal will break.


so in case you use magnetic speakers I would use as a protection a capacitor in series yes, and for piezos I don't know.
No cap needed, just a transistor to separate - PWM isn't really Hi-Fi, as used by controllers, so a class-C amp is plenty.


Also what it is important to know here is that both components work like a low pass filters, converting the square wave into a sine wave signal, so there is no need of pre conditioning the signal.
A piezo is just the opposite - a "HP filter" (although I wouldn't use such a term).
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Speaker for Axon2...
« Reply #15 on: January 05, 2011, 11:44:31 PM »
What size capacitor is good to go with a piezo?  Around 0.1uF or more like 200uF?
Depends on your piezo and how high you want the efficiency.
The average size (~10mm to ~40mm in diameter) piezos I have tested vary a lot in capacitance value, but most are between 10nF and 25nF IIRC (been some 8..10 years since I last made a major check).

The cap and the piezo will be in series and as such, will be a capacitive voltage divider. very similar to a two resistor voltage divider.
Assuming a piezo of say 15nF and an accepted amplitude loss of 50%, you'd need a cap of 15nF
If you want the loss to be say 5% max, use 330nF (=> 4.3% amplitude loss with a 15nF piezo). The larger the cap, the lower the loss, but don't overdo it.

For a real ear shattering sound (from even a small diameter piezo), a transistor and an inductor to make a resonant amplifier and use nodal mount for the piezo.
For wideband (speaker) use, edge mount gives the widest bandwidth followed by center mount.
Wideband has to be read as a relative size here, but piezos ain't half as bad as most people make them sound (double pun intended ;))  Many a Hi-Fi speaker is built with piezo tweeters, but don't expect lots of low frequency amplitude.


(Perhaps it's about time for a tut on piezos and sound in general in relation to controllers?)
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline enekux

  • Jr. Member
  • **
  • Posts: 23
  • Helpful? 0
Re: Speaker for Axon2...
« Reply #16 on: January 10, 2011, 02:46:54 AM »
Thanks for the info Soeren!

 


Get Your Ad Here

data_list