Re: Calculating resistors required

From: Anthony Fremont (spam_at_anywhere.com)
Date: 12/31/04


Date: Fri, 31 Dec 2004 18:36:29 GMT

Danny T wrote:
> Anthony Fremont wrote:
>> Or, as you should probably do, you could use a linear voltage
>> regulator with a low dropout.
>
> Excellent. I'm just looking @ Rapid Electronics, and they seem to be
> available in lots of different packages! Some look like ICs, and some
> have 3 legs. How do I figure out what I need?
>
>
http://www.rapidelectronics.co.uk/rkmain.asp?PAGEID=20671&CTL_CAT_CODE=30416

That's determined by how much current you need to draw, how much power
the regulator is going to have to dissipate (as heat) dropping the
voltage to the output level and how much margin the regulator has to
work with (i.e. how much greater the input voltage is than the output
voltage). The LM2940CT looks pretty good for you for all around
experimentation if you want to supply allot of current, but the LP2950CZ
should work ok in your circuit (as long as it is not trying to drive the
motors too). It is limited to 160mA output.

>> You *will* want to use resistors to limit the current thru your LEDs,
>> otherwise the PIC will attempt to supply a very large amount of
>> current to the LED. This is likely to result in damage to the LED
>> and/or the PIC output pin circuitry. (you can kill a PIC one pin at
>> a time) LEDs (like most diodes) are not voltage controled devices,
>> they need current limiting or they will burn out.
>
> Righto. I've seen a formular for figuring out what resistors I need
> for LEDs as:
>
> 1000 * (supply.voltage - voltage.needed) / current
>
> Does this look right? And is this for LEDs only, or can it be used for
> other things too?

It's just a variation of Ohms law with the 1000 multiplier allowing you
to specify current in milliamps instead of amps. For example, if you
are using a diode with a 1.7Vf (forward voltage drop), and you wished to
run it from a 5V supply, you will need to drop 3.3V thru the resistor.
If you want 20mA of current then ((5-1.7)/20)*1000 = 165 Ohms.

>> The goal is to never have an input pin in a "floating" state. They
>> are suggesting that you use a pull-up resistor on the pin so that
>> when the switch isn't closed(pressed), the input pin sees a logic 1
>> (+5V) via the juice feeding thru the pull-up. Then you have the
>> switch so that it shorts the pin directly to ground when pressed.
>> The pull-up resistor will limit how much current is flowing to
>> ground, and the input pin will "see" a logic 0. This way, the input
>> pin is always connected to a voltage reference of 5V or 0V.
>
> My only question here, is that a switch would then give logic 0. I
> thought it would be reversed, and a 1 would mean the switch is
> pressed. Is that the usual way of doing things?

It can be done the other way around if you like.

>> You would want to use a transistor for this. For highish currents
>> (like motors), I suggest looking into the wonderful and inexpensive
>> logic-level n-channel MOSFETs. These are used allot like generic NPN
>> transistors, but have extremely low "on resistance" (milliohms
>> usually). The logic-level part means that you can connect the gate
>> (base equiv) directly to the PIC output pin and you don't even need
>> a current limiting resistor going into it since the MOSFETs gate
>> input impedance is really high. You connect the source pin (emitter
>> equiv) directly to ground. You stick your load (motor, lights,
>> electric-chair or whatever ;-) between the drain pin (collector
>> equiv) and your +6V supply. When the gate is high (+5V) the motor
>> will run at full speed, when it's low (0V) it will be turned fully
>> off.
>
> Right - getting somewhere now! :)
>
> So, for a circuit with two switches, one driving an LED and one
> driving a motor, would this be correct? (I know the PIC is redundant,
> since the inputs directly drive the outputs, but this wouldn't always
> be the case!)
>
> Excuse the bad ascii, I've never used that program before!
>
> VCC
> +
> |
> o----------o-------o----------o----------------------o---------
> | | | |
> | | | ,---.
> | | | | X | MOTOR
> | | | PIC '---'
> | | | + __ - |
> .-. .-. '-o| |o---------------)------.
> R | | R | | '-------o| |o--------. | |
> | | | | | .----o| |o-----. | | |
> '-' '-' | | .o|__|o--. | | | |
> | '----' | | | .-. | ||-+ |
> | | | | | | | | ||<- MOSFET
> |-------)-------' | | |R| '---||-+ |
> | | | | '-' | |
> | | | | | | |
> | | .-. .-. '---. '--. |
> | o | o R | | R | | | | |
> |=|> |=|> | | | | ,---. | |
> | o | o '-' '-' | X |LED | |
> | | Unused Unused '---' | |
> | | | | | | |
> | | | | | | |
> | | | | | | |
> | | | | | | |
> | | | | | | |
> | | | | | | |
> o----------o-------o-----------o--------o------o--------o---o--'
> |
> ===
> GND
> (created by AACircuit v1.28.4 beta 13/12/04 www.tech-chat.de)
>
>
> Two switches on the left. Two pins unused, one LED, and one motor.
> That right?

It looks ok to me. I assume you have MCLR disabled and are using the
internal oscillator.



Relevant Pages

  • Re: PMOS in parallel with NMOS
    ... Connect 5 volts directly to the emitter. ... The 0 volts on the base is provided by a microcontroller pin. ... happens to come from an LM7805 voltage regulator. ... I am not as worried about the LEDs as I am the MCU. ...
    (comp.arch.embedded)
  • Re: LM3914 --help :/
    ... The output current for the LEDs is a 10x current mirror of the output ... of the REF OUT pin. ... voltage of 1.25, ...
    (sci.electronics.design)
  • Re: LEDs for dummies
    ... I have been given a bowling pin. ... I will be using 18-24 LEDs of various colors. ... My first problem is that I don't know for sure if those voltage specs ... Each string of LEDs has a nominal Vf of ~18.9 volts. ...
    (sci.electronics.basics)
  • Re: LEDs for dummies
    ... I have been given a bowling pin. ... I will drill holes or wiring and try to place the LEDs in little ... measurement of the voltage drop, or even if there is a difference ...
    (sci.electronics.basics)
  • Re: Gen Set will not remote start
    ... Did you make any voltage measurements? ... switch grounds the appropriate lead to initiate starting and stopping. ... Cut remote control wire near the generator ... generator by jumpering the appropriate pin to ground. ...
    (rec.outdoors.rv-travel)