SOUND command

matchbox

Senior Member
Has anyone found a work-around type thing. To change the amplitude or volume of the Sound beeps, through a command?

Or can it only be done by driving the beeper with a PWMout command?
 

erco

Senior Member

inglewoodpete

Senior Member
If you're using a piezo 'speaker', then changing to PWM won't make much difference. Note the piezos are quite peaky around their resonant frequency, so the volume won't be very consistent when you change the frequency.

Just a thought for changing the volume. An NPN transistor's gain is dramatically changed by adding resistance between its emitter and 0v. If you use a transistor to drive the speaker, you could try a chain of resistors between the emitter and 0v (Eg 3 x 330ohm). Also, include a 1k resistor between the PICAXE "Sound" pin and the base of the transistor. Then connect a diode between each resistor junction and a spare pin on the PICAXE (cathode towards the PICAXE pin). Turning ON or OFF each 'volume control' pin should change the gain of the transistor. Note that I have not tried this myself!
 

Buzby

Senior Member

Here is an idea I used a few years ago.
 

AllyCat

Senior Member
Hi,

It may depend which PICaxe you want to use (the 08M2 is more restricted) and whether you want to use the SOUND command, or just a more general "Beep" or TUNE, etc.. But for a good range of amplitude (Volume) and frequency (Pitch) you probably need to use some degree of "external hardware", but it could be quite simple. For example the DAC output level being "chopped" (modulated) by a diode to another pin carrying the Sound square-wave. Or as Pete suggests, using different pins to select the output drive and/or amplifier gain (via different resistor values).

Personally, I would explore the possibility of PWM-type commands driving a Resistor-Capacitor Low-Pass filter (R from the output pin, C to ground shunting the higher harmonics). The filter will make the sound "smoother" (i.e. with less harmonics) and narrow PWM pulses (i.e. with a low duty cycle) will sound quieter. Theoretically the PWMOUT command even gives the possibility of playing "Chords", but it does require the program-writer to issue a "Stop" (OFF) command at the end of the note(s), after a suitable PAUSE. With a Low Pass Filter, the PWMOUT command can select a Pin, the Frequency (PERIOD and PWMDIVn) and Volume (DUTY).

Other "Low Hardware" possibilities are to use the internal "Digital Signal Modulator" (DSM) in M2s and/or hanging a capacitor on a "Touch" input pin (to generate a "Triangle wave" with various amplitudes and frequencies).

Cheers, Alan.
 

matchbox

Senior Member
Thanks guys for all the idea's.
It is only a simple setup. Just a piezo transducer element, that beeps different sequences.

My idea was to have the less important tones beeping quieter. And the more important ones beeping at full volume.
I'll think your surgestions through and see which one will give me the least amount of work for effect;)
 

premelec

Senior Member
With just two levels - if you can use two pins just put a resistor in series with the piezo on one pin and straight with the other - and call the appropriate pin for volume. There are also digipots with serial control - 2 pins...
 
Top