0

I'm using an Arduino Nano and attempting to run the basic sample program at: https://www.arduino.cc/en/Tutorial/toneMelody

When I build the circuit they way they show (extremely simple) using an 8 Ohm speaker and connect the power to USB the Nano begins to power (never fully powers up) and then the USB port fails (I believe as a protection mechanism).

sample fritzing circuit

Is the schematic provided with that sample incorrect?
They say it can be used with an 8 Ohm speaker but they show it hooked up with e piezo.
Here are the comments from the Sketch:

sketch comments

Is it possibly overdrawing current with the 8 Ohm speaker?
Is the circuit incorrect in some way? NOTE: Without the speaker connected the Nano powers up with no problem. I am also building other circuits with the Nano and they work fine.

8
  • 3
    If you have a pure resistive load of an 8 ohm resistor across a 5V voltage source a current of 625 millamps would flow -- USB by standard provides 500mA (superuser.com/a/690077/546860), but since the current is coming out of the digital pin in this case, you will overload your pin which has a max of 40mA (playground.arduino.cc/Main/ArduinoPinCurrentLimitations). I'm also interested in how this is supposed to work (inductive load?). Jun 17, 2018 at 17:04
  • Thanks for you input. Because I was searching around and reading before I tried the simple circuit, I thought maybe it was wrong too.
    – raddevus
    Jun 17, 2018 at 17:06
  • 2
    Try putting a capacitor (maybe 470uOhm) in series with the speaker. This prevents DC voltage to pass through. But also keep in mind, that the pins are not designed to drive a speaker directly. It can work (tried it myself one time), but it is risky. The piezo doesn't let any DC current pass (since it is basically a capacitor with a special dielectric material in it), so it isn't critical.
    – chrisl
    Jun 17, 2018 at 17:19
  • 2
    The circuit depicted is for a piezo and is reasonable for that use. Using it with a low impedance magnetic speaker is incorrect (you'll find this is not the only glaring omissions in Arduino materials). However, that does not explain the USB failure, since the current drawn by shorting an I/O pin does not exceed that limit. Perhaps the speaker was accidentally connected between supply pins, rather than as shown. Jun 17, 2018 at 18:07
  • 2
    someone should write an answer :-)
    – Juraj
    Jun 17, 2018 at 19:41

2 Answers 2

1

As already mentioned in your question, in the Arduino tutorial "Melody" under "Hardware Required" is stated "piezo buzzer or a speaker" and in the comment that heads the sketch is stated: "8 ohm speaker on digital pin 8". But the pictures under "Circuit" and "Schematic" show a piezo sound transducer.

In any case the word "buzzer" is wrong. A buzzer usually has a built-in oscillating circuit or mechanism and, when energized, produces sound at a more or less fixed frequency. Better would have been: a piezo speaker and a 'normal' (moving coil) speaker.

There is a big difference between a piezo and a speaker: under a dc-voltage the piezeo wil have a near infinitive resistance and the 8 Ohm speaker roughly 4 Ohms. At 400 Hz the piezo has an impedance of roughly 2000 Ohm (there is a huge range of piezo's with varying characteristics), while the impedance of the normal speaker will be roughly 10 Ohm.

One side of the buzzer/speaker is connected to Ground, therefore current is only flowing when the side connected to pin 8 is HIGH (pin 8, has to source the current and not to sink it).

The datasheet of the Atmega328P states at page 299 that the absolute maximum ratings (which is not the same as maximum allowable operational ratings) are 40 mA for an I/O-pin is 40.0 mA and 200 mA for Vcc and Ground pins.
The datasheet shows a graph (fig. 35-24 at page 600) showing "I/O Pin Output Voltage vs. Source Current (VCC = 5 V)". From this graph an internal resistance of about 26 Ohm can be derived. The graph does'n show what happens at pin-currents larger than 20 mA, but let's guess the internal resistance stays about the same 26 Ohm.

When pin 8 is constantly HIGH (5 V at 0 Hz) the current through the speaker would be about 5/(26+4) = 167 mA. This is far above the 40 mA maximum rating for the pin current, but not enough to trip the USB-fuse (trips at 500 mA). When this situation lasts the pin-driver will be destroyed. This could cause an internal open circuit (with no further consequences) or an internal short circuit which might cause a supply current higher than 500 mA which would trip the USB-fuse. In this case pin 8 would be permanently destroyed which is easy to establish. If pin 8 keeps working, this scenario doesn't happen.

Normally the sketch "Melody" would not output a dc-signal (0 Hz). At 400 Hz the pin current would be 5/(26+8)= 147 mA. This is still far above the maximum rating for the pin current and the scenario is the same as above.

So the only way the USB-fuse could be tripped is when the pin driver burns out and causes a short-circuit from Vcc to ground. Reading between the lines, my impression is that Raddevus tried this out more than once, which means that pin 8 keeps working. Also I don't think that it is likely that an burn-out of a (few) transistor(s) of an IC causes a short-circuit. Therefore the cause for tripping the USB-fuse must lie elsewhere.

A last consideration is that Raddevus mentions (in his comment of June 18 at 15:34) three input buttons which are not in the 'schematic' shown with his question. He also seems to use a dodgy board ("missed ground hole on bboard, hit 5v"). So may be we don't see all the factors involved.

3
  • This was an older question and I obviously figured out the issue to resolve the problem, however, you explained the difference between the piezo and the speaker and that was something I thought was incorrectly explained in the original Arduino.cc post so I marked this as answer. Thanks.
    – raddevus
    Dec 15, 2018 at 16:26
  • Thanks for marking my answer. But I am still curious: did pin 8 survive and did you find the reason for the USB-port failure?
    – PimV
    Dec 15, 2018 at 22:50
  • Pin 8 did survive. I found an old piezo buzzer on an old motherboard and desoldered it and used it for my tests. I never did try the 8 Ohm speaker. The real problem (as I mentioned) was that I had wired one of my pushbuttons back to 5V instead of GND. However, everything worked (including that mis-connected pushbutton) until I added the piezo buzzer. When I did that I was seeing the Nano get kicked off the USB port (thankfully) so it didn't burn out the Nano or the USB port of my computer.
    – raddevus
    Dec 16, 2018 at 0:36
0

The USB +5v opens to protect your computers from the connected device trying to draw too much current. The pin driver may have burned out, or it may, in fact, have delivered an excessive current (even if not the full 625 mA) but have been saved from failure by the USB supply having opened soon enough.

2
  • 1
    No. The stated circumstances of this question would not draw more current than a USB protection device permits, because I/O pin output drivers are practically rather weak. That would only happen if something about the actual situation were not as stated. Jun 18, 2018 at 4:10
  • @ChrisStratton To close the loop on this-when I went to add the piezo I noticed that one of my input buttons was wired improperly. The input button had 5v incoming and then a line to 100K resistor and out to ground. As I looked closely, I saw that the line from the resistor to ground was actually back to 5v (missed ground hole on bboard, hit 5v). There are 3 input buttons & other 2 were correct. Also this input button still worked though wired improperly. However, when the 8Ohm speaker was added (between pin 8 and ground) only then did I see this odd behavior of USB port fail (protection).
    – raddevus
    Jun 18, 2018 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.