"Pleasant" Sound alarms

The device I am designing should emits bips when a special situation occurs. Three levels of alarms have been defined according to the severity of the situation: Notification alarm, critical alarm, major alarm.

A buzzer is connected to a PWM output for internal bips and a relay is connected to an io for external bips.
Notification alarm concerns only the internal buzzer, but others concern both internal buzzer and external buzzer.

Internal alarm uses a kind of pattern to play musical notes over a period (8 notes can be played per period)

The application monitors several environmental parameters and take the decision to launch or not an alarm. The main problem is that the alarms does not sound proffesionnal, bips are not emitted regularly (timer to change tone of buzzer is 100ms) and results is poor. Do you have any idea to solve that? any alarm library

@ leforban -

Why not play notes using PWM.

Not sure what board you are using but maybe this could get you started.

(My sample code)

@ willgeorge - He needs to play more professional sounds, meaning different frequencies at different amplitudeis needed typically.

@ leforban - best way would be to use the analog output. Connect it to a small amp and then play any sounds (PCM WAV) you like on the speaker.

1 Like

Many thanks for your answers guys! When I say professionnal, I mean that I don’t want to play Bach or Beethoven music but more emits some bips with regular tone and with a uniform period. I am using PWM and a buzzer. I can play notes and melody but melody is not really important, the thing I want to achieve is to emits bips regularly (let’s say 5 bips per second). Therefore I am using timer to activate buzzer or not but result is really poor and depends on the other tasks that run on the platform. I am using EMX for the moment but will switch to G400 soon and won’t have analog output ???

@ leforban - You need accuracy?

Accuracy ? a little bit yes!

For the moment it sounds to me that the timer callback can be delayed a lot…

@ leforban - Yes they can. NETMF isn’t designed to do this. It’s goal is to allow development of complex functionality on these small scale devices quickly and easily. If you want tighter timings then you will have to use RLP or an external IC.

I have a buzzer on a PWM pin for my oven controller. I use a thread to handle the audio output and this way I don’t have any timing issues with timers. I fire off the thread to create the sound and then it exits when I stop the alarm. You can also suspend and resume the thread for the same effect.

Interesting, do you mean that creating the sound in a separate thread would result in a more accurate timings than creating the sound in the main thread and use timers to manage start stop?

Give it a try. It works fine for me and I am updating graphics etc in the main loop. I don’t hear any timing changes with the sounder.

Good news, it may be the solution, I will try it soon and will let U know. Thanks the idea :slight_smile:

Hummm ??? When I said soon… Here I am, I have time for that now.

Let’s go for a thread solution!

1 Like

Sorry, couldn’t resist ;D

What an impressive film culture!!! :clap: