deivid77
Posts: 30
Joined: Wed Jun 24, 2015 6:09 pm
Location: Spain

Make a buzzing sound

Fri Oct 09, 2015 6:45 am

Hi folks,

I have a couple of buzzers.

When I set "GpioPinValue.High" to the pin the sound level is minimum.
Only dogs can hear it.

The snippet:

Private Const BUZZER_PIN As Integer = 18
Private _buzzerPin As GpioPin

Public Sub New()
InitializeComponent()

Dim gpio As GpioController = GpioController.GetDefault()

If gpio IsNot Nothing Then

_buzzerPin = gpio.OpenPin(BUZZER_PIN)
_buzzerPin.SetDriveMode(GpioPinDriveMode.Output)
_buzzerPin.Write(GpioPinValue.Low)

For i As Integer = 1 To 20

If i Mod 2 = 0 Then
_buzzerPin.Write(GpioPinValue.High)
Else
_buzzerPin.Write(GpioPinValue.Low)
End If

System.Threading.Tasks.Task.Delay(1000).Wait()

Next

End If

End Sub


Can you help me?

Thanks in advance

Dave White

ricl
Posts: 657
Joined: Wed Aug 26, 2015 11:55 am

Re: Make a buzzing sound

Fri Oct 09, 2015 8:41 am

That's because the GPIO pins only supply 3.3v at a recommended maximum of 3mA per pin.

http://www.thebox.myzen.co.uk/Raspberry ... tputs.html

You need to create some sort of output buffer board/interface which is capable of driving the current/voltage required for a loud sound or try an already buffered buzzer like

http://www.amazon.co.uk/3-3V-5V-Transis ... B00JP7UST2

No knowledge of how loud that one sounds though :-(
ricl : F/gamma = ma : Law ii(a) : https://climatedatablog.wordpress.com/2016/01/02/an-energy-challenge-2016/ #AnEnergyChallenge2016

gordon77
Posts: 4117
Joined: Sun Aug 05, 2012 3:12 pm

Re: Make a buzzing sound

Fri Oct 09, 2015 10:23 am

The maximum is 16mA per pin But with a total not exceeding 51mA for all pins.

ricl
Posts: 657
Joined: Wed Aug 26, 2015 11:55 am

Re: Make a buzzing sound

Fri Oct 09, 2015 12:11 pm

From the link provided
The simplest answer would be 3mA, but a more considered answer might be:-

A maximum of 16mA per pin with the total current from all pins not exceeding 51mA.
ricl : F/gamma = ma : Law ii(a) : https://climatedatablog.wordpress.com/2016/01/02/an-energy-challenge-2016/ #AnEnergyChallenge2016

gordon77
Posts: 4117
Joined: Sun Aug 05, 2012 3:12 pm

Re: Make a buzzing sound

Fri Oct 09, 2015 12:31 pm

To me saying a maximum of 3mA is a confusing answer and doesn't explain the situation.

ricl
Posts: 657
Joined: Wed Aug 26, 2015 11:55 am

Re: Make a buzzing sound

Fri Oct 09, 2015 12:37 pm

Fine

"That's because the GPIO pins only supply 3.3v at a recommended maximum of 3mA per pin (if all pins are used at the same time)"
ricl : F/gamma = ma : Law ii(a) : https://climatedatablog.wordpress.com/2016/01/02/an-energy-challenge-2016/ #AnEnergyChallenge2016

haroldpulcher
Posts: 58
Joined: Tue Jun 09, 2015 8:08 pm
Contact: Website

Re: Make a buzzing sound

Fri Oct 09, 2015 6:52 pm

In general driving a load from a GPIO pin by raising it high is bad practice.

If you want to use the GPIO pin directly without the output buffer mentioned, you should make that sync to ground. This means setting the pin low to turn on the buzzer. The GPIO pin can sync lots of current to ground, where it can only provide very little.

This is the generally accepted practice.

The hardware first guys usually make connections this way. Us software first guys like to assign on == high, and off == low because that is how we generally think about such things.

Notice how the hardware guys do not refer to anything as "on" or "off", but "active low" or "active high". This denotes at which state the device connected will "turn on" for lack a better term.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12125
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Make a buzzing sound

Fri Oct 09, 2015 7:06 pm

haroldpulcher wrote:In general driving a load from a GPIO pin by raising it high is bad practice.

If you want to use the GPIO pin directly without the output buffer mentioned, you should make that sync to ground. This means setting the pin low to turn on the buzzer. The GPIO pin can sync lots of current to ground, where it can only provide very little.

This is the generally accepted practice.

The hardware first guys usually make connections this way. Us software first guys like to assign on == high, and off == low because that is how we generally think about such things.

Notice how the hardware guys do not refer to anything as "on" or "off", but "active low" or "active high". This denotes at which state the device connected will "turn on" for lack a better term.
this may be general practice for most microcontrollers, but IMHO it is NOT valid for the GPIO's of the raspberry PI, which have push-pull drivers that can pull-down as hard as they can push-up, namely to a maximum of 15mA per GPIO pin (both when sinking and when sourcing current).

but yeah, don't try to connect any serious load to a GPIO, its not designed for that, when (for example) you want to sound a buzzer, then use a GPIO to control a transistor, which switches the buzzer on or off.

gordon77
Posts: 4117
Joined: Sun Aug 05, 2012 3:12 pm

Re: Make a buzzing sound

Fri Oct 09, 2015 7:32 pm

ricl wrote:Fine

"That's because the GPIO pins only supply 3.3v at a recommended maximum of 3mA per pin (if all pins are used at the same time)"
Don't forget there are now 26 gpio on the b+ or p2b so that's < 2mA if you want to use them all and quote it that way.

ricl
Posts: 657
Joined: Wed Aug 26, 2015 11:55 am

Re: Make a buzzing sound

Sat Oct 10, 2015 9:02 am

https://ms-iot.github.io/content/en-US/ ... gsRPi2.htm

Actually there are only 12 (not 13, someone can't count/didn't update the text) valid GPIO pins that are available for use in IoT so the exact calculation is 51/12 ~= 4mA and a bit.

The point was, don't just throw things at the Pi. Check what you are doing before hand. Including what the required voltages and currents are for external peripherals.

The 3mA source current for GPIO is a conservative view that is not likely to fail. Above that things may or may not work. All depends on the setup. And if you get it wrong you'll be buying a new Pi.
ricl : F/gamma = ma : Law ii(a) : https://climatedatablog.wordpress.com/2016/01/02/an-energy-challenge-2016/ #AnEnergyChallenge2016

deivid77
Posts: 30
Joined: Wed Jun 24, 2015 6:09 pm
Location: Spain

Re: Make a buzzing sound

Mon Oct 12, 2015 10:38 am

Thank you for your answers.

I'm gonna try this:
https://www.sparkfun.com/products/12009
(SparkFun Logic Level Converter - Bi-Directional)

I think is the better solution for not damaging the plate.

What do you think?

deivid77
Posts: 30
Joined: Wed Jun 24, 2015 6:09 pm
Location: Spain

Re: Make a buzzing sound

Wed Oct 21, 2015 6:51 am

Finally I think it was a problem with the buzzer.

I bought a 6v buzzer and it works perfect!!

Return to “Windows 10 for IoT”