buying advice shift registers

thank you! I might have to rethink my concept then. It's supposed to be some kind
of a wrist watch ;D .

best
yves

thank you! I might have to rethink my concept then. It's supposed to be some kind
of a wrist watch ;D .

In the pre-LCD days, there were LED wrist watches. The way they solved this is that they were off all the time. There was a button to make the display come on for a few seconds. There were also more advanced versions that had motion switches so you could swing your arm a certain way to get the display to come on.

sounds good, I'll look into that! :wink:

http://www.dipmicro.com/store/index.php?act=viewCat&catId=28

For cheap items, including Leds and a lot of other cool stuff.
It's especially good if you live near/in Canada.

I unfortunately live in europe, switzerland. any good advice for that region?

Hi,
if you have problems finding a local shop here are 2 german distributors :

Segor : http://www.segor.de/ Actually the distributor for the Arduino over here, and all sorts of electronic components.

Reichelt : http://www.reichelt.de/ In germany its probably the cheapest online shop for electronic components. (But check with Segor on individual items.)

Eberhard

I live in switzerland, any good advice for that region?

Travel to Zermatt and do the hohbalmen hohenweg :slight_smile:

But for parts, have a look on ebay, particularly if you want to buy in quantity and don't mind waiting a week or so for items to be shipped from china.

You could also try dealextreme, they have a eclectic range of LEDs, such as:

20 packs of red, green or orange for $2.35 each including shipping
http://www.dealextreme.com/details.dx/sku.11099
http://www.dealextreme.com/details.dx/sku.11100
http://www.dealextreme.com/details.dx/sku.11101

or this 60 lumen! white emitter for $2.75 including shipping.
http://www.dealextreme.com/details.dx/sku.13286

hi

thank you for these suggestions. I have two shops in switzerland but they
are not very cheap and lack certain items.

what kind of resistors do I need? I thought the ones I got with my
arduino kit are coal resistors. but the shop I have here lists them starting
at 1W. But I would need one at around 0.33W.

now they have also metal oxyde resistors, but they seem to be much more
expensive. is that possible, or could it be an errpr in the shop system (they
list the price per 1 resistor, where the coal ones are listed as per 100 items).

for the german speaking readers, this is the shop I'm talkin about, maybe you
can help:

https://www.distrelec.ch:443/ishopWebFront/catalog/node.do/para/language/is/de/and/shop/is/CH/and/id/is/01/and/node/is/acababafac.html

thanks so much for your help!

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?

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

=> 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

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=UI=1.5V0,02A=0,03W

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

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

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

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.

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... :o

best
yves

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

ok, I've bought the components and everything works as expected. yay! :smiley:
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! :sunglasses:

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?

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 = a2^7 + b2^6 + c2^5 + d2^4 + e2^3 + f2^2 + g2^1 + h2^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 + 210 ^2 + 310^1 + 410^0
= 1
1000 + 2100 + 310 + 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

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

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.