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

Re: Lighting An LED

Sun Jan 10, 2016 9:02 pm

emma1997 wrote:
gordon77 wrote:I used pin 40, just used a python program to set GPIO high.

Can you link to spec of led used?
No spec for generic red LED. I see very little variation in Vf for the many different types I have in the junk box. The only other variable I can think of is software. As mentioned I didn't use any special program. If possible would you post your Python code here.
Nothing special...

import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode (GPIO.BOARD)
GPIO.setup(40, GPIO.OUT)
GPIO.output(40, GPIO.HIGH)

emma1997
Posts: 325
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not the old one)

Re: Lighting An LED

Sun Jan 10, 2016 9:08 pm

gregeric wrote:I never understood where that 50mA figure came from - the 3V3 linear regulator on the Pi 1 (NCP1117) was a 1A rated part
That 50ma has nothing to do with regulators, it is supposed to be total package limit for I/O load. Possible but a very poor spec if true. Other chips like AVR with similar die size have many times higher limit. Because of comments made in that old thread I have little faith in what alleged chip designer says and conflicts with empirical data from myself and others. For example that link that you posted there:

http://tansi.info/rp/interfacing5v.html

We all agree LED w/o resistor does not make sense but not for the same reasons. In my case it's because modern 0603 parts, even with few ma, are so efficient brightness pretty much makes it impossible to see anything else on the board.

emma1997
Posts: 325
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not the old one)

Re: Lighting An LED

Sun Jan 10, 2016 9:15 pm

gordon77 wrote: import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode (GPIO.BOARD)
GPIO.setup(40, GPIO.OUT)
GPIO.output(40, GPIO.HIGH)
Thanks. I'll give that a try when back at the lab.

Heater
Posts: 13885
Joined: Tue Jul 17, 2012 3:02 pm

Re: Lighting An LED

Sun Jan 10, 2016 10:01 pm

emma1997,
Possible but a very poor spec if true.
How so? The Pi SoC is not a micro-controller. It was designed for use in phones and such. There was no requirement for delivering tons of current out of it's GPIO.

AVR and such are designed with very different goals in mind.

This is a wild guess on my part but the AVR may have a similar die size but perhaps the process technology it is built from is much bigger than that of the Pi SoC. That in turn may make it easier to provide higher current drive.

Now, you could argue that if the drive capability of the Pi SoC is "very poor" then it was the wrong device to use in the Pi.

I don't want to make that argument. Millions of Pi users are happy with this limitation. They just use current limiting resistors on their LEDs and perhaps driver transistors if need be. As one should :)
Memory in C++ is a leaky abstraction .

emma1997
Posts: 325
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not the old one)

Re: Lighting An LED

Sun Jan 10, 2016 10:34 pm

Heater wrote:The Pi SoC is not a micro-controller. It was designed for use in phones and such. There was no requirement for delivering tons of current out of it's GPIO.
That's probably true and must admit I have been spoiled by other ARM chips like STM32 and similarity at PCB level with Arduino. It just strikes me strange that die components have extreme per pin drive yet warn chip will self destruct when taken advantage of. And odd that the 50ma IC package limit is less than what a single pin can draw.

I can't really complain too much though because for what they do and what they cost (specially Zero) quite an amazing device.

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Lighting An LED

Sun Jan 10, 2016 10:42 pm

emma1997 wrote: That 50ma has nothing to do with regulators, it is supposed to be total package limit for I/O load. Possible but a very poor spec if true. Other chips like AVR with similar die size have many times higher limit.
Not that much higher:
AVR Mega162 Datasheet wrote: Although each I/O port can source more than the test conditions (20 mA at Vcc = 5V, 10 mA at Vcc = 3V) under steady state conditions (non-transient), the following must be observed:
PDIP Package:
1] The sum of all IOH, for all ports, should not exceed 200 mA.
2] The sum of all IOH, for port B0 - B7, D0 - D7, and XTAL2, should not exceed 100 mA.
3] The sum of all IOH, for ports A0 - A7, E0 - E2, C0 - C7, should not exceed 100 mA.
TQFP and MLF Package:
1] The sum of all IOH, for all ports, should not exceed 400 mA.
2] The sum of all IOH, for ports B0 - B7, D0 - D7, and XTAL2, should not exceed 200 mA.
3] The sum of all IOH, for ports C0 - C7 and E1 - E2, should not exceed 200 mA.
4] The sum of all IOH, for ports A0 - A7 and E0, should not exceed 200 mA.
Remember the AVR chips are designed to drive loads. The BCM ones are designed to drive logic. The largest load on a phone might be the power LED, and maybe not even that without a driver. In fact that 10mA at Vcc=3V is less than the 16mA we have available.

emma1997
Posts: 325
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not the old one)

Re: Lighting An LED

Mon Jan 11, 2016 12:14 am

"many times higher limit." vs "Not that much higher"? 50ma vs 200ma. Guess higher is in the eye of the beholder. Do the maths :) .

However it is unfair to compare those two families. AVR might have an edge in dissipation but not even close in terms of computing power, graphics, and OS support. Not even mentioning HDMI and USB.

Heater
Posts: 13885
Joined: Tue Jul 17, 2012 3:02 pm

Re: Lighting An LED

Mon Jan 11, 2016 12:40 am

OK. I did the maths.

200ma is less than ten times 50ma.

They are the same order of magnitude.

Where I come from they might as well be the same.

:)
Memory in C++ is a leaky abstraction .

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: Lighting An LED

Mon Jan 11, 2016 5:53 am

Heater wrote:
emma1997 wrote:BTW Ohms law does apply to LEDs and any other device that draws power be it linear or not.
I admire your tenacity for correctness. If only you were correct. The common or garden Ohms Law, as most people know it, states that I = V / R. This is clearly not applicable to a LED for which no "R" is specified in the data sheet. With good reason. But then, I have in front of me a circuit that generates a random current for some applied voltage. I have another for which the current goes down with increasing voltage. A negative resistance! Please explain how Ohm's Law works in these cases. The generalized Ohms Law used in plasma physics is something else again.
Heater - you and Emma have been talking past each other about R = V / I, which is Ohm's Law (i.e., resistance is a property that must be calculated from measurements). You're assuming a linear device where the resistance is constant and positive over the entire range of voltages or currents applied, but this isn't even valid for resistors if they change temperature enough (up due to internal or external heating, or down if externally cooled). What Ohm's Law really states is that the resistance is the ratio of the voltage divided by the current _for_a_specific_voltage_or_current_applied_and_measured. In other words, it's the slope of the resistance _function_ (which may or may _not_ be linear) for the particular voltage and current applied and measured. So, resistance _can_ vary over the range of voltage or current applied, which Heater observed in the negative resistance example. For those not aware, a common example is a fluorescent light source - the current decreases with increasing voltage over part of its operating range, hence a negative slope, or resistance, over that range.

Another poster mentioned the "i" word, impedance, which should not be confused with resistance that is only one component of impedance, with the others being capacitance, inductance, and further ugliness we won't get into here, given the difficulty that R = V / I has generated. Let's just say that time and the square root of negative one are involved and leave it at that! ;) My mind was completely blown when I absorbed that the slope value is the same as the function value for the natural logarithm f(x) = ln(x) (as are all of its derivatives and integrals), and that the additive and multiplicative identities, associative and commutative properties, among other mathematical relationships, are merely assumptions. They just happen to reflect what we perceive to be the real world at our unaided sensory level of detail, but they don't _have_ to, which comes in handy for bizarre stuff like quantum physics.

Don't feel bad, I didn't "get it" right away about Ohm's Law either, but I had really good professors who taught me to think so far outside the box that I need the Hubble Space Telescope to even _see_ the box looking back toward it! Among them was Dick Hamming - yes, of Hamming Codes, protege of the Father of Information Theory (Claude Shannon), and Bell Labs fame, who made the analog long-distance phone systems possible by developing the mathematics required for quantifying signal vs. noise. That's why some of my posts seem like wild and crazy emanations from deep space, but I hope this doesn't seem like one of them.
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

Heater
Posts: 13885
Joined: Tue Jul 17, 2012 3:02 pm

Re: Lighting An LED

Mon Jan 11, 2016 7:49 am

Jim,

This long winded and pointless debate is not about Ohm's Law. It all started with my observation about a video for beginners to using and Pi and LEDs. Namely:
"Did I just watch a video of someone lighting a LED from a Pi pin with no current limiting resistor?"
My stance is that showing people, who don't know any better, how to light up a LED without a current limiting resistor is a bad idea. For many and obvious reasons that I will not repeat here.

Emma's stance is, meh, it's OK. It works. Due to the characteristics of the LED and the Pi GPIO nothing bad happens. (Hope I expressed that correctly Emma.)

(Note: the video in question does not use a GPIO but the 3.3v supply directly)

As usual you have stepped into a thread to bluster about your supposedly superior education whilst adding adding useful.

So Jim, as someone who does such educational activities with kids, which side of the debate are you on? Would you instruct them just to jam a naked LED across a power supply. Would you start them off with a conversation about how LEDs work and why limiting current is a good idea? Would you perhaps skip the resistor but warn them this is in general not a good idea?

Me, I'd start them off with a demonstration of how nicely a red LED explodes when driven from a few volts with no current limiting. A nice way to make a lesson stick in the mind :)
Memory in C++ is a leaky abstraction .

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Lighting An LED

Mon Jan 11, 2016 8:21 am

Jim Manley wrote:In other words, it's the slope of the resistance _function_ (which may or may _not_ be linear) for the particular voltage and current applied and measured.
Not actually true. I was considering this the other day.
As commonly calculated: R = V/I, the resistance we calculate is the slope of a straight line that intersects both the origin and the operational point. It is not the slope of the V,I function at that point which is dV/dI -- an entirely different figure for anything other than a simple resistor.

Your fluorescent light probably does not have a negative resistance at any point in its operation. V/I > 0.
However over part of its operation, dV/dI < 0.

For those without A-level maths, "d" can be read as "a small change in".
resistance.jpg
resistance.jpg (8.78 KiB) Viewed 2134 times

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Lighting An LED

Mon Jan 11, 2016 10:51 am

emma1997 wrote:Alexandra seems to be the quintessential Pi-moron-i think. I laughed so hard almost fell off my chair. IMO that short was best work of art since "Look Around You" series (IMO greatest UK production EVER).

Unless RPF scrambled RPi pins recently her negative was actually positive and versa visa. The only reason that LED lit at all was because she plugged it in backwards, calling the short lead "positive". A case where two (or more) wrongs do make a right. I knew we were in for a treat starting out with that claim "Raspberry Pi only emits 5 volts" and that hooking up a "higher voltage LED will fry it". LOL

Most amusing of all is the air of conviction and expertise she "emits". Not that unusual considering this seems to be the norm on internet, specially some forums. The real problem is noobs can't tell the difference between jokers like her and those with real knowledge and experience. Tendency is to follow lock step with the ones they like rather than those who know.
I thought it was an amazing video, I was wincing as the male connectors from her dupont wires floated around the (running) pi, making contact with parts of the board without her noticing. Then later she "unplugged the pi" to make connecting the LED safe by disconnecting the two male dupont wires from the breadboard and letting them drift wherever they wanted.

Also note that in the (almost) two years since Alexandria posted that video she hasn't made a follow up video regarding the Raspberry Pi, perhaps she destroyed the Pi while making the 2nd video?

Just re-watched the video, note at 1:12 the Pi shuts down when she shorts the 3V3 to the ethernet housing.
Doug.
Building Management Systems Engineer.

Heater
Posts: 13885
Joined: Tue Jul 17, 2012 3:02 pm

Re: Lighting An LED

Mon Jan 11, 2016 11:11 am

Would the real Ohm's Law please stand up?

There are so many to choose from. It's all a matter of context and application.

At the risk of boring all those who know all tis stuff:

The Ohms Law we all know and love, I = V / R, is all about a ideal resistor. It has the same resistance no matter what I and V are. It's resistance does not change with frequency or temperature or or time or anything else. It never blows up!

That perfect R is a non-existent component. A model we use to make it easy to reason about circuits. We also have perfect C's and perfect L's and so on. Not to mention perfect wires, switches, voltage sources, current sources etc. This all the basis of the "Lumped element model" we use to analyse circuits. https://en.wikipedia.org/wiki/Lumped_element_model.

Things get tricky when we talk about alternating current circuits. Now a C or L has a "resistance" to the flow of current. But that "resistance" is now changing with the frequency we are using. It also messes with how the current and voltage are related at any instant, they need not be in phase any more. At this point we stop calling it "resistance", we call it "impedance" with the symbol Z. This has a lot of interesting maths using complex numbers which we won't even start to look into here.

But we can still use Ohms Law in AC circuits, just use that weird Z thing instead of R, I = V / Z. Sneaky ha?
http://hyperphysics.phy-astr.gsu.edu/hb ... cohml.html

What about that pesky negative resistance? It is certainly the case that you can build active circuits for which current goes down as voltage goes up. This also happens in gas discharge tubes and so on.

No problem. We had R = V / I. Well looking at the units of measurement here we can say that the unit of resistance is "volts per amp". So what if, instead of taking the actual voltages and currents as measured from zero we just change the voltage by a little bit and see how the current changes. Now we have a change in voltage dV = (V2 - V1) and a resulting change in current dI = (I2 - I1). We can use that little "d" to indicate difference.

Notice that the units of measurement of dI is amps and dV is volts. So if we write

X = dV / dI

We see that our mystery X has units of "volts per amp"

But hey, that's the same as the R in our old Ohms Law. X is a kind of R. And it can be negative! Oh my God.

How does current and resistance change in a plasma? In a plasma you have a soup of electrons and ions flying around not bound to each other as in normal materials. No worries there is an Ohms Law for that as well. The Generalized Ohms Law. See section 3.1 here: http://people.duke.edu/~ad159/files/p142/12.pdf if you are brave :)
Memory in C++ is a leaky abstraction .

User avatar
jojopi
Posts: 3085
Joined: Tue Oct 11, 2011 8:38 pm

Re: Lighting An LED

Wed Jan 13, 2016 4:19 pm

Jim Manley wrote:My mind was completely blown when I absorbed that the slope value is the same as the function value for the natural logarithm f(x) = ln(x) (as are all of its derivatives and integrals),
The derivative of ln(x) is 1/x, and its integral is x ln(x) - x + c.

It is the inverse function, exp(x), whose slope is equal to its value.

Heater
Posts: 13885
Joined: Tue Jul 17, 2012 3:02 pm

Re: Lighting An LED

Wed Jan 13, 2016 4:29 pm

That why he said his mind is blown. He got it totally wrong. :)
Memory in C++ is a leaky abstraction .

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Lighting An LED

Wed Jan 13, 2016 4:44 pm

My mind was blown when I heard you can take all three mysterious numbers in maths and do this:

e ^ (i * pi) + 1 = 0

Heater
Posts: 13885
Joined: Tue Jul 17, 2012 3:02 pm

Re: Lighting An LED

Wed Jan 13, 2016 4:52 pm

My mind was blown when I was shown how:

1 + 2 + 4 + 5 + .... = -1/12
Memory in C++ is a leaky abstraction .

User avatar
Burngate
Posts: 6094
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Lighting An LED

Wed Jan 13, 2016 5:55 pm

Heater wrote:1 + 2 + 4 + 5 + .... = -1/12
Where does that come from? What's the series creating the left hand side?

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Lighting An LED

Wed Jan 13, 2016 6:01 pm

wow

@Burngate, it is what you think it is: https://en.wikipedia.org/wiki/1_%2B_2_% ... _%E2%8B%AF

Re-edit: From the smoothed graph it seems it is the sum of the series for n=0. Interesting but not Earth-shattering. It would explain why adding a zero at the beginning makes such a difference. But I have nowhere near enough maths to truely understand it.

User avatar
rpdom
Posts: 15580
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Lighting An LED

Wed Jan 13, 2016 6:07 pm

rurwin wrote:wow

@Burngate, it is what you think it is: https://en.wikipedia.org/wiki/1_%2B_2_% ... _%E2%8B%AF
Where's the 3 come from?

Oskar
Posts: 13
Joined: Sun Feb 26, 2012 12:05 am

Re: Lighting An LED

Wed Jan 13, 2016 6:26 pm

Once upon a time there was a lovely little thread where a beginner asked for help. Everyone was pleasant and supportive, and no one called anyone else names or had snide little digs. People thanked each other for the help and it all worked out splendidly.

The end.

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

Re: Lighting An LED

Wed Jan 13, 2016 6:51 pm

Oskar wrote:Once upon a time there was a lovely little thread where a beginner asked for help. Everyone was pleasant and supportive, and no one called anyone else names or had snide little digs. People thanked each other for the help and it all worked out splendidly.

The end.
Ah, the good old days :)

Heater
Posts: 13885
Joined: Tue Jul 17, 2012 3:02 pm

Re: Lighting An LED

Wed Jan 13, 2016 7:54 pm

Oskar,

Once upon a time a beginner came to the internet and asked for help.

Many eagerly answered. Some correctly. Some incorrectly.

A massive mud slinging match ensued.

The beginner was totally confused.

They all lived happily ever after.

:)
Memory in C++ is a leaky abstraction .

User avatar
liz
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 5202
Joined: Thu Jul 28, 2011 7:22 pm
Contact: Website

Re: Lighting An LED

Wed Jan 13, 2016 11:36 pm

On that note, I'm closing that thread. Emma and Heater in particular: if something bugs you, can you please try to get aggravated about it in private rather than sharing your ire? It's particularly unhelpful when beginners read this stuff; they can come away with the (occasionally accurate, and I wish forum members wouldn't do this) impression that if they display any holes in their knowledge they'll be mocked. It's really not what this forum is supposed to be about.

PLEASE cool it.
Director of Communications, Raspberry Pi

Return to “General discussion”