Go Down

#### mem

#15
##### Jun 04, 2008, 09:58 am
Metal oxide resistors have better temperature stability and can be more reliable in the long term compared to carbon, but that probably doesn't matter in your application. I am not sure how much current you want to put through your leds but the .25 watt 5% carbons on that site should be ok for 50ma to 100ma depending on the LED voltage drop

How did you arrive at the .33 watt figure?

#### yves

#16
##### Jun 04, 2008, 10:06 am
I used the following formula to calculate the ohms:

Basically though, if you want 20mA, the resistor should be ([supply voltage] - [led voltage]) / 0.02.  Or 50*(supply voltage - led voltage).

So I calculated: 5V - 3.5 (led voltage) / 0.02 = 75 ohms

=> P = V^2/R with this formula I get around 0.33 watts?
Is this not correct?

About the 0.25w items on that site: what I don't understand is why there are several items available
starting from 1 W upwards. Is not this one the actual resistance value?

best
yves

#### bens

#17
##### Jun 04, 2008, 10:26 amLast Edit: Jun 04, 2008, 10:27 am by bens Reason: 1
Quote
=> P = V^2/R with this formula I get around 0.33 watts?
Is this not correct?

The power dissipated by the resistor is the voltage drop across the resistor squared divided by the resistance = 1.5^2 / 75 = 0.03 (or you can compute P = IV = 0.02 A * 1.5 V).  The rest of the power is dissipated by the LED, mostly in the form of light.  This power is computed by P = IV = 0.02 A * 3.5 V = 0.07 W, for a total resistor-LED power dissipation of 0.1 W.

- Ben

#### wayoda

#18
##### Jun 04, 2008, 10:27 amLast Edit: Jun 04, 2008, 10:29 am by wayoda Reason: 1
Quote
I used the following formula to calculate the ohms:

Basically though, if you want 20mA, the resistor should be ([supply voltage] - [led voltage]) / 0.02.  Or 50*(supply voltage - led voltage).

So I calculated: 5V - 3.5 (led voltage) / 0.02 = 75 ohms

=> P = V^2/R with this formula I get around 0.33 watts?
Is this not correct?

The formula is correct. Though, since you know both the voltage and the current through the resistor its easier to use
P=U*I=1.5V*0,02A=0,03W

But as you can see you got the actual calculation wrong. It's 0,03W not 0,3W.

Quote

About the 0.25w items on that site: what I don't understand is why there are several items available
starting from 1 W upwards. Is not this one the actual resistance value?

best
yves

Since all the values given in the table are typical resistor values they got an error in their database. The values should read 1Ohm, 27kOhm, 560kOhm etc.

But I'm not sure about the prices, looks like you have to order a minimum of 1000 Resistors per value? (that would almost match the prices in Germany 5? if you order >=1000)

Eberhard

#### bens

#19
##### Jun 04, 2008, 10:29 am
Quote
So I calculated: 5V - 3.5 (led voltage) / 0.02 = 75 ohms

I believe the mistake he was making was to use the full 5 V in the power calculation rather than the voltage drop across the resistor.  This leads to:

P = V^2 / R = 25 / 75 = 0.3333

- Ben

#### mem

#20
##### Jun 04, 2008, 10:40 amLast Edit: Jun 04, 2008, 10:40 am by mem Reason: 1
the 82 ohm ¼ watt carbon resistor is item number 700012 on the site you linked. I was able to put 1 pack of ten resistors in my basket at a price of  0.6chf. for the ten. Not sure if there is a minimum order value or what the shipping cost is.

#### yves

#21
##### Jun 04, 2008, 10:42 amLast Edit: Jun 04, 2008, 10:44 am by yves Reason: 1
Quote

Since all the values given in the table are typical resistor values they got an error in their database. The values should read 1Ohm, 27kOhm, 560kOhm etc.

But I'm not sure about the prices, looks like you have to order a minimum of 1000 Resistors per value? (that would almost match the prices in Germany 5? if you order >=1000)

Eberhard

so you mean that these figures are ohms, not watts (like stated on the page)?
this would mean I could order for example #700012 which would be 82 ohms.
or is it better to go with the standard 220 ohms?

thank you all for your detail explanations. I'm a little confused as you may see...

best
yves

update: thank you mem, you just answered what I was guessing

#### yves

#22
##### Jun 08, 2008, 12:07 pmLast Edit: Jun 08, 2008, 12:13 pm by yves Reason: 1
ok, I've bought the components and everything works as expected. yay!
now on to some questions... I'm going trhough the shift register tutorial and
it's running allright (with 8 leds at the moment). I'm drawing the plans at the
moment for a prototype, next week I can lasercut the enclosure.

until then I have some questions about binary math... I was never good
at it at school, but now I seem to need it. I was just looking at the code
example, where there is the line:

shiftOut(dataPin, clockPin, 255);

which lights all eight LEDs.
Am I right that 255 is all eight binary values (0-7) converted to decimal again?

so it's:
000+001+010+011+100+101+110+111

unfortunately I'm unsure how to add these digits together... I looked
at the wikipedia tutorial, but I'm still unsure... Can anyone help?

thanks for all your help! next week there will be pictures!  8-)

update: haha, just found out it's alot easier... 255 is 11111111 so I guess
each bit represents the pin on the shift register. so if I would like to only light up
the first led, it would be 1000000, or 64, correct?

#### bens

#23
##### Jun 08, 2008, 12:20 pm
Quote
Am I right that 255 is all eight binary values (0-7) converted to decimal again?

No, 255 is all eight bits of a byte set to 1:

255 == 0b11111111

If you have a binary number abcdefgh, where a-h are all either 0 or 1, you can convert this to a decimal value using the following:

value = a*2^7 + b*2^6 + c*2^5 + d*2^4 + e*2^3 + f*2^2 + g*2^1 + h*2^0
= 128a + 64b + 32c + 16d + 8e + 4f + 2g + h

Note that you can perform this exact same calculation in a base-10 system (there's nothing special about base-2).  For example:

1234 = 1 * 10^3 + 2*10 ^2 + 3*10^1 + 4*10^0
= 1*1000 + 2*100 + 3*10 + 4

For a general base b, your numerical value is:

sum from i = 0 to n-1 of (digit i * base ^ i)

where you have n base-b digits in your number.

Does this make sense?

- Ben

#### yves

#24
##### Jun 08, 2008, 12:25 pm
hi ben

thanks alot, this starting to make sense to me...
I'm just looking at the example with two shift registers, that's an code fragment:

void blinkAll_2Bytes(int n, int d) {
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, 0);
shiftOut(dataPin, clockPin, 0);
digitalWrite(latchPin, 1);
delay(200);
for (int x = 0; x < n; x++) {
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, 255);
shiftOut(dataPin, clockPin, 255);

digitalWrite(latchPin, 1);
delay(d);
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, 0);
shiftOut(dataPin, clockPin, 0);

digitalWrite(latchPin, 1);
delay(d);
}

Am I correct that shifting out has to be done twice because
there are two shift registers?

On another note, I'll be using 48 leds with 6 shift registers.
can the arduino power that much leds? If not, would it be possible
to light one at a time in such a high frequency that it looks like
they are all on?

sorry for all those questions...

best
yves

#### Oracle

#25
##### Jun 08, 2008, 06:29 pm
Quote

Am I correct that shifting out has to be done twice because
there are two shift registers?

On another note, I'll be using 48 leds with 6 shift registers.
can the arduino power that much leds? If not, would it be possible
to light one at a time in such a high frequency that it looks like
they are all on?

Yes, this is shifting out 2 bytes each time to fill all 16 LEDs.  I think if it were only one shiftout in each place, you'd have the first 8 turn on, then the second 8 turn on while the first 8 turn off, going back and forth.

The Arduino off USB can provide 0.5 amps, so at 10mA each, it should be able to hand the 48 LEDs.

Normally it's possible to light one (or more likely several) at a time at a high frequency so it looks like they're all on.  But with shift registers, it gets a lot more complicated to do that.

Go Up