Sound!

We have a burnout Robot that does burnouts (smokebombs!) and we wanted to add sound (simple fixed pitch, squealing sound) to our robot (IFI system). I did a tad of research, and it appears that all I would need is a 5v speaker and hook it up to a relay and every loop send it forward and next loop send reverse. Am I correct or would i have to use the pwm? I would have to use the fast loop, and execute it with a counter to change the pitch and like.

Are you referring to hooking the speaker directly into the relay output, or hooking the relay output to a relay hooked to the speaker?

An alternative: Record a burnout sound on one of those Radio Shack 20-second solid-state record/playback thingies (under $20), use an amplifier for the speaker to make it as loud as you want (e.g., a boom box using external audio input), and use the relay (momentary closure) to trigger playback.

A very realistic sound for little $ and effort.

Plus, you can swap out sounds. Like “moo” - now that would be funny.

Relay to speaker

I would revisit this design before implementing it. As I understand it, you are toggling it on or off each time the main loop executes, which is quite slow in the sound world. Remember, you can only generate tones that are at most half of your update frequency. A “squeal” noise would be several kHz (thousands of cycles per second), but the IFI update rate is only several tens of herz (tens of cycles per second). Even if you sent the signal fast enough, the relay would be unable to respond.

It may be theoretically possible to do it with a CAN enabled Jaguar - after all, the Segway makes its vooOOOIIIIIP start up noise this way. However, I can’t guarantee it is possible, and even if it is it will be hard.

I really like Don Rotolo’s suggestion. I used one of those for a project in college - very quick and simple to get it working. It handles all the quick stuff, so you can ignore everything I said in the first paragraph.

A simple fixed pitch is a beep. It won’t sound like a squeal.

If you wish to pursue this idea, I suggest you use a digital output rather than a relay output. The update rate on the relay pins is way too slow for the kind of sound you’re aiming for.

I have done this before as a project on another microcontroller (an HCS12 to be exact). I hooked up a speaker and amplifier to a PWM output and modulated the PWM period to generate different tones (granted, the square PWM wave sounds a little strange, but with a simple RC filter you can get a roughly sinusoidal, single pitch sound).

I suspect that if you were to look at some of Kevin Watson’s code on how to use PWM ports 13-16 with custom frequencies, you could probably do something very similar.

I think I will do it like this, could you give me some wiring diagrams?