Controlling loudspeaker beeps

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

For a simple user interface I have to generate some beeps. At the same time, the underlaying program has to respond to interrupts for software UARTS and their like.

Does anybody have an idea how I should keep these two rather timing-intensive tasks running at once? I also consider putting up an atTiny to control just the loudspeaker from its interrupt function. Another way to go might be to get a loudspeaker with some kind of beep generator - give it some voltage and it beeps. Anybody seen such a thing?

Anyway, thanks for setting up this page. It's nice to have a forum for AVR talks.

Best regards

admin's test signature
 

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

I have a simple routine that makes beeps for arm and disarm beeps on a house alarm.....

It should run in the forgraound with IRQ running unnoticed in the back graound though you will need to modifi it to suite you're application....

Please email me if you are interested and ill email you the asm file

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

Perhaps a PWM will do. For example, if you use an AT8535, then with various settings for TimerCounter1 prescaler and the PWM resolution you should find a block wave to your liking. Then just use a simple amplifier cirtuit (I think a single transistor would do) to drive a piezo buzzer.

I'm not an electronics expert, but I do know what a PWM is!

Dave

admin's test signature
 

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

why don't you try a piezoelectric buzzer ?
It can be directly driven from one of your available ports and
it consumes only <10mA

Vaggelis

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

Bob,

If you are using a 2313 or above, I think there is a solution which uses no processor time or interrupt resources at all! (Note: I haven't actually tried this - this is from inspection of the documents and experience from doing something similar driving IREDs.)

This involves some familiarity with the Timer 1 compare match function.

You should be able to set bit 3 (CTC1) of TCCR1B to zero timer 1 when a compare match occurs. You can then set a value in the timer compare register and prescaler for timer 1 which will set how often this match happens.

If you also set bits 7 and 6 (COM1A1 and COM1A0) in TCCR1A to 0 and 1 respectively, this sets up the timer to toggle pin PB3 when the timer overflows.

Once this is set up, this should work without any processor load and will not generate any interrupts unless you specifically enable them.

To disable the output , reset bit COM1A0 in TCCR1A - this disconnects the timer overflow from the output pin.

(Source data is on pp 32-33 of the 90S2313 documentation.)

Sean Ellis