Working out correct calculations for resistance from different data sheets

Hello,

This is a pretty standard question, but I would love to know how others work out the resistance calculations for different sensors/controls/etc from data sheets. I've found data sheets vary quite a lot, providing different types of data - eg. watts + ohms or volts + current. Example below shows 2 different calculations for the same problem, but which one is correct?

Example:

Calculation A: (calculator Ohm's Law Calculators and Formulas from here

  1. calculate speaker current: square root of (power / resistance) = square root of (0.2w / 8ohm) = 0.15811 A
  2. calculate speaker voltage: square root of (power * resistance) = square root of (0.2w * 8ohm) = 1.26491 V
  3. calculate voltage to be absorbed by resistor (KVL): 5V (arduino power) - 1.26491V = 3.73509 V
  4. calculate resistance of resistor (ohms): R = Vr / I = 3.73509 V / 0.15811 A = 23.6233 ohms

So I guess for Calculation A, a 100ohm resistor be ok because it's the closest to the 23.62ohms?

Calculation B:
The max voltage from an output pin (eg, if you were to write HIGH) is 5v. Current output is 40mA. To work out those two values expressed as Watts, you would do this:

  1. calculate arduino watts per pin: (Amps * Volts = Watts) 0.04a (arduino current per pin) * 5V (arduino power) = 0.2 W

For Calculation B, no resistor is required because the speaker is 0.2w and the arduino output per pin is 0.2w?

So which calculations should I use? 'A' seems like a lot of calculations and doesn't take into consideration the 40mA current output from the individual arduino pin. And 'B' is much simpler and easy to understand, but doesn't take into consideration the 8ohms from the speaker.

Thanks,
Trent

Nether calculation is correct, speaker is AC device, but arduino outputs DC only. Use power amplifier, or USB speakers.

I just want to point out that 40 mA is the absolute maximum rating of the pin. I would be calculating on a 20 mA output.

Driving a 8 ohm speaker directly from a output pin will damage the pin. Adding series resistance will protect the output pin but waste audio power leaving little left over for the speaker. So find a higher impedeance speaker or do what most do and add an external audio amp stage.

Lefty

Thanks for the responses, but hardware aside what calculations would you recommend for similar style data sheets? Using amplifiers, usb speakers, or any other different hardware is not relevant for this example.

On the arduino site, the 'Tone' tutorial example (http://arduino.cc/en/Tutorial/Tone) uses a similar setup- ardiuno + 8ohm speaker. They recommend a 100ohm resistor. I just want to know what steps they would have taken to work out the resistance?

Your 'A' calculation is the way you need to be heading. The current rating of the pin isn't what it will output, it's how much current can flow before it is damaged. The current flowing depends on the voltage on the output, and the resistance of the load. It has resistance of it's own which will limit the current it is capable of producing, but in most cases it will try to provide more than it can withstand and ultimately fail.

I disagree with the statement that your math is irrelevant because the Arduino is DC. You can pulse DC to create a square wave at a frequency of your choosing. Frequency implies AC. It is true however that when dealing with AC, you need to speak in terms of impedance rather than resistance, since no speaker has flat impedance from DC to kHz and beyond. Therefore the current it uses depends on the frequency of the signal. On the flip side, most devices don't instantaneously die when their current threshold is tripped. Too much current is usually a problem because of heat, which builds up over time, eventually causing damage.

Way more than you wanted to know I'm sure, but to say electronics is easy would be a disservice.