
robotmaker
USA
Asked
— Edited
SHOULD always use a current resistor inline with led ,so you dont damage the ezb digital pin or burn out the diode
Here is a link for reasons why and formula to work out the resistor value.
driving a led from a digital output
GREAT Job RobotMaker !
I like the Idea of Showing the EZ-B Digital Output BOTH Sinking and Sourcing the Current !
In your example, P0 is SINKING the Current, and P1 is SOURCING the Current.
Therefore, P0 has approximately a 1-Volt Advantage over P1.
Chances are that the EZ-B has the HexFet Equivalent of a Totem Pole Output.
The Final Choice would be to find out Which FET has the Highest or Safest Current Limits ?
Best Wishes,
DougPope@cox.net, 602-246-1246(H)
Users: Please ignore RobotMaker's post. There is no point to use a resistor for LED on EZ-B.
Further reading visit our hardware tutorial: http://www.ez-robot.com/Tutorials/Hardware.aspx?id=7
DO you meen from a microprocessor or fet driving circuit?
If microprocessor is depends on the type ,its in the data sheet of that microprocessor for max sink current and max source current
DJ is right look at the led tutorial and see that its built in,not like other boards like arduino and other microprocessoor board that need it.
As usual, I have got a lot of Homework and Catching Up to Do; The Joys of being age 68.
NEXT time will look at the hardware manual first and if i can find the answer will post it,nobody is perfect.
From the Microchip 18F4684 datasheet (document DS39761C, page 134):
" Each of the PORTB pins has a weak internal pull-up. A
single control bit can turn on all the pull-ups. This is
performed by clearing bit RBPU (INTCON2<7>). The
weak pull-up is automatically turned off when the port
pin is configured as an output. The pull-ups are
disabled on all device Resets."
The reason that you can drive an led directly from the port pins is that they are internally limited to sourcing or sinking a maximum of 25 ma. However, you have no control over the brightness since every led will get this 25 ma. Another disadvantage is that driving 8 leds at 25ma makes a total of 200ma which is the aggregate current limit for all of the port pins. If you use resistors you can match the brightness of different types and colours of leds and reduce the current so that you can use all of the port pins. For some ir leds used in sensors and many high efficiency leds 10ma is sufficient.
There is also a more general concern about a lack of resistors. When port pins are connected to a cable, there can be voltage spikes from noise pickup and static electricity. If the port pin is connected directly to the wire it may be damaged. A 100 ohm res. between the port and the wire will give some protection (both outputs and inputs).
Finally, being able to drive an led directly is valuable if you are designing a commercial product for a very competitive market because it saves parts and board space. For most diy designs these are not issues so I always use transistors to drive leds and relays. You have a more robust design, the microcontroller will be isolated from the dangerous real world and there will be less heat generated in the microcontroller.
To make it easier on everyone - there still is no need for a resistor on your LED because it won't do any damage
When i get home late tonight going to make a quick test using a inline current meter with the led to EZB to find out how much it really draws.
One thing I have learned about Microchip is that you need to read at least 3 different data sheets; 1 on hardware design, one on software design and another on the family the part belongs to. Each document will have a couple of critical points that the other two don't mention.
I don't need an award. SEND MONEY!, but seriously, I am happy to help out.
Troy - I don't want to confuse the issue because DJ is correct in saying that you can run the led directly and not damage the part. What I am trying to say is that there are some applications where using a resistor is beneficial in several ways. Since resistors are cheap and have virtually zero negative impact, why not use them all the time? It always comes down to the application.
For example, if the led is connected as in the tutorial and there is a 1 kohm pullup resistor on the pin, the led will be on when the port output is high. If the port was not connected, the 1 kohm res. would limit the current through the led to 3.8 ma since the led anode will be at 2 diode drops above ground potential. However, with the port connected it tries to drive the line to 4V which means its output will hit the 25 ma limit. To turn off the led the port pin goes low and steals the current being supplied to the led by the pullup. A low on the port pin will be 0.4V which means the port will be sinking 4 ma from the pullup to keep the led off. If your robot is powered by a 12V lead acid battery, this isn't a big concern. However, if you are using a couple of AAs and you have 8 leds your batteries will be dead in a few days just from sitting. Instead, keep the led connected to the pullup resistor but connect the cathode to the port pin. Now, the port sinks the 3.8 ma through the pullup when the led is on but when the led is off the port pin is high and zero current flows. This also results in less heat being generated in the microcontroller. My current project requires 2 gear motors and controller electronics with battery inside an 16 cu. in. waterproof shell with a total weight of less than 5 oz. For me, saving 4 ma is a big deal.
If you want to go even farther, consider that sinking 4 ma through a port pin will generate slightly less heat than sourcing 4 ma. I leave the proof of this as an exercise for the reader. It is very useful in combatting insomnia.
Although our new web hire is pretty awesome and he's implementing a neat new community feature soon. When people ask questions, those who answer the question and help the OP out get EZ-Bucks! That's credits to be spent in our store. So the more helpful you are (i.e. rich and dave and others) will have credits to buy more things.
Also, those "things" are changing